Skip to content

Commit

Permalink
fix(subnets) fix how subnets are handled when multiple vpcs are prese…
Browse files Browse the repository at this point in the history
…nt in the account
  • Loading branch information
morga471 committed Feb 23, 2026
1 parent 67c87e4 commit 1e76186
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ 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
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
4 changes: 3 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ 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
Expand Down Expand Up @@ -103,7 +105,7 @@ 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
})
]
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

0 comments on commit 1e76186

Please sign in to comment.