Skip to content

Commit d48983c

Browse files
committed
feat: support user to specify AMI for node gorup
Signed-off-by: Sammy Huang <sammy.huang@zilliz.com>
1 parent ad2bec7 commit d48983c

File tree

5 files changed

+53
-10
lines changed

5 files changed

+53
-10
lines changed

examples/aws-project-byoc-I/data.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ locals {
6868
}
6969

7070
# Kubernetes node group specifications and resource quotas
71-
# Defines the compute capacity and node types for the EKS cluster
72-
k8s_node_groups = data.zillizcloud_byoc_i_project_settings.this.node_quotas
71+
# Merges node quotas from Zilliz cloud settings with optional ami_type overrides
72+
k8s_node_groups = {
73+
for name, ng in data.zillizcloud_byoc_i_project_settings.this.node_quotas : name => merge(ng, {
74+
ami_type = lookup(var.k8s_node_group_ami_type, name, "")
75+
})
76+
}
7377

7478
# Zilliz project identifier for resource tagging and organization
7579
# Links AWS resources back to the specific Zilliz cloud project

examples/aws-project-byoc-I/terraform.sample.tfvars

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ minimal_roles = {
107107
}
108108
}
109109

110+
# Optional AMI type override per node group (core, index, search, fundamental)
111+
# By default, AMI type is auto-detected from instance architecture:
112+
# - ARM instances (e.g., m6g, c7g, t4g) -> AL2023_ARM_64_STANDARD
113+
# - x86 instances (e.g., m6i, c5, r5) -> AL2023_x86_64_STANDARD
114+
# k8s_node_group_ami_type = {
115+
# fundamental = "BOTTLEROCKET_x86_64"
116+
# search = "BOTTLEROCKET_x86_64"
117+
# index = "BOTTLEROCKET_x86_64"
118+
# core = "BOTTLEROCKET_x86_64"
119+
# }
120+
110121
# Enable AWS Client-Side Encryption (CSE) for Milvus data
111122
# When enabled without aws_cse_exiting_key_arn, a new KMS key will be created automatically
112123
enable_aws_cse = false

examples/aws-project-byoc-I/variables.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,31 @@ variable "aws_cse_exiting_key_arn" {
221221
description = "The ARN of the existing KMS key to use for AWS CSE"
222222
type = string
223223
default = ""
224+
}
225+
226+
variable "k8s_node_group_ami_type" {
227+
description = <<-EOT
228+
Optional AMI type override per node group (core, index, search, fundamental).
229+
By default, the AMI type is auto-detected based on instance architecture:
230+
- ARM instances (e.g., m6g, c7g, t4g) -> AL2023_ARM_64_STANDARD
231+
- x86 instances (e.g., m6i, c5, r5) -> AL2023_x86_64_STANDARD
232+
233+
When specified, the provided value takes precedence over auto-detection.
234+
Only the node groups listed in the map are overridden; others keep auto-detection.
235+
236+
Example - override a single node group:
237+
k8s_node_group_ami_type = {
238+
core = "AL2_x86_64"
239+
}
240+
241+
Example - override multiple node groups:
242+
k8s_node_group_ami_type = {
243+
fundamental = "BOTTLEROCKET_x86_64"
244+
search = "BOTTLEROCKET_x86_64"
245+
index = "BOTTLEROCKET_x86_64"
246+
core = "BOTTLEROCKET_x86_64"
247+
}
248+
EOT
249+
type = map(string)
250+
default = {}
224251
}

modules/aws_byoc_i/eks/eks_nodegroup.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,16 @@ resource "aws_launch_template" "diskann" {
239239
}
240240

241241

242-
# Determine AMI type based on instance architecture
242+
# Determine AMI type for each node group:
243+
# - Use the explicitly provided ami_type if set
244+
# - Otherwise auto-detect from instance type (ARM 'g' suffix -> AL2023_ARM_64_STANDARD, else AL2023_x86_64_STANDARD)
243245
locals {
244-
# Map instance types to their appropriate AMI types
245-
# ARM instances typically have 'g' in their generation identifier (e.g., m6g, c7g, t4g)
246-
# This regex matches instance types with 'g' after the number, which indicates ARM architecture
247246
ami_types = {
248-
search = can(regex("^[a-z]+[0-9]+g[a-z]*\\.", var.k8s_node_groups.search.instance_types)) ? "AL2023_ARM_64_STANDARD" : "AL2023_x86_64_STANDARD"
249-
core = can(regex("^[a-z]+[0-9]+g[a-z]*\\.", var.k8s_node_groups.core.instance_types)) ? "AL2023_ARM_64_STANDARD" : "AL2023_x86_64_STANDARD"
250-
index = can(regex("^[a-z]+[0-9]+g[a-z]*\\.", var.k8s_node_groups.index.instance_types)) ? "AL2023_ARM_64_STANDARD" : "AL2023_x86_64_STANDARD"
251-
fundamental = can(regex("^[a-z]+[0-9]+g[a-z]*\\.", var.k8s_node_groups.fundamental.instance_types)) ? "AL2023_ARM_64_STANDARD" : "AL2023_x86_64_STANDARD"
247+
for name, ng in var.k8s_node_groups : name => (
248+
ng.ami_type != "" ? ng.ami_type : (
249+
can(regex("^[a-z]+[0-9]+g[a-z]*\\.", ng.instance_types)) ? "AL2023_ARM_64_STANDARD" : "AL2023_x86_64_STANDARD"
250+
)
251+
)
252252
}
253253
}
254254

modules/aws_byoc_i/eks/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ variable "k8s_node_groups" {
8585
desired_size = number
8686
instance_types = string
8787
capacity_type = string
88+
ami_type = optional(string, "")
8889
}))
8990

9091
default = {

0 commit comments

Comments
 (0)