What does configuring EKS node groups look like with Gruntwork?
A customer asked: > Can you modify the EKS node groups following a Reference Architecture deployment? Can you provide me some examples of what it looks like to configure node groups using Gruntwork's modules?
Firstly, you can definitely modify the EKS cluster node groups following a Reference Architecture deployment. One of the benefits of having a Reference Architecture deployed is that you receive 100% of the code, so you can modify it however you wish. Secondly, here's some examples of what it looks like to configure Node groups in terragrunt: ``` managed_node_group_configurations = { group = { min_size = 2 max_size = 4 desired_size = 2 instance_types = ["t3.micro"] subnet_ids = dependency.vpc.outputs.private_app_subnet_ids } } cluster_instance_ami_filters = { owners = [local.common_vars.locals.account_ids.shared] filters = [ { name = "name" values = ["eks-workers-v0.70.0-*"] }, ] } ``` Here's the configuration format for Node groups in our eks-cluster module: ``` variable "managed_node_group_configurations" { description = "Configure one or more Node Groups to manage the EC2 instances in this cluster. Set to empty object ({}) if you do not wish to configure managed node groups." # Ideally, this would be a map of (string, object), with all the supported properties, but object does not support # optional properties. We can't use a map(any) either as that would require the values to all have the same type. type = any # Each configuration must be keyed by a unique string that will be used as a suffix for the node group name. The # values support the following attributes: # # # OPTIONAL (defaults to value of corresponding module input): # - subnet_ids list(string) : (Defaults to value from var.node_group_default_subnet_ids) A list of the # subnets into which the EKS Cluster's managed nodes will be launched. # These should usually be all private subnets and include one in each AWS # Availability Zone. NOTE: If using a cluster autoscaler with EBS volumes, # each ASG may only belong to a single availability zone. # - min_size number : (Defaults to value from var.node_group_default_min_size) The minimum # number of EC2 Instances representing workers launchable for this EKS # Cluster. Useful for auto-scaling limits. # - max_size number : (Defaults to value from var.node_group_default_max_size) The maximum # number of EC2 Instances representing workers that must be running for # this EKS Cluster. We recommend making this at least twice the min_size, # even if you don't plan on scaling the cluster up and down, as the extra # capacity will be used to deploy updates to the cluster. # - desired_size number : (Defaults to value from var.node_group_default_desired_size) The current # desired number of EC2 Instances representing workers that must be running # for this EKS Cluster. # - instance_types list(string) : (Defaults to value from var.node_group_default_instance_types) A list of # instance types (e.g., t2.medium) to use for the EKS Cluster's worker # nodes. EKS will choose from this list of instance types when launching # new instances. When using launch templates, this setting will override # the configured instance type of the launch template. # - capacity_type string : (Defaults to value from var.node_group_default_capacity_type) Type of capacity # associated with the EKS Node Group. Valid values: ON_DEMAND, SPOT. # - launch_template LaunchTemplate : (Defaults to value from var.node_group_default_launch_template) # Launch template to use for the node. Specify either Name or ID of launch # template. Must include version. Although the API supports using the # values "$Latest" and "$Default" to configure the version, this can lead # to a perpetual diff. Use the `latest_version` or `default_version` output # of the aws_launch_template data source or resource instead. See # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group#launch_template-configuration-block # for more information. # - instance_root_volume_size number : (Defaults to value from var.node_group_default_instance_root_volume_size) # The root volume size of instances to use for the ASG in GB (e.g., 40). # - instance_root_volume_type string : (Defaults to value from var.node_group_default_instance_root_volume_type) # The root volume type of instances to use for the ASG (e.g., "standard"). # - instance_root_volume_encryption bool : (Defaults to value from var.node_group_default_instance_root_volume_encryption) # Whether or not to enable root volume encryption for instances of the ASG. # - tags map(string) : (Defaults to value from var.node_group_default_tags) Custom tags to apply # to the EC2 Instances in this node group. This should be a key value pair, # where the keys are tag keys and values are the tag values. Merged with # var.common_tags. # - labels map(string) : (Defaults to value from var.node_group_default_labels) Custom Kubernetes # Labels to apply to the EC2 Instances in this node group. This should be a # key value pair, where the keys are label keys and values are the label # values. Merged with var.common_labels. # - eks_kubelet_extra_args string : Extra args to pass to the kubelet process on node boot. # - eks_bootstrap_script_options string : Extra option args to pass to the bootstrap.sh script. This will be # passed through directly to the bootstrap script. # - cloud_init_parts map(string) : (Defaults to value from var.cloud_init_parts) # Per-ASG cloud init scripts to run at boot time on the node. See var.cloud_init_parts for accepted keys. # # Structure of LaunchTemplate object: # - name string : The Name of the Launch Template to use. One of ID or Name should be provided. # - id string : The ID of the Launch Template to use. One of ID or Name should be provided. # - version string : The version of the Launch Template to use. # # Example: # managed_node_group_configurations = { # ngroup1 = { # desired_size = 1 # min_size = 1 # max_size = 3 # subnet_ids = [data.terraform_remote_state.vpc.outputs.private_app_subnet_ids[0]] # } # asg2 = { # desired_size = 1 # min_size = 1 # max_size = 3 # subnet_ids = [data.terraform_remote_state.vpc.outputs.private_app_subnet_ids[0]] # disk_size = 50 # } # ngroup2 = {} # Only defaults # } default = {} } ```