Skip to content

Commit 9d35285

Browse files
committed
[single-cluster/aws] Install Calico as the CNI
Fixes #12953 This PR updates the EKS single cluster reference guides to install calico as the CNI. This is important for the network policies to work. For GKE and AKS, There are already options to do the same which we use already instead of doing it manually. Signed-off-by: Tarun Pothulapati <[email protected]>
1 parent 8b94c54 commit 9d35285

File tree

9 files changed

+54
-38
lines changed

9 files changed

+54
-38
lines changed

install/infra/modules/eks/kubernetes.tf

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ module "eks" {
8989
resolve_conflicts = "OVERWRITE"
9090
}
9191
kube-proxy = {}
92-
vpc-cni = {
93-
resolve_conflicts = "OVERWRITE"
94-
service_account_role_arn = module.vpc_cni_irsa.iam_role_arn
95-
}
9692
}
9793

9894
eks_managed_node_group_defaults = {
@@ -245,22 +241,6 @@ module "eks" {
245241
}
246242
}
247243

248-
module "vpc_cni_irsa" {
249-
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
250-
version = "~> 4.12"
251-
252-
role_name_prefix = "VPC-CNI-IRSA"
253-
attach_vpc_cni_policy = true
254-
vpc_cni_enable_ipv4 = true
255-
256-
oidc_providers = {
257-
main = {
258-
provider_arn = module.eks.oidc_provider_arn
259-
namespace_service_accounts = ["kube-system:aws-node"]
260-
}
261-
}
262-
}
263-
264244
resource "null_resource" "kubeconfig" {
265245
depends_on = [module.eks]
266246
provisioner "local-exec" {

install/infra/modules/eks/local.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
locals {
2-
aws_cert_manager_enabled = local.domain_name_enabled && var.use_aws_cert_manager == true
3-
aws_cert_manager_count = local.aws_cert_manager_enabled ? 1 : 0
4-
domain_name_enabled = var.domain_name != ""
5-
domain_name_count = local.domain_name_enabled ? 1 : 0
6-
}
1+
locals {
2+
aws_cert_manager_enabled = local.domain_name_enabled && var.use_aws_cert_manager == true
3+
aws_cert_manager_count = local.aws_cert_manager_enabled ? 1 : 0
4+
domain_name_enabled = var.domain_name != ""
5+
domain_name_count = local.domain_name_enabled ? 1 : 0
6+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
terraform {
22
required_providers {
33
aws = {
4-
version = " ~> 3.0"
5-
source = "registry.terraform.io/hashicorp/aws"
4+
version = " ~> 3.0"
5+
source = "registry.terraform.io/hashicorp/aws"
66
}
77
helm = {
88
source = "hashicorp/helm"
@@ -12,5 +12,5 @@ terraform {
1212
}
1313

1414
provider "aws" {
15-
region = var.region
15+
region = var.region
1616
}

install/infra/modules/eks/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ variable "vpc_availability_zones" {
4343
}
4444

4545
variable "domain_name" {
46-
default = ""
46+
default = ""
4747
description = "Domain name to associate with the route53 zone"
4848
}
4949

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
variable "kubeconfig" {
2+
description = "Path to the KUBECONFIG file to connect to the cluster"
3+
default = "./kubeconfig"
4+
}
5+
6+
provider "helm" {
7+
kubernetes {
8+
config_path = var.kubeconfig
9+
}
10+
}
11+
12+
resource "helm_release" "calico" {
13+
name = "tigera-operator"
14+
repository = "https://projectcalico.docs.tigera.io/charts"
15+
chart = "tigera-operator"
16+
namespace = "tigera-operator"
17+
version = "v3.24.1"
18+
create_namespace = true
19+
}

install/infra/modules/tools/azure-external-dns/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
variable settings {}
2-
variable domain_name { default = "test"}
3-
variable kubeconfig { default = "conf"}
4-
variable txt_owner_id { default = "nightly-test"}
1+
variable "settings" {}
2+
variable "domain_name" { default = "test" }
3+
variable "kubeconfig" { default = "conf" }
4+
variable "txt_owner_id" { default = "nightly-test" }
55

66
provider "helm" {
77
kubernetes {

install/infra/single-cluster/aws/Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ plan-cluster:
2626
@terraform plan -target=module.eks
2727

2828
.PHONY: plan-tools
29-
plan-tools: plan-cm-edns plan-cluster-issuer plan-cluster-autoscaler
29+
plan-tools: plan-calico plan-cm-edns plan-cluster-issuer plan-cluster-autoscaler
3030

3131
.PHONY: plan-cluster-autoscaler
3232
plan-cluster-autoscaler:
3333
@terraform plan -target=module.cluster-autoscaler
3434

35+
.PHONY: plan-calico
36+
plan-calico:
37+
@terraform plan -target=module.calico
38+
3539
.PHONY: plan-cm-edns
3640
plan-cm-edns:
3741
@terraform plan -target=module.certmanager -target=module.externaldns
@@ -45,7 +49,11 @@ apply-cluster:
4549
@terraform apply -target=module.eks --auto-approve
4650

4751
.PHONY: apply-tools
48-
apply-tools: install-cm-edns install-cluster-issuer install-cluster-autoscaler
52+
apply-tools: install-calico install-cm-edns install-cluster-issuer install-cluster-autoscaler
53+
54+
.PHONY: install-calico
55+
install-calico:
56+
@terraform apply -target=module.calico --auto-approve
4957

5058
.PHONY: install-cluster-autoscaler
5159
install-cluster-autoscaler:
@@ -64,7 +72,11 @@ destroy-cluster:
6472
@terraform destroy -target=module.eks --auto-approve
6573

6674
.PHONY: destroy-tools
67-
destroy-tools: destroy-cluster-issuer destroy-cm-edns destroy-cluster-autoscaler
75+
destroy-tools: destroy-calico destroy-cluster-issuer destroy-cm-edns destroy-cluster-autoscaler
76+
77+
.PHONY: destroy-calico
78+
destroy-calico:
79+
@terraform destroy -target=module.calico --auto-approve
6880

6981
.PHONY: destroy-cluster-autoscaler
7082
destroy-cluster-autoscaler:

install/infra/single-cluster/aws/output.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ output "url" {
33
}
44

55
output "cluster_name" {
6-
value = var.cluster_name
6+
value = var.cluster_name
77
}
88

99
output "registry_backend" {

install/infra/single-cluster/aws/tools.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ module "cluster-autoscaler" {
2929
cluster_id = module.eks.cluster_id
3030
oidc_provider_arn = module.eks.oidc_provider_arn
3131
}
32+
33+
module "calico" {
34+
source = "../../modules/tools/aws-calico"
35+
kubeconfig = var.kubeconfig
36+
}

0 commit comments

Comments
 (0)