Skip to content

Commit e4d97ca

Browse files
committed
docs: Re-organize documentation for easier navigation and improved support for referencing sections in issues/PRs
1 parent 6d72456 commit e4d97ca

File tree

9 files changed

+1296
-671
lines changed

9 files changed

+1296
-671
lines changed

README.md

Lines changed: 42 additions & 671 deletions
Large diffs are not rendered by default.

docs/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Documentation
2+
3+
## Table of Contents
4+
5+
- [Frequently Asked Questions](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/faq.md)
6+
- [Module Design](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/module_design.md)
7+
- [Node Groups](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/node_groups.md)
8+
- [User Data](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/user_data.md)
9+
- [Network Connectivity](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/network_connectivity.md)
10+
- Upgrade Guides
11+
- [Upgrade to v17.x](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/UPGRADE-17.0.md)
12+
- [Upgrade to v18.x](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/UPGRADE-18.0.md)

docs/UPGRADE-17.0.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# How to handle the terraform-aws-eks module upgrade
2+
3+
## Upgrade module to v17.0.0 for Managed Node Groups
4+
5+
In this release, we now decided to remove random_pet resources in Managed Node Groups (MNG). Those were used to recreate MNG if something changed. But they were causing a lot of issues. To upgrade the module without recreating your MNG, you will need to explicitly reuse their previous name and set them in your MNG `name` argument.
6+
7+
1. Run `terraform apply` with the module version v16.2.0
8+
2. Get your worker group names
9+
10+
```shell
11+
~ terraform state show 'module.eks.module.node_groups.aws_eks_node_group.workers["example"]' | grep node_group_name
12+
node_group_name = "test-eks-mwIwsvui-example-sincere-squid"
13+
```
14+
15+
3. Upgrade your module and configure your node groups to use existing names
16+
17+
```hcl
18+
module "eks" {
19+
source = "terraform-aws-modules/eks/aws"
20+
version = "17.0.0"
21+
22+
cluster_name = "test-eks-mwIwsvui"
23+
cluster_version = "1.20"
24+
# ...
25+
26+
node_groups = {
27+
example = {
28+
name = "test-eks-mwIwsvui-example-sincere-squid"
29+
30+
# ...
31+
}
32+
}
33+
# ...
34+
}
35+
```
36+
37+
4. Run `terraform plan`, you shoud see that only `random_pets` will be destroyed
38+
39+
```shell
40+
Terraform will perform the following actions:
41+
42+
# module.eks.module.node_groups.random_pet.node_groups["example"] will be destroyed
43+
- resource "random_pet" "node_groups" {
44+
- id = "sincere-squid" -> null
45+
- keepers = {
46+
- "ami_type" = "AL2_x86_64"
47+
- "capacity_type" = "SPOT"
48+
- "disk_size" = "50"
49+
- "iam_role_arn" = "arn:aws:iam::123456789123:role/test-eks-mwIwsvui20210527220853611600000009"
50+
- "instance_types" = "t3.large"
51+
- "key_name" = ""
52+
- "node_group_name" = "test-eks-mwIwsvui-example"
53+
- "source_security_group_ids" = ""
54+
- "subnet_ids" = "subnet-xxxxxxxxxxxx|subnet-xxxxxxxxxxxx|subnet-xxxxxxxxxxxx"
55+
} -> null
56+
- length = 2 -> null
57+
- separator = "-" -> null
58+
}
59+
60+
Plan: 0 to add, 0 to change, 1 to destroy.
61+
```
62+
63+
5. If everything sounds good to you, run `terraform apply`
64+
65+
After the first apply, we recommand you to create a new node group and let the module use the `node_group_name_prefix` (by removing the `name` argument) to generate names and avoid collision during node groups re-creation if needed, because the lifce cycle is `create_before_destroy = true`.

docs/UPGRADE-18.0.md

Lines changed: 586 additions & 0 deletions
Large diffs are not rendered by default.

docs/faq.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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.

docs/module_design.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
## Module Design Considerations
3+
4+
### General Notes
5+
6+
While the module is designed to be flexible and support as many use cases and configurations as possible, there is a limit to what first class support can be provided without over-burdening the complexity of the module. Below are a list of general notes on the design intent captured by this module which hopefully explains some of the decisions that are, or will be made, in terms of what is added/supported natively by the module:
7+
8+
- Despite the addition of Windows Subsystem for Linux (WSL for short), containerization technology is very much a suite of Linux constructs and therefore Linux is the primary OS supported by this module. In addition, due to the first class support provided by AWS, Bottlerocket OS and Fargate Profiles are also very much fully supported by this module. This module does not make any attempt to NOT support Windows, as in preventing the usage of Windows based nodes, however it is up to users to put in additional effort in order to operate Windows based nodes when using the module. User can refer to the [AWS documentation](https://docs.aws.amazon.com/eks/latest/userguide/windows-support.html) for further details. What this means is:
9+
- AWS EKS Managed Node Groups default to `linux` as the `platform`, but `bottlerocket` is also supported by AWS (`windows` is not supported by AWS EKS Managed Node groups)
10+
- AWS Self Managed Node Groups also default to `linux` and the default AMI used is the latest AMI for the selected Kubernetes version. If you wish to use a different OS or AMI then you will need to opt in to the necessary configurations to ensure the correct AMI is used in conjunction with the necessary user data to ensure the nodes are launched and joined to your cluster successfully.
11+
- AWS EKS Managed Node groups are currently the preferred route over Self Managed Node Groups for compute nodes. Both operate very similarly - both are backed by autoscaling groups and launch templates deployed and visible within your account. However, AWS EKS Managed Node groups provide a better user experience and offer a more "managed service" experience and therefore has precedence over Self Managed Node Groups. That said, there are currently inherent limitations as AWS continues to rollout additional feature support similar to the level of customization you can achieve with Self Managed Node Groups. When requesting added feature support for AWS EKS Managed Node groups, please ensure you have verified that the feature(s) are 1) supported by AWS and 2) supported by the Terraform AWS provider before submitting a feature request.
12+
- Due to the plethora of tooling and different manners of configuring your cluster, cluster configuration is intentionally left out of the module in order to simplify the module for a broader user base. Previous module versions provided support for managing the aws-auth configmap via the Kubernetes Terraform provider using the now deprecated aws-iam-authenticator; these are no longer included in the module. This module strictly focuses on the infrastructure resources to provision an EKS cluster as well as any supporting AWS resources. How the internals of the cluster are configured and managed is up to users and is outside the scope of this module. There is an output attribute, `aws_auth_configmap_yaml`, that has been provided that can be useful to help bridge this transition. Please see the various examples provided where this attribute is used to ensure that self managed node groups or external node groups have their IAM roles appropriately mapped to the aws-auth configmap. How users elect to manage the aws-auth configmap is left up to their choosing.

docs/network_connectivity.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Network Connectivity
2+
3+
### Security Groups
4+
5+
- Cluster Security Group
6+
- This module by default creates a cluster security group ("additional" security group when viewed from the console) in addition to the default security group created by the AWS EKS service. This "additional" security group allows users to customize inbound and outbound rules via the module as they see fit
7+
- The default inbound/outbound rules provided by the module are derived from the [AWS minimum recommendations](https://docs.aws.amazon.com/eks/latest/userguide/sec-group-reqs.html) in addition to NTP and HTTPS public internet egress rules (without, these show up in VPC flow logs as rejects - they are used for clock sync and downloading necessary packages/updates)
8+
- The minimum inbound/outbound rules are provided for cluster and node creation to succeed without errors, but users will most likely need to add the necessary port and protocol for node-to-node communication (this is user specific based on how nodes are configured to communicate across the cluster)
9+
- Users have the ability to opt out of the security group creation and instead provide their own externally created security group if so desired
10+
- The security group that is created is designed to handle the bare minimum communication necessary between the control plane and the nodes, as well as any external egress to allow the cluster to successfully launch without error
11+
- Users also have the option to supply additional, externally created security groups to the cluster as well via the `cluster_additional_security_group_ids` variable
12+
- Lastly, users are able to opt in to attaching the primary security group automatically created by the EKS service by setting `attach_cluster_primary_security_group` = `true` from the root module for the respective node group (or set it within the node group defaults). This security group is not managed by the module; it is created by the EKS service. It permits all traffic within the domain of the security group as well as all egress traffic to the internet.
13+
14+
- Node Group Security Group(s)
15+
- Each node group (EKS Managed Node Group and Self Managed Node Group) by default creates its own security group. By default, this security group does not contain any additional security group rules. It is merely an "empty container" that offers users the ability to opt into any addition inbound our outbound rules as necessary
16+
- Users also have the option to supply their own, and/or additional, externally created security group(s) to the node group as well via the `vpc_security_group_ids` variable
17+
18+
See the example snippet below which adds additional security group rules to the cluster security group as well as the shared node security group (for node-to-node access). Users can use this extensibility to open up network access as they see fit using the security groups provided by the module:
19+
20+
```hcl
21+
...
22+
# Extend cluster security group rules
23+
cluster_security_group_additional_rules = {
24+
egress_nodes_ephemeral_ports_tcp = {
25+
description = "To node 1025-65535"
26+
protocol = "tcp"
27+
from_port = 1025
28+
to_port = 65535
29+
type = "egress"
30+
source_node_security_group = true
31+
}
32+
}
33+
34+
# Extend node-to-node security group rules
35+
node_security_group_additional_rules = {
36+
ingress_self_all = {
37+
description = "Node to node all ports/protocols"
38+
protocol = "-1"
39+
from_port = 0
40+
to_port = 0
41+
type = "ingress"
42+
self = true
43+
}
44+
egress_all = {
45+
description = "Node all egress"
46+
protocol = "-1"
47+
from_port = 0
48+
to_port = 0
49+
type = "egress"
50+
cidr_blocks = ["0.0.0.0/0"]
51+
ipv6_cidr_blocks = ["::/0"]
52+
}
53+
}
54+
...
55+
```
56+
The security groups created by this module are depicted in the image shown below along with their default inbound/outbound rules:
57+
58+
<p align="center">
59+
<img src="https://raw.githubusercontent.com/terraform-aws-modules/terraform-aws-eks/master/.github/images/security_groups.svg" alt="Security Groups" width="100%">
60+
</p>

0 commit comments

Comments
 (0)