From 238886a642d5c206fe87f406d644548d59e31da1 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Thu, 10 Oct 2024 19:52:24 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(cleanup):=20remove=20unused?= =?UTF-8?q?=20code=20and=20add=20node=20group=20label?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++++----- main.tf | 16 +++++++++------- variables.tf | 20 +------------------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index ce2fe87..14e6705 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # tfmod-eks Create an EKS cluster given the specification of the cluster. -The module creates an EKS cluster named cluster_name in the region using kuberenetes version cluster_version with eks_ng_desired_size nodes initially. The services in the cluster will be accessible using hostnames for the services ending with the cluster_name.domain fully qualified domain name. The cluster-autoscaler will resize the node group based upon capacity from a minimum of eks_ng_min_size to a maximum of eks_ng_max_size. The eks_instance_types is a prioritized list of instance types to use as the worker nodes. Note that it is best if the vCPU and Mem sizes of all of the instance types are the same. +The module creates an EKS cluster named `cluster_name` in the region using kubernetes version `cluster_version` with `eks_ng_desired_size` nodes initially. The services in the cluster will be accessible using hostnames for the services ending with the `cluster_name.domain` fully qualified domain name. The nodegroup for karpenter will resize based upon capacity from a minimum of `eks_ng_min_size` to a maximum of `eks_ng_max_size`. After initial deployment, karpenter will create a node group for workloads that will autoscale using on-demand or spot instances with compaction based upon running workloads. The cluster is configured with an oidc provider allowing service accounts to be configured with IRSA roles as needed. @@ -85,7 +85,7 @@ Change logs are auto-generated with commitizen. | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.67.0 | +| [aws](#provider\_aws) | 5.70.0 | | [null](#provider\_null) | 3.2.3 | ## Modules @@ -93,7 +93,7 @@ Change logs are auto-generated with commitizen. | Name | Source | Version | |------|--------|---------| | [cloudwatch\_observability\_irsa\_role](#module\_cloudwatch\_observability\_irsa\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a | -| [cluster](#module\_cluster) | git@github.e.it.census.gov:SCT-Engineering/terraform-aws-eks.git | v20.24.1 | +| [cluster](#module\_cluster) | git@github.e.it.census.gov:SCT-Engineering/terraform-aws-eks.git | v20.24.3 | | [ebs\_csi\_irsa\_role](#module\_ebs\_csi\_irsa\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a | | [efs\_csi\_irsa\_role](#module\_efs\_csi\_irsa\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a | | [vpc\_cni\_irsa\_role](#module\_vpc\_cni\_irsa\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | n/a | @@ -130,14 +130,13 @@ Change logs are auto-generated with commitizen. | [cluster\_name](#input\_cluster\_name) | EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev) | `string` | n/a | yes | | [cluster\_version](#input\_cluster\_version) | The Kubernetes version number to use for this EKS cluster. See https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html | `string` | `"1.27"` | no | | [eks\_instance\_disk\_size](#input\_eks\_instance\_disk\_size) | The size of the disk of the worker nodes in gigabytes. 40 is the approximate minimum. Needs to hold the all of the normal operating system files plus every image that will be used in the cluster. | `number` | `80` | no | -| [eks\_instance\_types](#input\_eks\_instance\_types) | EKS worker node instance types | `list(string)` |
[
"t3.xlarge"
]
| no | +| [eks\_instance\_types](#input\_eks\_instance\_types) | EKS worker node instance types | `list(string)` |
[
"t3.small"
]
| no | | [eks\_ng\_desired\_size](#input\_eks\_ng\_desired\_size) | Node Group desired size | `number` | `4` | no | | [eks\_ng\_max\_size](#input\_eks\_ng\_max\_size) | Node Group maximum size | `number` | `15` | no | | [eks\_ng\_min\_size](#input\_eks\_ng\_min\_size) | Node Group minimum size | `number` | `4` | no | | [enable\_cluster\_creator\_admin\_permissions](#input\_enable\_cluster\_creator\_admin\_permissions) | Indicates whether or not to add the cluster creator (the identity used by Terraform) as an administrator via access entry | `bool` | `false` | no | | [profile](#input\_profile) | AWS config profile | `string` | `""` | no | | [subnets\_name](#input\_subnets\_name) | Define the name of the subnets to be used by this cluster | `string` | `"*-container-*"` | no | -| [tag\_costallocation](#input\_tag\_costallocation) | Tag CostAllocation (default) | `string` | `"csvd:infrastructure"` | no | | [tags](#input\_tags) | AWS Tags to apply to appropriate resources | `map(string)` | `{}` | no | | [vpc\_name](#input\_vpc\_name) | Define the VPC name that will be used by this cluster | `string` | n/a | yes | diff --git a/main.tf b/main.tf index 3ab29b3..4aa0708 100644 --- a/main.tf +++ b/main.tf @@ -30,11 +30,11 @@ data "aws_kms_key" "ebs_key" { locals { additional_policies = {} base_tags = { - "boc:eks-cluster-name" = var.cluster_name - "boc:tf_module_name" = local.module_name - "boc:tf_module_version" = local.module_version - "boc:created_by" = "terraform" - CostAllocation = var.tag_costallocation + "boc:eks-cluster-name" = var.cluster_name + "boc:tf_module_name" = local.module_name + "boc:tf_module_version" = local.module_version + "boc:created_by" = "terragrunt" + "karpenter.sh/discovery" = var.cluster_name } max_tag_count = 45 ng_name = format("%v%v-nodegroup", local.prefixes["eks"], var.cluster_name) @@ -45,7 +45,7 @@ locals { } module "cluster" { - source = "git@github.e.it.census.gov:SCT-Engineering/terraform-aws-eks.git?ref=v20.24.1" + source = "git@github.e.it.census.gov:SCT-Engineering/terraform-aws-eks.git?ref=v20.24.3" cluster_name = var.cluster_name cluster_version = var.cluster_version @@ -129,9 +129,11 @@ module "cluster" { } } } + labels = { + intent = "control-apps" + } } } - tags = local.tags } diff --git a/variables.tf b/variables.tf index 6cf7c30..1c50bbf 100644 --- a/variables.tf +++ b/variables.tf @@ -42,7 +42,7 @@ variable "eks_instance_types" { description = "EKS worker node instance types" type = list(string) default = [ - "t3.xlarge" + "t3.small" ] } @@ -79,12 +79,6 @@ variable "census_private_cidr" { default = ["148.129.0.0/16", "172.16.0.0/12", "192.168.0.0/16"] } -variable "tag_costallocation" { - description = "Tag CostAllocation (default)" - type = string - default = "csvd:infrastructure" -} - variable "tags" { description = "AWS Tags to apply to appropriate resources" type = map(string) @@ -96,15 +90,3 @@ variable "profile" { type = string default = "" } - -# variable "region" { -# description = "AWS config region" -# type = string -# default = "" -# } - -# variable "os_username" { -# description = "OS username from environment variable, ideally as $USER" -# type = string -# default = null -# }