You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Replace the local-exec script with a http datasource for waiting cluster (#1339)
NOTES: Using the [terraform-aws-modules/http](https://registry.terraform.io/providers/terraform-aws-modules/http/latest) provider is a more platform agnostic way to wait for the cluster availability than using a local-exec. With this change we're able to provision EKS clusters and manage the `aws_auth` configmap while still using the `hashicorp/tfc-agent` docker image.
Copy file name to clipboardexpand all lines: README.md
+9-15
Original file line number
Diff line number
Diff line change
@@ -25,11 +25,7 @@ You also need to ensure your applications and add ons are updated, or workloads
25
25
26
26
An example of harming update was the removal of several commonly used, but deprecated APIs, in Kubernetes 1.16. More information on the API removals, see the [Kubernetes blog post](https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/).
27
27
28
-
By default, this module manages the `aws-auth` configmap for you (`manage_aws_auth=true`). To avoid the following [issue](https://github.com/aws/containers-roadmap/issues/654) where the EKS creation is `ACTIVE` but not ready, we implemented a retry logic with an `local-exec` provisioner and `wget` (by default) with failover to `curl`.
29
-
30
-
**If you want to manage your `aws-auth` configmap, ensure you have `wget` (or `curl`) and `/bin/sh` installed where you're running Terraform or set `wait_for_cluster_cmd` and `wait_for_cluster_interpreter` to match your needs.**
31
-
32
-
For windows users, please read the following [doc](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/faq.md#deploying-from-windows-binsh-file-does-not-exist).
28
+
By default, this module manages the `aws-auth` configmap for you (`manage_aws_auth=true`). To avoid the following [issue](https://github.com/aws/containers-roadmap/issues/654) where the EKS creation is `ACTIVE` but not ready. We implemented a "retry" logic with a fork of the http provider https://github.com/terraform-aws-modules/terraform-provider-http. This fork adds the support of a self-signed CA certificate. The original PR can be found at https://github.com/hashicorp/terraform-provider-http/pull/29.
33
29
34
30
## Usage example
35
31
@@ -145,21 +141,21 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
|[aws_ami.eks_worker](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami)| data source |
@@ -221,6 +216,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
221
216
|[aws_iam_policy_document.workers_assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
222
217
|[aws_iam_role.custom_cluster_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_role)| data source |
223
218
|[aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition)| data source |
219
+
|[http_http.wait_for_cluster](https://registry.terraform.io/providers/terraform-aws-modules/http/latest/docs/data-sources/http)| data source |
224
220
|[template_file.launch_template_userdata](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file)| data source |
225
221
|[template_file.userdata](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file)| data source |
226
222
@@ -273,8 +269,6 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
273
269
| <aname="input_subnets"></a> [subnets](#input\_subnets)| A list of subnets to place the EKS cluster and workers within. |`list(string)`| n/a | yes |
274
270
| <aname="input_tags"></a> [tags](#input\_tags)| A map of tags to add to all resources. Tags added to launch configuration or templates override these values for ASG Tags only. |`map(string)`|`{}`| no |
275
271
| <aname="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id)| VPC where the cluster and workers will be deployed. |`string`| n/a | yes |
276
-
| <aname="input_wait_for_cluster_cmd"></a> [wait\_for\_cluster\_cmd](#input\_wait\_for\_cluster\_cmd)| Custom local-exec command to execute for determining if the eks cluster is healthy. Cluster endpoint will be available as an environment variable called ENDPOINT |`string`|`"for i in `seq 1 60`; do if `command -v wget > /dev/null`; then wget --no-check-certificate -O - -q $ENDPOINT/healthz >/dev/null && exit 0 || true; else curl -k -s $ENDPOINT/healthz >/dev/null && exit 0 || true;fi; sleep 5; done; echo TIMEOUT && exit 1"` | no |
277
-
| <aname="input_wait_for_cluster_interpreter"></a> [wait\_for\_cluster\_interpreter](#input\_wait\_for\_cluster\_interpreter)| Custom local-exec command line interpreter for the command to determining if the eks cluster is healthy. |`list(string)`| <pre>[<br> "/bin/sh",<br> "-c"<br>]</pre> | no |
278
272
| <aname="input_worker_additional_security_group_ids"></a> [worker\_additional\_security\_group\_ids](#input\_worker\_additional\_security\_group\_ids)| A list of additional security group ids to attach to worker instances |`list(string)`|`[]`| no |
279
273
| <aname="input_worker_ami_name_filter"></a> [worker\_ami\_name\_filter](#input\_worker\_ami\_name\_filter)| Name filter for AWS EKS worker AMI. If not provided, the latest official AMI for the specified 'cluster\_version' is used. |`string`|`""`| no |
280
274
| <aname="input_worker_ami_name_filter_windows"></a> [worker\_ami\_name\_filter\_windows](#input\_worker\_ami\_name\_filter\_windows)| Name filter for AWS EKS Windows worker AMI. If not provided, the latest official AMI for the specified 'cluster\_version' is used. |`string`|`""`| no |
@@ -304,7 +298,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
304
298
| <aname="output_cluster_endpoint"></a> [cluster\_endpoint](#output\_cluster\_endpoint)| The endpoint for your EKS Kubernetes API. |
305
299
| <aname="output_cluster_iam_role_arn"></a> [cluster\_iam\_role\_arn](#output\_cluster\_iam\_role\_arn)| IAM role ARN of the EKS cluster. |
306
300
| <aname="output_cluster_iam_role_name"></a> [cluster\_iam\_role\_name](#output\_cluster\_iam\_role\_name)| IAM role name of the EKS cluster. |
307
-
| <aname="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id)| The name/id of the EKS cluster. Will block on cluster creation until the cluster is really ready |
301
+
| <aname="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id)| The name/id of the EKS cluster. Will block on cluster creation until the cluster is really ready.|
308
302
| <aname="output_cluster_oidc_issuer_url"></a> [cluster\_oidc\_issuer\_url](#output\_cluster\_oidc\_issuer\_url)| The URL on the EKS cluster OIDC Issuer |
309
303
| <aname="output_cluster_primary_security_group_id"></a> [cluster\_primary\_security\_group\_id](#output\_cluster\_primary\_security\_group\_id)| The cluster primary security group ID created by the EKS cluster on 1.14 or later. Referred to as 'Cluster security group' in the EKS console. |
310
304
| <aname="output_cluster_security_group_id"></a> [cluster\_security\_group\_id](#output\_cluster\_security\_group\_id)| Security group ID attached to the EKS cluster. On 1.14 or later, this is the 'Additional security groups' in the EKS console. |
@@ -314,8 +308,8 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
314
308
| <aname="output_fargate_iam_role_name"></a> [fargate\_iam\_role\_name](#output\_fargate\_iam\_role\_name)| IAM role name for EKS Fargate pods |
315
309
| <aname="output_fargate_profile_arns"></a> [fargate\_profile\_arns](#output\_fargate\_profile\_arns)| Amazon Resource Name (ARN) of the EKS Fargate Profiles. |
316
310
| <aname="output_fargate_profile_ids"></a> [fargate\_profile\_ids](#output\_fargate\_profile\_ids)| EKS Cluster name and EKS Fargate Profile names separated by a colon (:). |
317
-
| <aname="output_kubeconfig"></a> [kubeconfig](#output\_kubeconfig)| kubectl config file contents for this EKS cluster. |
318
-
| <aname="output_kubeconfig_filename"></a> [kubeconfig\_filename](#output\_kubeconfig\_filename)| The filename of the generated kubectl config. |
311
+
| <aname="output_kubeconfig"></a> [kubeconfig](#output\_kubeconfig)| kubectl config file contents for this EKS cluster. Will block on cluster creation until the cluster is really ready. |
312
+
| <aname="output_kubeconfig_filename"></a> [kubeconfig\_filename](#output\_kubeconfig\_filename)| The filename of the generated kubectl config. Will block on cluster creation until the cluster is really ready. |
319
313
| <aname="output_node_groups"></a> [node\_groups](#output\_node\_groups)| Outputs from EKS node groups. Map of maps, keyed by var.node\_groups keys |
320
314
| <aname="output_oidc_provider_arn"></a> [oidc\_provider\_arn](#output\_oidc\_provider\_arn)| The ARN of the OIDC Provider if `enable_irsa = true`. |
321
315
| <aname="output_security_group_rule_cluster_https_worker_ingress"></a> [security\_group\_rule\_cluster\_https\_worker\_ingress](#output\_security\_group\_rule\_cluster\_https\_worker\_ingress)| Security group rule responsible for allowing pods to communicate with the EKS cluster API. |
Copy file name to clipboardexpand all lines: docs/faq.md
+1-13
Original file line number
Diff line number
Diff line change
@@ -107,7 +107,7 @@ You do not need to do anything extra since v12.1.0 of the module as long as the
107
107
-`manage_aws_auth = true` on the module (default)
108
108
- the kubernetes provider is correctly configured like in the [Usage Example](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/README.md#usage-example). Primarily the module's `cluster_id` output is used as input to the `aws_eks_cluster*` data sources.
109
109
110
-
The `cluster_id` depends on a `null_resource` that polls the EKS cluster's endpoint until it is alive. This blocks initialisation of the kubernetes provider.
110
+
The `cluster_id` depends on a `data.http.wait_for_cluster` that polls the EKS cluster's endpoint until it is alive. This blocks initialisation of the kubernetes provider.
111
111
112
112
## `aws_auth.tf: At 2:14: Unknown token: 2:14 IDENT`
113
113
@@ -170,18 +170,6 @@ worker_groups = [
170
170
171
171
4. With `kubectl get nodes` you can see cluster with mixed (Linux/Windows) nodes support.
172
172
173
-
## Deploying from Windows: `/bin/sh` file does not exist
174
-
175
-
The module is almost pure Terraform apart from the `wait_for_cluster``null_resource` that runs a local provisioner. The module has a default configuration for Unix-like systems. In order to run the provisioner on Windows systems you must set the interpreter to a valid value. [PR #795 (comment)](https://github.com/terraform-aws-modules/terraform-aws-eks/pull/795#issuecomment-599191029) suggests the following value:
Alternatively, you can disable the `null_resource` by disabling creation of the `aws-auth` ConfigMap via setting `manage_aws_auth = false` on the module. The ConfigMap will then need creating via a different method.
184
-
185
173
## Worker nodes with labels do not join a 1.16+ cluster
186
174
187
175
Kubelet restricts the allowed list of labels in the `kubernetes.io` namespace that can be applied to nodes starting in 1.16.
description="Custom local-exec command to execute for determining if the eks cluster is healthy. Cluster endpoint will be available as an environment variable called ENDPOINT"
210
-
type=string
211
-
default="for i in `seq 1 60`; do if `command -v wget > /dev/null`; then wget --no-check-certificate -O - -q $ENDPOINT/healthz >/dev/null && exit 0 || true; else curl -k -s $ENDPOINT/healthz >/dev/null && exit 0 || true;fi; sleep 5; done; echo TIMEOUT && exit 1"
212
-
}
213
-
214
-
variable"wait_for_cluster_interpreter" {
215
-
description="Custom local-exec command line interpreter for the command to determining if the eks cluster is healthy."
216
-
type=list(string)
217
-
default=["/bin/sh", "-c"]
218
-
}
219
-
220
208
variable"cluster_create_security_group" {
221
209
description="Whether to create a security group for the cluster or attach the cluster to `cluster_security_group_id`."
0 commit comments