From a19b8fb2daf4f843793f196da28a15cae0aa7f24 Mon Sep 17 00:00:00 2001 From: miguelhar <98769216+miguelhar@users.noreply.github.com> Date: Tue, 30 Jan 2024 10:33:16 -0500 Subject: [PATCH] PLAT-7889 move config to vpc-cni install (#208) --- modules/eks/cluster.tf | 15 +++++++++++---- .../k8s/templates/k8s-functions.sh.tftpl | 2 -- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/eks/cluster.tf b/modules/eks/cluster.tf index cdf993b9..fe4e68f9 100644 --- a/modules/eks/cluster.tf +++ b/modules/eks/cluster.tf @@ -91,6 +91,16 @@ data "aws_eks_addon_version" "default_vpc_cni" { kubernetes_version = aws_eks_cluster.this.version } +locals { + is_pod_sb = length(var.network_info.subnets.pod) > 0 + vpc_cni_env = merge({ + ENABLE_PREFIX_DELEGATION = tostring(try(var.eks.vpc_cni.prefix_delegation, false)) + ANNOTATE_POD_IP = tostring(try(var.eks.vpc_cni.annotate_pod_ip, true)) + }, local.is_pod_sb ? { + AWS_VPC_K8S_CNI_CUSTOM_NETWORK_CFG = "true" + ENI_CONFIG_LABEL_DEF = "topology.kubernetes.io/zone" } : {}) +} + resource "aws_eks_addon" "vpc_cni" { cluster_name = aws_eks_cluster.this.name addon_name = "vpc-cni" @@ -98,10 +108,7 @@ resource "aws_eks_addon" "vpc_cni" { resolve_conflicts_on_create = "OVERWRITE" resolve_conflicts_on_update = "OVERWRITE" configuration_values = jsonencode({ - env = { - ENABLE_PREFIX_DELEGATION = tostring(try(var.eks.vpc_cni.prefix_delegation, false)) - ANNOTATE_POD_IP = tostring(try(var.eks.vpc_cni.annotate_pod_ip, true)) - } + env = local.vpc_cni_env }) } diff --git a/modules/eks/submodules/k8s/templates/k8s-functions.sh.tftpl b/modules/eks/submodules/k8s/templates/k8s-functions.sh.tftpl index 80789724..4b4aa33d 100644 --- a/modules/eks/submodules/k8s/templates/k8s-functions.sh.tftpl +++ b/modules/eks/submodules/k8s/templates/k8s-functions.sh.tftpl @@ -67,8 +67,6 @@ set_eniconfig() { else printf "$RED $ENICONFIG_YAML does not exist. $EC \n" && exit 1 fi - echo - kubectl_cmd -n kube-system set env daemonset aws-node AWS_VPC_K8S_CNI_CUSTOM_NETWORK_CFG=true ENI_CONFIG_LABEL_DEF=topology.kubernetes.io/zone } remove_calico_cr() {