Skip to content

Commit

Permalink
fix: Allow instance_requirements to be set in self-managed node gro…
Browse files Browse the repository at this point in the history
…ups (#3455)
  • Loading branch information
Bryant Biggs authored and GitHub committed Jul 30, 2025
1 parent 1f2f95a commit 5322bf7
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 69 deletions.
2 changes: 1 addition & 1 deletion modules/self-managed-node-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ resource "aws_launch_template" "this" {
}
}

instance_type = var.instance_type
instance_type = var.instance_requirements != null ? null : var.instance_type
kernel_id = var.kernel_id
key_name = var.key_name

Expand Down
141 changes: 73 additions & 68 deletions tests/self-managed-node-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,79 @@ module "eks" {
}
}

# Complete
instance_attributes = {
name = "instance-attributes"

min_size = 1
max_size = 2
desired_size = 1

cloudinit_pre_nodeadm = [{
content = <<-EOT
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
kubelet:
config:
shutdownGracePeriod: 30s
EOT
content_type = "application/node.eks.aws"
}]

instance_type = null

# launch template configuration
instance_requirements = {
cpu_manufacturers = ["intel"]
instance_generations = ["current", "previous"]
spot_max_price_percentage_over_lowest_price = 100

memory_mib = {
min = 8192
}

vcpu_count = {
min = 1
}

allowed_instance_types = ["t*", "m*"]
}

use_mixed_instances_policy = true
mixed_instances_policy = {
instances_distribution = {
on_demand_base_capacity = 0
on_demand_percentage_above_base_capacity = 0
on_demand_allocation_strategy = "lowest-price"
spot_allocation_strategy = "price-capacity-optimized"
}

# ASG configuration
launch_template = {
override = [
{
instance_requirements = {
cpu_manufacturers = ["intel"]
instance_generations = ["current", "previous"]
spot_max_price_percentage_over_lowest_price = 100

memory_mib = {
min = 8192
}

vcpu_count = {
min = 1
}

allowed_instance_types = ["t*", "m*"]
}
}
]
}
}
}

complete = {
name = "complete-self-mng"
use_name_prefix = false
Expand Down Expand Up @@ -212,73 +284,6 @@ module "eks" {
}
}

instance_attributes = {
name = "instance-attributes"

min_size = 1
max_size = 2
desired_size = 1

bootstrap_extra_args = "--kubelet-extra-args '--node-labels=node.kubernetes.io/lifecycle=spot'"

cloudinit_pre_nodeadm = [{
content = <<-EOT
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
kubelet:
config:
shutdownGracePeriod: 30s
EOT
content_type = "application/node.eks.aws"
}]

instance_type = null

# launch template configuration
instance_requirements = {
cpu_manufacturers = ["intel"]
instance_generations = ["current", "previous"]
spot_max_price_percentage_over_lowest_price = 100

vcpu_count = {
min = 1
}

allowed_instance_types = ["t*", "m*"]
}

use_mixed_instances_policy = true
mixed_instances_policy = {
instances_distribution = {
on_demand_base_capacity = 0
on_demand_percentage_above_base_capacity = 0
on_demand_allocation_strategy = "lowest-price"
spot_allocation_strategy = "price-capacity-optimized"
}

# ASG configuration
launch_template = {
override = [
{
instance_requirements = {
cpu_manufacturers = ["intel"]
instance_generations = ["current", "previous"]
spot_max_price_percentage_over_lowest_price = 100

vcpu_count = {
min = 1
}

allowed_instance_types = ["t*", "m*"]
}
}
]
}
}
}

metadata_options = {
http_endpoint = "enabled"
http_tokens = "required"
Expand Down

0 comments on commit 5322bf7

Please sign in to comment.