From d152102f6a57420277ecbf5a1ef5795e5a453033 Mon Sep 17 00:00:00 2001 From: mcgin314 Date: Tue, 25 Jun 2024 12:27:58 -0400 Subject: [PATCH 1/2] Update example and align to upgraded 1.30 EKS version --- cluster_autoscaler.tf | 39 ++++++++++++++++++---------- examples/simple/eks-configuration.tf | 7 +++-- examples/simple/simple.auto.tfvars | 31 +++++++++++++++------- examples/simple/variables.tf | 5 ++++ outputs.tf | 16 ++++++------ variables.tf | 12 ++++++--- 6 files changed, 74 insertions(+), 36 deletions(-) diff --git a/cluster_autoscaler.tf b/cluster_autoscaler.tf index 53cf973..6b8c284 100644 --- a/cluster_autoscaler.tf +++ b/cluster_autoscaler.tf @@ -8,22 +8,34 @@ locals { ng_asg_name = var.eks_managed_node_groups_autoscaling_group_names[0] } -module "cluster_autoscaler_irsa_role" { - source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" +# module "cluster_autoscaler_irsa_role" { +# source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" - role_name = "${var.cluster_name}-cluster-autoscaler" +# role_name = "${var.cluster_name}-cluster-autoscaler" - attach_cluster_autoscaler_policy = true +# attach_cluster_autoscaler_policy = true - cluster_autoscaler_cluster_names = [var.cluster_name] +# cluster_autoscaler_cluster_names = [var.cluster_name] - oidc_providers = { - main = { - provider_arn = var.oidc_provider_arn - namespace_service_accounts = ["kube-system:cluster-autoscaler"] - } +# oidc_providers = { +# main = { +# provider_arn = var.oidc_provider_arn +# namespace_service_accounts = ["kube-system:cluster-autoscaler"] +# } +# } +# tags = local.tags +# } + +# ALTERNATELY WE PASS THIS VIA OUTPUT DEPENDENCY W/ TERRAGRUNT +data "aws_iam_role" "cluster_autoscaler_irsa_role" { + name = "${var.cluster_name}-cluster-autoscaler" +} + +#### NEED TO MOVE THIS TO A PROPER PLACE +resource "kubernetes_namespace" "operators" { + metadata { + name = var.operators_ns } - tags = local.tags } resource "aws_autoscaling_group_tag" "on-demand" { @@ -79,12 +91,13 @@ resource "helm_release" "cluster-autoscaler" { set { name = "rbac.serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn" - value = module.cluster_autoscaler_irsa_role.iam_role_arn + value = data.aws_iam_role.cluster_autoscaler_irsa_role.arn + # value = module.cluster_autoscaler_irsa_role.iam_role_arn } set { name = "rbac.serviceAccount.create" - value = "false" + value = "true" } } diff --git a/examples/simple/eks-configuration.tf b/examples/simple/eks-configuration.tf index 2005892..a0e95a2 100644 --- a/examples/simple/eks-configuration.tf +++ b/examples/simple/eks-configuration.tf @@ -1,6 +1,7 @@ module "eks-configuration" { - source = "git@github.it.census.gov:SOA/tfmod-eks-storage-classes.git//" - #source = "git@github.it.census.gov:SOA/tfmod-eks-configuration.git//?ref=v1.0.0" + # source = "git@github.it.census.gov:SOA/tfmod-eks-configuration.git//" + source = "../.." + # source = "git@github.it.census.gov:SOA/tfmod-eks-configuration.git//?ref=v1.0.0" region = var.region profile = var.profile @@ -12,4 +13,6 @@ module "eks-configuration" { oidc_provider_arn = var.oidc_provider_arn eks_managed_node_groups_autoscaling_group_names = var.eks_managed_node_groups_autoscaling_group_names + + tags = var.tags } diff --git a/examples/simple/simple.auto.tfvars b/examples/simple/simple.auto.tfvars index 9fab5ab..c7b6caf 100644 --- a/examples/simple/simple.auto.tfvars +++ b/examples/simple/simple.auto.tfvars @@ -1,16 +1,27 @@ region = "us-gov-east-1" -profile = "107742151971-do2-govcloud" -cluster_name = "adsd-cumulus-sandbox" +profile = "terraform" +cluster_name = "platform-test-1" -vpc_id = "vpc-0d71dc78076c0e0b3" +vpc_id = "vpc-0280f77b373744eaa" subnets = [ - "subnet-004f46dfe18f4cd53", - "subnet-00dba5a2905c7fe70", - "subnet-0360b208aa4feefd6", + "subnet-078b228071c609a50", + "subnet-02c2250b9ec2dd6a2", + "subnet-07a6339be3670fb41", ] -security_group_all_worker_mgmt_id = "sg-0208882843ec79a56" - -oidc_provider_arn = "arn:aws-us-gov:iam::107742151971:oidc-provider/oidc.eks.us-gov-east-1.amazonaws.com/id/7FE48CFA5D16E37DFCCB764674F0A212" -eks_managed_node_groups_autoscaling_group_names = [""] +security_group_all_worker_mgmt_id = "sg-08d7d5d8cff75c1d3" +oidc_provider_arn = "arn:aws-us-gov:iam::224384469011:oidc-provider/oidc.eks.us-gov-east-1.amazonaws.com/id/EA906CF6F61F76098A45EEE3BA96B161" +eks_managed_node_groups_autoscaling_group_names = ["eks-eks-platform-test-1-nodegroup-20240528141016973700000016-2cc7dfc4-cca4-345f-c0a2-ab63401f0cd9"] +tags = { + project_number = "fs0000000078" + project_name = "csvd_platformbaseline" + project_role = "csvd_platformbaseline_app" + organization = "census:ocio:csvd" + created_by = "luther.coleman.mcginty@census.gov" + created_for = "luther.coleman.mcginty@census.gov" + created_reason = "Testing eks module operation" + Terraform = "true" + Terragrunt = "true" + test_adjustment = "testing adding tags" +} diff --git a/examples/simple/variables.tf b/examples/simple/variables.tf index 0bfe98e..a822a7d 100644 --- a/examples/simple/variables.tf +++ b/examples/simple/variables.tf @@ -38,3 +38,8 @@ variable "oidc_provider_arn" { type = string } +variable "tags" { + description = "AWS Tags to apply to appropriate resources" + type = map(string) + default = {} +} \ No newline at end of file diff --git a/outputs.tf b/outputs.tf index ddfe7c4..67f697c 100644 --- a/outputs.tf +++ b/outputs.tf @@ -29,14 +29,14 @@ output "rwx_storage_class" { ################################################################################ # IRSA Roles created ################################################################################ -output "cluster_autoscaler_irsa_role" { - description = "The arn/name/unique_id of the irsa role for the cluster autoscaler addon" - value = { - arn = module.cluster_autoscaler_irsa_role.iam_role_arn - name = module.cluster_autoscaler_irsa_role.iam_role_name - unique_id = module.cluster_autoscaler_irsa_role.iam_role_unique_id - } -} +# output "cluster_autoscaler_irsa_role" { +# description = "The arn/name/unique_id of the irsa role for the cluster autoscaler addon" +# value = { +# arn = module.cluster_autoscaler_irsa_role.iam_role_arn +# name = module.cluster_autoscaler_irsa_role.iam_role_name +# unique_id = module.cluster_autoscaler_irsa_role.iam_role_unique_id +# } +# } ################################################################################ # Details about kubectl image diff --git a/variables.tf b/variables.tf index a874cfe..496e5f5 100644 --- a/variables.tf +++ b/variables.tf @@ -39,6 +39,12 @@ variable "oidc_provider_arn" { type = string } +variable "operators_ns" { + description = "Namespace to create where operators will be installed." + type = string + default = "operators" +} + variable "tag_costallocation" { description = "Tag CostAllocation (default)" type = string @@ -54,7 +60,7 @@ variable "tags" { variable "kubectl_image_tag" { description = "The version of bitnami/kubectl image to use." type = string - default = "1.27.1" + default = "1.27.14" } # helm add repo autoscaler "https://kubernetes.github.io/autoscaler" @@ -62,12 +68,12 @@ variable "kubectl_image_tag" { variable "cluster_autoscaler_chart_version" { description = "The helm chart of the cluster-autoscaler most closely matching the Kuberentes version. Review output of `helm add repo autoscaler 'https://kubernetes.github.io/autoscaler'` (if the repo hasn't been added previously) and `helm search repo -l autoscaler/cluster-autoscaler`" type = string - default = "9.29.3" + default = "9.37.0" } # helm show values --version [cluster_autoscaler_chart_version] autoscaler/cluster-autoscaler | grep tag: variable "cluster_autoscaler_tag" { description = "Image tag of cluster-autoscaler associated with the cluster_autoscaler_chart_version helm chart. `helm show values --version [cluster_autoscaler_chart_version] autoscaler/cluster-autoscaler | grep tag:`" type = string - default = "v1.27.2" + default = "v1.30.0" } From fa89db7ee2c5c67a3ab4c959b712857528843a3d Mon Sep 17 00:00:00 2001 From: mcgin314 Date: Tue, 25 Jun 2024 13:07:11 -0400 Subject: [PATCH 2/2] Better explanation of example variables --- examples/simple/simple.auto.tfvars | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/simple/simple.auto.tfvars b/examples/simple/simple.auto.tfvars index c7b6caf..fef01fc 100644 --- a/examples/simple/simple.auto.tfvars +++ b/examples/simple/simple.auto.tfvars @@ -1,3 +1,4 @@ +# Generally these values originate from or need to match those in tfmod-eks region = "us-gov-east-1" profile = "terraform" cluster_name = "platform-test-1" @@ -9,6 +10,7 @@ subnets = [ "subnet-07a6339be3670fb41", ] +# These values are outputs of tfmod-eks security_group_all_worker_mgmt_id = "sg-08d7d5d8cff75c1d3" oidc_provider_arn = "arn:aws-us-gov:iam::224384469011:oidc-provider/oidc.eks.us-gov-east-1.amazonaws.com/id/EA906CF6F61F76098A45EEE3BA96B161" eks_managed_node_groups_autoscaling_group_names = ["eks-eks-platform-test-1-nodegroup-20240528141016973700000016-2cc7dfc4-cca4-345f-c0a2-ab63401f0cd9"]