mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-01-16 08:37:18 +01:00
feat: Added custom AMI support for managed node groups (#1473)
This commit is contained in:
@@ -20,6 +20,7 @@ The role ARN specified in `var.default_iam_role_arn` will be used by default. In
|
||||
| additional\_tags | Additional tags to apply to node group | map(string) | Only `var.tags` applied |
|
||||
| ami\_release\_version | AMI version of workers | string | Provider default behavior |
|
||||
| ami\_type | AMI Type. See Terraform or AWS docs | string | Provider default behavior |
|
||||
| ami\_id | ID of custom AMI. If you use a custom AMI, you need to supply bootstrap script via user-data or as AMI built-in. | string | Provider default behavior |
|
||||
| capacity\_type | Type of instance capacity to provision. Options are `ON_DEMAND` and `SPOT` | string | Provider default behavior |
|
||||
| create_launch_template | Create and use a default launch template | bool | `false` |
|
||||
| desired\_capacity | Desired number of workers | number | `var.workers_group_defaults[asg_desired_capacity]` |
|
||||
|
||||
@@ -9,8 +9,10 @@ data "cloudinit_config" "workers_userdata" {
|
||||
content_type = "text/x-shellscript"
|
||||
content = templatefile("${path.module}/templates/userdata.sh.tpl",
|
||||
{
|
||||
pre_userdata = each.value["pre_userdata"]
|
||||
kubelet_extra_args = each.value["kubelet_extra_args"]
|
||||
pre_userdata = each.value["pre_userdata"]
|
||||
kubelet_extra_args = each.value["kubelet_extra_args"]
|
||||
cluster_name = var.cluster_name
|
||||
run_bootstrap_script = lookup(each.value, "ami_id", null) != null
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -64,7 +66,7 @@ resource "aws_launch_template" "workers" {
|
||||
}
|
||||
|
||||
# if you want to use a custom AMI
|
||||
# image_id = var.ami_id
|
||||
image_id = lookup(each.value, "ami_id", null)
|
||||
|
||||
# If you use a custom AMI, you need to supply via user-data, the bootstrap script as EKS DOESNT merge its managed user-data then
|
||||
# you can add more than the minimum code you see in the template, e.g. install SSM agent, see https://github.com/aws/containers-roadmap/issues/593#issuecomment-577181345
|
||||
|
||||
@@ -4,3 +4,6 @@
|
||||
${pre_userdata}
|
||||
|
||||
sed -i '/^KUBELET_EXTRA_ARGS=/a KUBELET_EXTRA_ARGS+=" ${kubelet_extra_args}"' /etc/eks/bootstrap.sh
|
||||
%{ if run_bootstrap_script }
|
||||
/etc/eks/bootstrap.sh ${cluster_name}
|
||||
%{ endif }
|
||||
|
||||
Reference in New Issue
Block a user