From 55fffea8b941bb4a264ae7ef87746fd4c367c493 Mon Sep 17 00:00:00 2001 From: Flamarion Jorge Date: Mon, 14 Oct 2024 12:31:51 +0200 Subject: [PATCH 1/3] fix: Allow EKS addons version config --- main.tf | 7 ++++++ modules/app_eks/add-ons.tf | 40 +++++++++++++++---------------- modules/app_eks/main.tf | 10 ++++---- modules/app_eks/variables.tf | 30 +++++++++++++++++++++++ modules/app_lb/outputs.tf | 4 ++-- modules/endpoint/main.tf | 10 ++++---- modules/endpoint/variables.tf | 10 ++++---- modules/iam_role/variables.tf | 2 +- modules/private_link/main.tf | 10 ++++---- modules/private_link/variables.tf | 4 ++-- variables.tf | 31 ++++++++++++++++++++++++ 11 files changed, 113 insertions(+), 45 deletions(-) diff --git a/main.tf b/main.tf index 8bece8a3..4a630e81 100644 --- a/main.tf +++ b/main.tf @@ -171,6 +171,13 @@ module "app_eks" { system_reserved_pid = var.system_reserved_pid aws_loadbalancer_controller_tags = var.aws_loadbalancer_controller_tags + + eks_addon_efs_csi_driver_version = var.eks_addon_efs_csi_driver_version + eks_addon_ebs_csi_driver_version = var.eks_addon_ebs_csi_driver_version + eks_addon_coredns_version = var.eks_addon_coredns_version + eks_addon_kube_proxy_version = var.eks_addon_kube_proxy_version + eks_addon_vpc_cni_version = var.eks_addon_vpc_cni_version + } locals { diff --git a/modules/app_eks/add-ons.tf b/modules/app_eks/add-ons.tf index 3db67c0f..3265aa0f 100644 --- a/modules/app_eks/add-ons.tf +++ b/modules/app_eks/add-ons.tf @@ -32,43 +32,43 @@ resource "aws_iam_role" "oidc" { ### add-ons for eks version 1.28 resource "aws_eks_addon" "aws_efs_csi_driver" { - depends_on = [ - aws_eks_addon.vpc_cni - ] - cluster_name = var.namespace - addon_name = "aws-efs-csi-driver" - addon_version = "v2.0.4-eksbuild.1" - resolve_conflicts = "OVERWRITE" + depends_on = [ + aws_eks_addon.vpc_cni + ] + cluster_name = var.namespace + addon_name = "aws-efs-csi-driver" + addon_version = var.eks_addon_efs_csi_driver_version + resolve_conflicts = "OVERWRITE" } resource "aws_eks_addon" "aws_ebs_csi_driver" { depends_on = [ aws_eks_addon.vpc_cni ] - cluster_name = var.namespace - addon_name = "aws-ebs-csi-driver" - addon_version = "v1.31.0-eksbuild.1" - resolve_conflicts = "OVERWRITE" + cluster_name = var.namespace + addon_name = "aws-ebs-csi-driver" + addon_version = var.eks_addon_ebs_csi_driver_version + resolve_conflicts = "OVERWRITE" } resource "aws_eks_addon" "coredns" { depends_on = [ aws_eks_addon.vpc_cni ] - cluster_name = var.namespace - addon_name = "coredns" - addon_version = "v1.10.1-eksbuild.11" - resolve_conflicts = "OVERWRITE" + cluster_name = var.namespace + addon_name = "coredns" + addon_version = var.eks_addon_coredns_version + resolve_conflicts = "OVERWRITE" } resource "aws_eks_addon" "kube_proxy" { depends_on = [ aws_eks_addon.vpc_cni ] - cluster_name = var.namespace - addon_name = "kube-proxy" - addon_version = "v1.28.8-eksbuild.5" - resolve_conflicts = "OVERWRITE" + cluster_name = var.namespace + addon_name = "kube-proxy" + addon_version = var.eks_addon_kube_proxy_version + resolve_conflicts = "OVERWRITE" } resource "aws_eks_addon" "vpc_cni" { @@ -77,7 +77,7 @@ resource "aws_eks_addon" "vpc_cni" { ] cluster_name = var.namespace addon_name = "vpc-cni" - addon_version = "v1.18.2-eksbuild.1" + addon_version = var.eks_addon_vpc_cni_version resolve_conflicts = "OVERWRITE" service_account_role_arn = aws_iam_role.oidc.arn } diff --git a/modules/app_eks/main.tf b/modules/app_eks/main.tf index 2e8620b5..50234fb8 100644 --- a/modules/app_eks/main.tf +++ b/modules/app_eks/main.tf @@ -75,7 +75,7 @@ resource "kubernetes_annotations" "gp2" { api_version = "storage.k8s.io/v1" kind = "StorageClass" force = "true" - depends_on = [module.eks] + depends_on = [module.eks] metadata { name = "gp2" @@ -92,14 +92,14 @@ resource "kubernetes_storage_class" "gp3" { "storageclass.kubernetes.io/is-default-class" = "true" } } - depends_on = [kubernetes_annotations.gp2] + depends_on = [kubernetes_annotations.gp2] storage_provisioner = "kubernetes.io/aws-ebs" parameters = { fsType = "ext4" - type = "gp3" + type = "gp3" } - reclaim_policy = "Delete" - volume_binding_mode = "WaitForFirstConsumer" + reclaim_policy = "Delete" + volume_binding_mode = "WaitForFirstConsumer" allow_volume_expansion = true } diff --git a/modules/app_eks/variables.tf b/modules/app_eks/variables.tf index ff2d4ce6..188f0279 100644 --- a/modules/app_eks/variables.tf +++ b/modules/app_eks/variables.tf @@ -151,3 +151,33 @@ variable "aws_loadbalancer_controller_tags" { type = map(string) default = {} } + +variable "eks_addon_efs_csi_driver_version" { + description = "The version of the EFS CSI driver to install." + type = string + default = "v2.0.4-eksbuild.1" +} + +variable "eks_addon_ebs_csi_driver_version" { + description = "The version of the EBS CSI driver to install." + type = string + default = "v1.31.0-eksbuild.1" +} + +variable "eks_addon_coredns_version" { + description = "The version of the CoreDNS addon to install." + type = string + default = "v1.10.1-eksbuild.11" +} + +variable "eks_addon_kube_proxy_version" { + description = "The version of the kube-proxy addon to install." + type = string + default = "v1.28.8-eksbuild.5" +} + +variable "eks_addon_vpc_cni_version" { + description = "The version of the VPC CNI addon to install." + type = string + default = "v1.18.2-eksbuild.1" +} diff --git a/modules/app_lb/outputs.tf b/modules/app_lb/outputs.tf index 20724c32..6f8fa61f 100644 --- a/modules/app_lb/outputs.tf +++ b/modules/app_lb/outputs.tf @@ -15,9 +15,9 @@ output "tg_app_arn" { } output "alb_name" { -value = aws_lb.alb.arn + value = aws_lb.alb.arn } output "nlb_security_group" { - value = var.enable_private_only_traffic? aws_security_group.inbound_private[0].id : null + value = var.enable_private_only_traffic ? aws_security_group.inbound_private[0].id : null } \ No newline at end of file diff --git a/modules/endpoint/main.tf b/modules/endpoint/main.tf index dc64c71c..2c8ebe6b 100644 --- a/modules/endpoint/main.tf +++ b/modules/endpoint/main.tf @@ -1,9 +1,9 @@ resource "aws_vpc_endpoint" "default" { - vpc_id = var.network_id - service_name = var.service_name - vpc_endpoint_type = "Gateway" - auto_accept = true - route_table_ids = var.private_route_table_id + vpc_id = var.network_id + service_name = var.service_name + vpc_endpoint_type = "Gateway" + auto_accept = true + route_table_ids = var.private_route_table_id policy = < Date: Tue, 15 Oct 2024 09:47:17 +0200 Subject: [PATCH 2/3] Fix duplication of default values --- modules/app_eks/cluster_autoscaler/cluster_autoscaler.tf | 8 ++++---- modules/app_eks/variables.tf | 5 ----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/app_eks/cluster_autoscaler/cluster_autoscaler.tf b/modules/app_eks/cluster_autoscaler/cluster_autoscaler.tf index b7930fc7..594dc213 100644 --- a/modules/app_eks/cluster_autoscaler/cluster_autoscaler.tf +++ b/modules/app_eks/cluster_autoscaler/cluster_autoscaler.tf @@ -1,10 +1,10 @@ data "aws_region" "current" {} resource "helm_release" "cluster-autoscaler" { - chart = "cluster-autoscaler" - name = "cluster-autoscaler" - repository = "https://kubernetes.github.io/autoscaler" - namespace = "cluster-autoscaler" + chart = "cluster-autoscaler" + name = "cluster-autoscaler" + repository = "https://kubernetes.github.io/autoscaler" + namespace = "cluster-autoscaler" create_namespace = true set { diff --git a/modules/app_eks/variables.tf b/modules/app_eks/variables.tf index 7ab20a88..5b79a2d0 100644 --- a/modules/app_eks/variables.tf +++ b/modules/app_eks/variables.tf @@ -161,29 +161,24 @@ variable "aws_loadbalancer_controller_tags" { variable "eks_addon_efs_csi_driver_version" { description = "The version of the EFS CSI driver to install." type = string - default = "v2.0.7-eksbuild.1" } variable "eks_addon_ebs_csi_driver_version" { description = "The version of the EBS CSI driver to install." type = string - default = "v1.35.0-eksbuild.1" } variable "eks_addon_coredns_version" { description = "The version of the CoreDNS addon to install." type = string - default = "v1.11.3-eksbuild.1" } variable "eks_addon_kube_proxy_version" { description = "The version of the kube-proxy addon to install." type = string - default = "v1.29.7-eksbuild.9" } variable "eks_addon_vpc_cni_version" { description = "The version of the VPC CNI addon to install." type = string - default = "v1.18.3-eksbuild.3" } From 31c49e9c139680eeb10205bce08b7b06e04e4182 Mon Sep 17 00:00:00 2001 From: Flamarion Jorge Date: Tue, 15 Oct 2024 10:12:37 +0200 Subject: [PATCH 3/3] Add doc reference --- modules/app_eks/variables.tf | 10 +++++----- variables.tf | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/app_eks/variables.tf b/modules/app_eks/variables.tf index 5b79a2d0..1dab64c2 100644 --- a/modules/app_eks/variables.tf +++ b/modules/app_eks/variables.tf @@ -159,26 +159,26 @@ variable "aws_loadbalancer_controller_tags" { } variable "eks_addon_efs_csi_driver_version" { - description = "The version of the EFS CSI driver to install." + description = "The version of the EFS CSI driver to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html." type = string } variable "eks_addon_ebs_csi_driver_version" { - description = "The version of the EBS CSI driver to install." + description = "The version of the EBS CSI driver to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html." type = string } variable "eks_addon_coredns_version" { - description = "The version of the CoreDNS addon to install." + description = "The version of the CoreDNS addon to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html." type = string } variable "eks_addon_kube_proxy_version" { - description = "The version of the kube-proxy addon to install." + description = "The version of the kube-proxy addon to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html." type = string } variable "eks_addon_vpc_cni_version" { - description = "The version of the VPC CNI addon to install." + description = "The version of the VPC CNI addon to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html." type = string } diff --git a/variables.tf b/variables.tf index 9b6f4475..2113f8dd 100644 --- a/variables.tf +++ b/variables.tf @@ -418,33 +418,33 @@ variable "aws_loadbalancer_controller_tags" { } variable "eks_addon_efs_csi_driver_version" { - description = "The version of the EFS CSI driver to install." + description = "The version of the EFS CSI driver to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html." type = string - default = "v2.0.4-eksbuild.1" + default = "v2.0.7-eksbuild.1" } variable "eks_addon_ebs_csi_driver_version" { - description = "The version of the EBS CSI driver to install." + description = "The version of the EBS CSI driver to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html." type = string - default = "v1.31.0-eksbuild.1" + default = "v1.35.0-eksbuild.1" } variable "eks_addon_coredns_version" { - description = "The version of the CoreDNS addon to install." + description = "The version of the CoreDNS addon to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html." type = string - default = "v1.10.1-eksbuild.11" + default = "v1.11.3-eksbuild.1" } variable "eks_addon_kube_proxy_version" { - description = "The version of the kube-proxy addon to install." + description = "The version of the kube-proxy addon to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html." type = string - default = "v1.28.8-eksbuild.5" + default = "v1.29.7-eksbuild.9" } variable "eks_addon_vpc_cni_version" { - description = "The version of the VPC CNI addon to install." + description = "The version of the VPC CNI addon to install. Check the docs for more information about the compatibility https://docs.aws.amazon.com/eks/latest/userguide/vpc-add-on-update.html.s" type = string - default = "v1.18.2-eksbuild.1" + default = "v1.18.3-eksbuild.3" }