Skip to content

Subnet Handling #28

Merged
merged 2 commits into from
Mar 6, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ The module deploys Karpenter needed AWS resources, namely in IAM. It copies the
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.14.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.11.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2.1 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.15.0 |
| <a name="provider_aws.eecr"></a> [aws.eecr](#provider\_aws.eecr) | 6.15.0 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | 3.0.2 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.33.0 |
| <a name="provider_aws.eecr"></a> [aws.eecr](#provider\_aws.eecr) | 6.33.0 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | 3.1.1 |
| <a name="provider_null"></a> [null](#provider\_null) | 3.2.4 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_images"></a> [images](#module\_images) | git::https://github.e.it.census.gov/terraform-modules/aws-ecr-copy-images.git | tf-upgrade |
| <a name="module_karpenter_resources"></a> [karpenter\_resources](#module\_karpenter\_resources) | git::https://github.e.it.census.gov/SCT-Engineering/terraform-aws-eks.git//modules/karpenter | v21.11.0 |
| <a name="module_karpenter_resources"></a> [karpenter\_resources](#module\_karpenter\_resources) | git::https://github.e.it.census.gov/SCT-Engineering/terraform-aws-eks.git//modules/karpenter | v21.15.1 |

## Resources

Expand Down Expand Up @@ -69,7 +69,7 @@ The module deploys Karpenter needed AWS resources, namely in IAM. It copies the
| <a name="input_oidc_provider_arn"></a> [oidc\_provider\_arn](#input\_oidc\_provider\_arn) | The ARN of the OIDC Provider if `enable_irsa = true` | `string` | `""` | no |
| <a name="input_profile"></a> [profile](#input\_profile) | AWS config profile | `string` | `""` | no |
| <a name="input_region"></a> [region](#input\_region) | AWS region | `string` | n/a | yes |
| <a name="input_subnets_name"></a> [subnets\_name](#input\_subnets\_name) | Define the name of the subnets to be used by this cluster | `string` | `"*-container-*"` | no |
| <a name="input_subnets"></a> [subnets](#input\_subnets) | Subnet IDs used to derive a subnet Name tag (optional) | `list(string)` | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | AWS Tags to apply to appropriate resources | `map(string)` | `{}` | no |

## Outputs
Expand Down
9 changes: 4 additions & 5 deletions karpenter-resources/values.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ ec2NodeClass:
amiSelectorTerms:
- alias: ${amd_ami_alias}
subnetSelectorTerms:
- tags:
Name: "${subnets_name}"
${subnets}
securityGroupSelectorTerms:
- tags:
Name: "${cluster_name}-node"
Expand Down Expand Up @@ -42,9 +41,9 @@ nodePool:
disruption:
consolidationPolicy: "WhenEmptyOrUnderutilized"
consolidateAfter: "5m"
limits:
cpu: "1000"
memory: 1000Gi
# limits:
# cpu: "1000"
# memory: 1000Gi
weight: 1
labels: {}
taints: []
Expand Down
10 changes: 6 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ locals {
max_rule_name_length = 8
rule_name_prefix = length(local.rule_name_raw) > local.max_rule_name_length ? substr(local.rule_name_raw, 0, local.max_rule_name_length) : local.rule_name_raw
queue_name = format("%v%v", local.prefixes["eks-queue"], var.cluster_name)
subnet_ids = try(tolist(var.subnets), [])

}

# Replicating from here: https://github.e.it.census.gov/SCT-Engineering/terraform-aws-eks/tree/master/modules/karpenter
# Karpenter IRSA roles and policies
module "karpenter_resources" {
source = "git::https://github.e.it.census.gov/SCT-Engineering/terraform-aws-eks.git//modules/karpenter?ref=v21.11.0"
source = "git::https://github.e.it.census.gov/SCT-Engineering/terraform-aws-eks.git//modules/karpenter?ref=v21.15.1"

cluster_name = var.cluster_name
create_access_entry = true
Expand Down Expand Up @@ -84,7 +86,7 @@ resource "helm_release" "karpenter" {
})
]

timeout = 600
timeout = 900
wait = true
}

Expand All @@ -103,12 +105,12 @@ resource "helm_release" "nodepool_resources" {
amd_ami_family = local.amd_ami_family
cluster_name = var.cluster_name
karpenter_node_profile = module.karpenter_resources.instance_profile_name
subnets_name = var.subnets_name
subnets = join("\n", [for id in local.subnet_ids : " - id: ${id}"])
tags = var.tags
})
]

timeout = 600
timeout = 900
wait = true
}

Expand Down
2 changes: 1 addition & 1 deletion requirements.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.14.0"
version = ">= 6.0"
}
helm = {
source = "hashicorp/helm"
Expand Down
8 changes: 4 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ variable "region" {
type = string
}

variable "subnets_name" {
description = "Define the name of the subnets to be used by this cluster"
type = string
default = "*-container-*"
variable "subnets" {
description = "Subnet IDs used to derive a subnet Name tag (optional)"
type = list(string)
default = []
}

variable "tags" {
Expand Down