|
| 1 | +# Frequently Asked Questions |
| 2 | + |
| 3 | +- [How do I manage the `aws-auth` configmap?](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/faq.md#how-do-i-manage-the-aws-auth-configmap) |
| 4 | +- [I received an error: `Error: Invalid for_each argument ...`](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/faq.md#i-received-an-error-error-invalid-for_each-argument-) |
| 5 | +- [Why are nodes not being registered?](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/faq.md#why-are-nodes-not-being-registered) |
| 6 | +- [Why are there no changes when a node group's `desired_size` is modified?](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/faq.md#why-are-there-no-changes-when-a-node-groups-desired_size-is-modified) |
| 7 | +- [How can I deploy Windows based nodes?](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/faq.md#how-can-i-deploy-windows-based-nodes) |
| 8 | + |
| 9 | +### How do I manage the `aws-auth` configmap? |
| 10 | + |
| 11 | +TL;DR - https://github.com/terraform-aws-modules/terraform-aws-eks/issues/1901 |
| 12 | + |
| 13 | +- Users can roll their own equivalent of `kubectl patch ...` using the [`null_resource`](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/9a99689cc13147f4afc426b34ba009875a28614e/examples/complete/main.tf#L301-L336) |
| 14 | +- There is a module that was created to fill this gap that provides a Kuberenetes based approach to provision: https://github.com/aidanmelen/terraform-aws-eks-auth |
| 15 | +- Ideally, one of the following issues are resolved upstream for a more native experience for users: |
| 16 | + - https://github.com/aws/containers-roadmap/issues/185 |
| 17 | + - https://github.com/hashicorp/terraform-provider-kubernetes/issues/723 |
| 18 | + |
| 19 | +### I received an error: `Error: Invalid for_each argument ...` |
| 20 | + |
| 21 | +Users may encounter an error such as `Error: Invalid for_each argument - The "for_each" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply ...` |
| 22 | + |
| 23 | +This error is due to an upstream issue with [Terraform core](https://github.com/hashicorp/terraform/issues/4149). There are two potential options you can take to help mitigate this issue: |
| 24 | + |
| 25 | +1. Create the dependent resources before the cluster => `terraform apply -target <your policy or your security group>` and then `terraform apply` for the cluster (or other similar means to just ensure the referenced resources exist before creating the cluster) |
| 26 | + - Note: this is the route users will have to take for adding additional security groups to nodes since there isn't a separate "security group attachment" resource |
| 27 | +2. For additional IAM policies, users can attach the policies outside of the cluster definition as demonstrated below |
| 28 | + |
| 29 | +```hcl |
| 30 | +resource "aws_iam_role_policy_attachment" "additional" { |
| 31 | + for_each = module.eks.eks_managed_node_groups |
| 32 | + # you could also do the following or any combination: |
| 33 | + # for_each = merge( |
| 34 | + # module.eks.eks_managed_node_groups, |
| 35 | + # module.eks.self_managed_node_group, |
| 36 | + # module.eks.fargate_profile, |
| 37 | + # ) |
| 38 | +
|
| 39 | + # This policy does not have to exist at the time of cluster creation. Terraform can |
| 40 | + # deduce the proper order of its creation to avoid errors during creation |
| 41 | + policy_arn = aws_iam_policy.node_additional.arn |
| 42 | + role = each.value.iam_role_name |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +TL;DR - Terraform resource passed into the modules map definition *must* be known before you can apply the EKS module. The variables this potentially affects are: |
| 47 | + |
| 48 | +- `cluster_security_group_additional_rules` (i.e. - referencing an external security group resource in a rule) |
| 49 | +- `node_security_group_additional_rules` (i.e. - referencing an external security group resource in a rule) |
| 50 | +- `iam_role_additional_policies` (i.e. - referencing an external policy resource) |
| 51 | + |
| 52 | +- Setting `instance_refresh_enabled = true` will recreate your worker nodes without draining them first. It is recommended to install [aws-node-termination-handler](https://github.com/aws/aws-node-termination-handler) for proper node draining. See the [instance_refresh](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/examples/irsa_autoscale_refresh) example provided. |
| 53 | + |
| 54 | +### Why are nodes not being registered? |
| 55 | + |
| 56 | +Nodes not being able to register with the EKS control plane is generally due to networking mis-configurations. |
| 57 | + |
| 58 | +1. At least one of the cluster endpoints (public or private) must be enabled. |
| 59 | + |
| 60 | +If you require a public endpoint, setting up both (public and private) and restricting the public endpoint via setting `cluster_endpoint_public_access_cidrs` is recommended. More info regarding communication with an endpoint is available [here](https://docs.aws.amazon.com/eks/latest/userguide/cluster-endpoint.html). |
| 61 | + |
| 62 | +2. Nodes need to be able to contact the EKS cluster endpoint. By default, the module only creates a public endpoint. To access the endpoint, the nodes need outgoing internet access: |
| 63 | + |
| 64 | +- Nodes in private subnets: via a NAT gateway or instance along with the appropriate routing rules |
| 65 | +- Nodes in public subnets: ensure that nodes are launched with public IPs (enable through either the module here or your subnet setting defaults) |
| 66 | + |
| 67 | +__Important: If you apply only the public endpoint and configure the `cluster_endpoint_public_access_cidrs` to restrict access, know that EKS nodes will also use the public endpoint and you must allow access to the endpoint. If not, then your nodes will fail to work correctly.__ |
| 68 | + |
| 69 | +3. The private endpoint can also be enabled by setting `cluster_endpoint_private_access = true`. Ensure that VPC DNS resolution and hostnames are also enabled for your VPC when the private endpoint is enabled. |
| 70 | + |
| 71 | +4. Nodes need to be able to connect to other AWS services to function (download container images, make API calls to assume roles, etc.). If for some reason you cannot enable public internet access for nodes you can add VPC endpoints to the relevant services: EC2 API, ECR API, ECR DKR and S3. |
| 72 | + |
| 73 | +### Why are there no changes when a node group's `desired_size` is modified? |
| 74 | + |
| 75 | +The module is configured to ignore this value. Unfortunately, Terraform does not support variables within the `lifecycle` block. The setting is ignored to allow autoscaling via controllers such as cluster autoscaler or Karpenter to work properly and without interference by Terraform. Changing the desired count must be handled outside of Terraform once the node group is created. |
| 76 | + |
| 77 | +### How can I deploy Windows based nodes? |
| 78 | + |
| 79 | +To enable Windows support for your EKS cluster, you will need to apply some configuration manually. See the [Enabling Windows Support (Windows/MacOS/Linux)](https://docs.aws.amazon.com/eks/latest/userguide/windows-support.html#enable-windows-support). |
| 80 | + |
| 81 | +In addition, Windows based nodes require an additional cluster RBAC role (`eks:kube-proxy-windows`). |
| 82 | + |
| 83 | +Note: Windows based node support is limited to a default user data template that is provided due to the lack of Windows support and manual steps required to provision Windows based EKS nodes. |
0 commit comments