Skip to content

Commit

Permalink
[eks/cluster] Add support for kubelet extra args, etc. (#1046)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored May 31, 2024
1 parent d556d73 commit cdb16cf
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 4 deletions.
12 changes: 12 additions & 0 deletions modules/eks/cluster/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## Release 1.452.0

Components PR [#1046](https://github.com/cloudposse/terraform-aws-components/pull/1046)

Added support for passing extra arguments to `kubelet` and other startup modifications supported by EKS on Amazon Linux
2 via the
[`bootsrap.sh`](https://github.com/awslabs/amazon-eks-ami/blob/d87c6c49638216907cbd6630b6cadfd4825aed20/templates/al2/runtime/bootstrap.sh)
script.

This support should be considered an `alpha` version, as it may change when support for Amazon Linux 2023 is added, and
does not work with Bottlerocket.

## Breaking Changes: Components PR [#1033](https://github.com/cloudposse/terraform-aws-components/pull/1033)

### Major Breaking Changes
Expand Down
13 changes: 10 additions & 3 deletions modules/eks/cluster/README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions modules/eks/cluster/eks-node-groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module "region_node_group" {
instance_types = each.value.instance_types == null ? var.node_group_defaults.instance_types : each.value.instance_types
kubernetes_labels = each.value.kubernetes_labels == null ? var.node_group_defaults.kubernetes_labels : each.value.kubernetes_labels
kubernetes_taints = each.value.kubernetes_taints == null ? var.node_group_defaults.kubernetes_taints : each.value.kubernetes_taints
node_userdata = each.value.node_userdata == null ? var.node_group_defaults.node_userdata : each.value.node_userdata
kubernetes_version = each.value.kubernetes_version == null ? local.node_group_default_kubernetes_version : each.value.kubernetes_version
resources_to_tag = each.value.resources_to_tag == null ? var.node_group_defaults.resources_to_tag : each.value.resources_to_tag
subnet_type_tag_key = local.subnet_type_tag_key
Expand Down
15 changes: 14 additions & 1 deletion modules/eks/cluster/modules/node_group_by_az/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ locals {
subnet_ids = local.subnet_ids_test[0] == local.sentinel ? null : local.subnet_ids_test
az_map = var.cluster_context.az_abbreviation_type == "short" ? module.az_abbreviation.region_az_alt_code_maps.to_short : module.az_abbreviation.region_az_alt_code_maps.to_fixed
az_attribute = local.az_map[var.availability_zone]

before_cluster_joining_userdata = var.cluster_context.node_userdata.before_cluster_joining_userdata != null ? [trimspace(var.cluster_context.node_userdata.before_cluster_joining_userdata)] : []
bootstrap_extra_args = var.cluster_context.node_userdata.bootstrap_extra_args != null ? [trimspace(var.cluster_context.node_userdata.bootstrap_extra_args)] : []
kubelet_extra_args = var.cluster_context.node_userdata.kubelet_extra_args != null ? [trimspace(var.cluster_context.node_userdata.kubelet_extra_args)] : []
after_cluster_joining_userdata = var.cluster_context.node_userdata.after_cluster_joining_userdata != null ? [trimspace(var.cluster_context.node_userdata.after_cluster_joining_userdata)] : []

}

module "eks_node_group" {
source = "cloudposse/eks-node-group/aws"
version = "2.11.0"
version = "2.12.0"

enabled = local.enabled

Expand All @@ -57,6 +63,13 @@ module "eks_node_group" {
resources_to_tag = local.enabled ? var.cluster_context.resources_to_tag : null
subnet_ids = local.enabled ? local.subnet_ids : null

# node_userdata
before_cluster_joining_userdata = local.enabled ? local.before_cluster_joining_userdata : []
bootstrap_additional_options = local.enabled ? local.bootstrap_extra_args : []
kubelet_additional_options = local.enabled ? local.kubelet_extra_args : []
after_cluster_joining_userdata = local.enabled ? local.after_cluster_joining_userdata : []


block_device_map = local.enabled ? var.cluster_context.block_device_map : null

# Prevent the node groups from being created before the Kubernetes aws-auth configMap
Expand Down
6 changes: 6 additions & 0 deletions modules/eks/cluster/modules/node_group_by_az/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ variable "cluster_context" {
value = string
effect = string
}))
node_userdata = object({
before_cluster_joining_userdata = optional(string)
bootstrap_extra_args = optional(string)
kubelet_extra_args = optional(string)
after_cluster_joining_userdata = optional(string)
})
kubernetes_version = string
module_depends_on = any
resources_to_tag = list(string)
Expand Down
6 changes: 6 additions & 0 deletions modules/eks/cluster/modules/node_group_by_region/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ variable "cluster_context" {
value = string
effect = string
}))
node_userdata = object({
before_cluster_joining_userdata = optional(string)
bootstrap_extra_args = optional(string)
kubelet_extra_args = optional(string)
after_cluster_joining_userdata = optional(string)
})
kubernetes_version = string
module_depends_on = optional(any)
resources_to_tag = list(string)
Expand Down
12 changes: 12 additions & 0 deletions modules/eks/cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ variable "node_groups" {
value = string
effect = string
})), null)
node_userdata = optional(object({
before_cluster_joining_userdata = optional(string)
bootstrap_extra_args = optional(string)
kubelet_extra_args = optional(string)
after_cluster_joining_userdata = optional(string)
}), {})
# Desired Kubernetes master version. If you do not specify a value, the latest available version is used
kubernetes_version = optional(string, null)
# The maximum size of the AutoScaling Group
Expand Down Expand Up @@ -295,6 +301,12 @@ variable "node_group_defaults" {
value = string
effect = string
})), [])
node_userdata = optional(object({
before_cluster_joining_userdata = optional(string)
bootstrap_extra_args = optional(string)
kubelet_extra_args = optional(string)
after_cluster_joining_userdata = optional(string)
}), {})
kubernetes_version = optional(string, null) # set to null to use cluster_kubernetes_version
max_group_size = optional(number, null)
min_group_size = optional(number, null)
Expand Down

0 comments on commit cdb16cf

Please sign in to comment.