* WIP Move node_groups to a submodule * Split the old node_groups file up * Start moving locals * Simplify IAM creation logic * depends_on from the TF docs * Wire in the variables * Call module from parent * Allow to customize the role name. As per workers * aws_auth ConfigMap for node_groups * Get the managed_node_groups example to plan * Get the basic example to plan too * create_eks = false works "The true and false result expressions must have consistent types. The given expressions are object and object, respectively." Well, that's useful. But apparently set(string) and set() are ok. So everything else is more complicated. Thanks. * Update Changelog * Update README * Wire in node_groups_defaults * Remove node_groups from workers_defaults_defaults * Synchronize random and node_group defaults * Error: "name_prefix" cannot be longer than 32 * Update READMEs again * Fix double destroy Was producing index errors when running destroy on an empty state. * Remove duplicate iam_role in node_group I think this logic works. Needs some testing with an externally created role. * Fix index fail if node group manually deleted * Keep aws_auth template in top module Downside: count causes issues as usual: can't use distinct() in the child module so there's a template render for every node_group even if only one role is really in use. Hopefully just output noise instead of technical issue * Hack to have node_groups depend on aws_auth etc The AWS Node Groups create or edit the aws-auth ConfigMap so that nodes can join the cluster. This breaks the kubernetes resource which cannot do a force create. Remove the race condition with explicit depend. Can't pull the IAM role out of the node_group any more. * Pull variables via the random_pet to cut logic No point having the same logic in two different places * Pass all ForceNew variables through the pet * Do a deep merge of NG labels and tags * Update README.. again * Additional managed node outputs #644 Add change from @TBeijin from PR #644 * Remove unused local * Use more for_each * Remove the change when create_eks = false * Make documentation less confusing * node_group version user configurable * Pass through raw output from aws_eks_node_groups * Merge workers defaults in the locals This simplifies the random_pet and aws_eks_node_group logic. Which was causing much consernation on the PR. * Fix typo Co-authored-by: Max Williams <max.williams@deliveryhero.com>
eks node_groups submodule
Helper submodule to create and manage resources related to eks_node_groups.
Assumptions
- Designed for use by the parent module and not directly by end users
Node Groups' IAM Role
The role ARN specified in var.default_iam_role_arn will be used by default. In a simple configuration this will be the worker role created by the parent module.
iam_role_arn must be specified in either var.node_groups_defaults or var.node_groups if the default parent IAM role is not being created for whatever reason, for example if manage_worker_iam_resources is set to false in the parent.
node_groups and node_groups_defaults keys
node_groups_defaults is a map that can take the below keys. Values will be used if not specified in individual node groups.
node_groups is a map of maps. Key of first level will be used as unique value for for_each resources and in the aws_eks_node_group name. Inner map can take the below values.
| Name | Description | Type | If unset |
|---|---|---|---|
| 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 |
| desired_capacity | Desired number of workers | number | var.workers_group_defaults[asg_desired_capacity] |
| disk_size | Workers' disk size | number | Provider default behavior |
| iam_role_arn | IAM role ARN for workers | string | var.default_iam_role_arn |
| instance_type | Workers' instance type | string | var.workers_group_defaults[instance_type] |
| k8s_labels | Kubernetes labels | map(string) | No labels applied |
| key_name | Key name for workers. Set to empty string to disable remote access | string | var.workers_group_defaults[key_name] |
| max_capacity | Max number of workers | number | var.workers_group_defaults[asg_max_size] |
| min_capacity | Min number of workers | number | var.workers_group_defaults[asg_min_size] |
| source_security_group_ids | Source security groups for remote access to workers | list(string) | If key_name is specified: THE REMOTE ACCESS WILL BE OPENED TO THE WORLD |
| subnets | Subnets to contain workers | list(string) | var.workers_group_defaults[subnets] |
| version | Kubernetes version | string | Provider default behavior |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name | Name of parent cluster | string | n/a | yes |
| create_eks | Controls if EKS resources should be created (it affects almost all resources) | bool | "true" |
no |
| default_iam_role_arn | ARN of the default IAM worker role to use if one is not specified in var.node_groups or var.node_groups_defaults |
string | n/a | yes |
| node_groups | Map of maps of eks_node_groups to create. See "node_groups and node_groups_defaults keys" section in README.md for more details |
any | {} |
no |
| node_groups_defaults | map of maps of node groups to create. See "node_groups and node_groups_defaults keys" section in README.md for more details |
any | n/a | yes |
| tags | A map of tags to add to all resources | map(string) | n/a | yes |
| workers_group_defaults | Workers group defaults from parent | any | n/a | yes |
Outputs
| Name | Description |
|---|---|
| aws_auth_roles | Roles for use in aws-auth ConfigMap |
| node_groups | Outputs from EKS node groups. Map of maps, keyed by var.node_groups keys. See aws_eks_node_group Terraform documentation for values |