Skip to content

Commit 5322bf7

Browse files
authored
fix: Allow instance_requirements to be set in self-managed node groups (#3455)
1 parent 1f2f95a commit 5322bf7

File tree

2 files changed

+74
-69
lines changed
  • modules/self-managed-node-group
  • tests/self-managed-node-group

2 files changed

+74
-69
lines changed

modules/self-managed-node-group/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ resource "aws_launch_template" "this" {
321321
}
322322
}
323323

324-
instance_type = var.instance_type
324+
instance_type = var.instance_requirements != null ? null : var.instance_type
325325
kernel_id = var.kernel_id
326326
key_name = var.key_name
327327

tests/self-managed-node-group/main.tf

Lines changed: 73 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,79 @@ module "eks" {
164164
}
165165
}
166166

167-
# Complete
167+
instance_attributes = {
168+
name = "instance-attributes"
169+
170+
min_size = 1
171+
max_size = 2
172+
desired_size = 1
173+
174+
cloudinit_pre_nodeadm = [{
175+
content = <<-EOT
176+
---
177+
apiVersion: node.eks.aws/v1alpha1
178+
kind: NodeConfig
179+
spec:
180+
kubelet:
181+
config:
182+
shutdownGracePeriod: 30s
183+
EOT
184+
content_type = "application/node.eks.aws"
185+
}]
186+
187+
instance_type = null
188+
189+
# launch template configuration
190+
instance_requirements = {
191+
cpu_manufacturers = ["intel"]
192+
instance_generations = ["current", "previous"]
193+
spot_max_price_percentage_over_lowest_price = 100
194+
195+
memory_mib = {
196+
min = 8192
197+
}
198+
199+
vcpu_count = {
200+
min = 1
201+
}
202+
203+
allowed_instance_types = ["t*", "m*"]
204+
}
205+
206+
use_mixed_instances_policy = true
207+
mixed_instances_policy = {
208+
instances_distribution = {
209+
on_demand_base_capacity = 0
210+
on_demand_percentage_above_base_capacity = 0
211+
on_demand_allocation_strategy = "lowest-price"
212+
spot_allocation_strategy = "price-capacity-optimized"
213+
}
214+
215+
# ASG configuration
216+
launch_template = {
217+
override = [
218+
{
219+
instance_requirements = {
220+
cpu_manufacturers = ["intel"]
221+
instance_generations = ["current", "previous"]
222+
spot_max_price_percentage_over_lowest_price = 100
223+
224+
memory_mib = {
225+
min = 8192
226+
}
227+
228+
vcpu_count = {
229+
min = 1
230+
}
231+
232+
allowed_instance_types = ["t*", "m*"]
233+
}
234+
}
235+
]
236+
}
237+
}
238+
}
239+
168240
complete = {
169241
name = "complete-self-mng"
170242
use_name_prefix = false
@@ -212,73 +284,6 @@ module "eks" {
212284
}
213285
}
214286

215-
instance_attributes = {
216-
name = "instance-attributes"
217-
218-
min_size = 1
219-
max_size = 2
220-
desired_size = 1
221-
222-
bootstrap_extra_args = "--kubelet-extra-args '--node-labels=node.kubernetes.io/lifecycle=spot'"
223-
224-
cloudinit_pre_nodeadm = [{
225-
content = <<-EOT
226-
---
227-
apiVersion: node.eks.aws/v1alpha1
228-
kind: NodeConfig
229-
spec:
230-
kubelet:
231-
config:
232-
shutdownGracePeriod: 30s
233-
EOT
234-
content_type = "application/node.eks.aws"
235-
}]
236-
237-
instance_type = null
238-
239-
# launch template configuration
240-
instance_requirements = {
241-
cpu_manufacturers = ["intel"]
242-
instance_generations = ["current", "previous"]
243-
spot_max_price_percentage_over_lowest_price = 100
244-
245-
vcpu_count = {
246-
min = 1
247-
}
248-
249-
allowed_instance_types = ["t*", "m*"]
250-
}
251-
252-
use_mixed_instances_policy = true
253-
mixed_instances_policy = {
254-
instances_distribution = {
255-
on_demand_base_capacity = 0
256-
on_demand_percentage_above_base_capacity = 0
257-
on_demand_allocation_strategy = "lowest-price"
258-
spot_allocation_strategy = "price-capacity-optimized"
259-
}
260-
261-
# ASG configuration
262-
launch_template = {
263-
override = [
264-
{
265-
instance_requirements = {
266-
cpu_manufacturers = ["intel"]
267-
instance_generations = ["current", "previous"]
268-
spot_max_price_percentage_over_lowest_price = 100
269-
270-
vcpu_count = {
271-
min = 1
272-
}
273-
274-
allowed_instance_types = ["t*", "m*"]
275-
}
276-
}
277-
]
278-
}
279-
}
280-
}
281-
282287
metadata_options = {
283288
http_endpoint = "enabled"
284289
http_tokens = "required"

0 commit comments

Comments
 (0)