Skip to content

Commit b643172

Browse files
authored
Update EKS basic components (cloudposse/terraform-aws-components#509)
1 parent 64d405b commit b643172

File tree

8 files changed

+40
-117
lines changed

8 files changed

+40
-117
lines changed

src/README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# Component: `echo-server`
1+
# Component: `eks/echo-server`
22

33
This is copied from [cloudposse/terraform-aws-components](https://github.com/cloudposse/terraform-aws-components/tree/master/modules/echo-server).
44

5-
This component installs the [Ealenn/Echo-Server](https://github.com/Ealenn/Echo-Server) to EKS clusters.
5+
This component installs the [Ealenn/Echo-Server](https://github.com/Ealenn/Echo-Server) to EKS clusters.
66
The echo server is a server that sends it back to the client a JSON representation of all the data
77
the server received, which is a combination of information sent by the client and information sent
88
by the web server infrastructure. For further details, please consult the [Echo-Server documentation](https://ealenn.github.io/Echo-Server/).
99

1010
## Prerequisites
1111

12-
Echo server is intended to provide end-to-end testing of everything needed to deploy an application or service with a public HTTPS endpoint.
13-
Therefore it requires several other components.
12+
Echo server is intended to provide end-to-end testing of everything needed to deploy an application or service with a public HTTPS endpoint.
13+
Therefore, it requires several other components.
1414
At the moment, it supports 2 configurations:
1515

1616
1. ALB with ACM Certificate
1717
- AWS Load Balancer Controller (ALB) version 2.2.0 or later, with ACM certificate auto-discovery enabled
1818
- Pre-provisioned ACM TLS certificate covering the provisioned host name (typically a wildcard certificate covering all hosts in the domain)
1919
2. Nginx with Cert Manager Certificate
20-
- Nginx (via `kubernetes/ingress-nginx` controller). We recommend `ingress-nginx` v1.1.0 or later, but `echo-server`
20+
- Nginx (via `kubernetes/ingress-nginx` controller). We recommend `ingress-nginx` v1.1.0 or later, but `echo-server`
2121
should work with any version that supports Ingress API version `networking.k8s.io/v1`.
2222
- `jetstack/cert-manager` configured to automatically (via Ingress Shim, installed by default) generate TLS certificates via a Cluster Issuer
2323
(by default, named `letsEncrypt-prod`).
@@ -26,10 +26,11 @@ In both configurations, it has these common requirements:
2626
- Kubernetes version 1.19 or later
2727
- Ingress API version `networking.k8s.io/v1`
2828
- [kubernetes-sigs/external-dns](https://github.com/kubernetes-sigs/external-dns)
29+
- A default IngressClass, either explicitly provisioned or supported without provisioning by the Ingress controller.
2930

3031
## Warnings
3132

32-
A Terraform plan may fail to apply, giving a Kubernetes authentication failure. This is due to a known issue with
33+
A Terraform plan may fail to apply, giving a Kubernetes authentication failure. This is due to a known issue with
3334
Terraform and the Kubernetes provider. During the "plan" phase Terraform gets a short-lived Kubernetes
3435
authentication token and caches it, and then tries to use it during "apply". If the token has expired by
3536
the time you try to run "apply", the "apply" will fail. The workaround is to run `terraform apply -auto-approve` without
@@ -72,29 +73,27 @@ components:
7273
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
7374
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
7475
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.0 |
76+
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.7.1 |
7577
7678
## Providers
7779
7880
| Name | Version |
7981
|------|---------|
8082
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0 |
81-
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | n/a |
8283
8384
## Modules
8485
8586
| Name | Source | Version |
8687
|------|--------|---------|
87-
| <a name="module_alb-controller-ingress-group"></a> [alb-controller-ingress-group](#module\_alb-controller-ingress-group) | cloudposse/stack-config/yaml//modules/remote-state | 0.22.4 |
88-
| <a name="module_echo_server"></a> [echo\_server](#module\_echo\_server) | cloudposse/helm-release/aws | 0.5.0 |
89-
| <a name="module_eks"></a> [eks](#module\_eks) | cloudposse/stack-config/yaml//modules/remote-state | 0.22.4 |
88+
| <a name="module_echo_server"></a> [echo\_server](#module\_echo\_server) | cloudposse/helm-release/aws | 0.7.0 |
89+
| <a name="module_eks"></a> [eks](#module\_eks) | cloudposse/stack-config/yaml//modules/remote-state | 1.3.1 |
9090
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../../account-map/modules/iam-roles | n/a |
9191
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
9292
9393
## Resources
9494
9595
| Name | Type |
9696
|------|------|
97-
| [kubernetes_namespace.default](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
9897
| [aws_eks_cluster.kubernetes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |
9998
| [aws_eks_cluster_auth.eks](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source |
10099
| [aws_eks_cluster_auth.kubernetes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source |
@@ -104,12 +103,9 @@ components:
104103
| Name | Description | Type | Default | Required |
105104
|------|-------------|------|---------|:--------:|
106105
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
107-
| <a name="input_alb_access_logs_enabled"></a> [alb\_access\_logs\_enabled](#input\_alb\_access\_logs\_enabled) | Whether or not to enable access logs for the ALB | `bool` | `false` | no |
108-
| <a name="input_alb_access_logs_s3_bucket_name"></a> [alb\_access\_logs\_s3\_bucket\_name](#input\_alb\_access\_logs\_s3\_bucket\_name) | The name of the S3 bucket to store the access logs in | `string` | `null` | no |
109-
| <a name="input_alb_access_logs_s3_bucket_prefix"></a> [alb\_access\_logs\_s3\_bucket\_prefix](#input\_alb\_access\_logs\_s3\_bucket\_prefix) | The prefix to use when storing the access logs | `string` | `"echo-server"` | no |
110-
| <a name="input_alb_controller_ingress_group_component_name"></a> [alb\_controller\_ingress\_group\_component\_name](#input\_alb\_controller\_ingress\_group\_component\_name) | The name of the alb-controller-ingress-group component | `string` | `"eks/alb-controller-ingress-group"` | no |
111106
| <a name="input_atomic"></a> [atomic](#input\_atomic) | If set, installation process purges chart on fail. The wait flag will be set automatically if atomic is used. | `bool` | `true` | no |
112107
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no |
108+
| <a name="input_chart_values"></a> [chart\_values](#input\_chart\_values) | Addition map values to yamlencode as `helm_release` values. | `any` | `{}` | no |
113109
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | Specify the exact chart version to install. If this is not specified, the latest version is installed. | `string` | `null` | no |
114110
| <a name="input_cleanup_on_fail"></a> [cleanup\_on\_fail](#input\_cleanup\_on\_fail) | Allow deletion of new resources created in this upgrade when upgrade fails. | `bool` | `true` | no |
115111
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
@@ -118,7 +114,6 @@ components:
118114
| <a name="input_description"></a> [description](#input\_description) | Set release description attribute (visible in the history). | `string` | `null` | no |
119115
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
120116
| <a name="input_eks_component_name"></a> [eks\_component\_name](#input\_eks\_component\_name) | The name of the eks component | `string` | `"eks/cluster"` | no |
121-
| <a name="input_enable_alb_controller_ingress_group"></a> [enable\_alb\_controller\_ingress\_group](#input\_enable\_alb\_controller\_ingress\_group) | Uses alb-controller-ingress-group component for alb ingress group | `bool` | `false` | no |
122117
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
123118
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
124119
| <a name="input_helm_manifest_experiment_enabled"></a> [helm\_manifest\_experiment\_enabled](#input\_helm\_manifest\_experiment\_enabled) | Enable storing of the rendered manifest for helm\_release so the full diff of what is changing can been seen in the plan | `bool` | `true` | no |

src/charts/echo-server/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ spec:
2121
- name: {{ .Chart.Name }}
2222
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
2323
imagePullPolicy: {{ .Values.image.pullPolicy }}
24+
args:
25+
# Disable the feature that turns the echo server into a file browser on the server (security risk)
26+
- "--enable:file=false"
2427
ports:
2528
- name: http
2629
containerPort: 80

src/charts/echo-server/templates/ingress.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,10 @@ metadata:
99
name: {{ $fullName }}
1010
annotations:
1111
{{- if eq (printf "%v" .Values.ingress.nginx.enabled) "true" }}
12-
kubernetes.io/ingress.class: {{ .Values.ingress.nginx.class }}
1312
{{- if (index .Values.ingress.nginx "tls_certificate_cluster_issuer") }}
1413
cert-manager.io/cluster-issuer: {{ .Values.ingress.nginx.tls_certificate_cluster_issuer }}
1514
{{- end }}
1615
{{- else if eq (printf "%v" .Values.ingress.alb.enabled) "true" }}
17-
kubernetes.io/ingress.class: {{ .Values.ingress.alb.class }}
18-
{{- if not .Values.ingress.alb.group_name }}
19-
alb.ingress.kubernetes.io/load-balancer-name: {{ index .Values.ingress.alb "load_balancer_name" | default "k8s-common" }}
20-
{{- end }}
21-
alb.ingress.kubernetes.io/group.name: {{ index .Values.ingress.alb "group_name" | default "common" }}
22-
alb.ingress.kubernetes.io/scheme: internet-facing
23-
{{- if .Values.ingress.alb.access_logs.enabled }}
24-
alb.ingress.kubernetes.io/load-balancer-attributes: access_logs.s3.enabled=true,access_logs.s3.bucket={{.Values.ingress.alb.access_logs.s3_bucket_name}},access_logs.s3.prefix={{.Values.ingress.alb.access_logs.s3_bucket_prefix}}
25-
{{- end }}
2616
alb.ingress.kubernetes.io/target-type: 'ip'
2717
{{- if eq (printf "%v" .Values.ingress.alb.ssl_redirect.enabled) "true" }}
2818
alb.ingress.kubernetes.io/ssl-redirect: '{{ .Values.ingress.alb.ssl_redirect.port }}'

src/main.tf

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,32 @@ locals {
22
enabled = module.this.enabled
33
ingress_nginx_enabled = var.ingress_type == "nginx" ? true : false
44
ingress_alb_enabled = var.ingress_type == "alb" ? true : false
5-
6-
alb_access_logs_enabled = var.alb_access_logs_enabled && var.alb_access_logs_s3_bucket_name != null && var.alb_access_logs_s3_bucket_name != ""
7-
ingress_controller_group_enabled = var.enable_alb_controller_ingress_group ? [
8-
{
9-
name = "ingress.alb.group_name"
10-
value = module.alb-controller-ingress-group.outputs.group_name
11-
type = "auto"
12-
}
13-
] : []
14-
}
15-
16-
resource "kubernetes_namespace" "default" {
17-
count = local.enabled && var.create_namespace ? 1 : 0
18-
19-
metadata {
20-
name = var.kubernetes_namespace
21-
22-
labels = module.this.tags
23-
}
245
}
256

267
module "echo_server" {
278
source = "cloudposse/helm-release/aws"
28-
version = "0.5.0"
9+
version = "0.7.0"
2910

3011
name = module.this.name
3112
chart = "${path.module}/charts/echo-server"
3213

3314
# Optional arguments
34-
description = var.description
35-
repository = var.repository
36-
chart_version = var.chart_version
37-
kubernetes_namespace = join("", kubernetes_namespace.default.*.id)
38-
create_namespace = false
39-
verify = var.verify
40-
wait = var.wait
41-
atomic = var.atomic
42-
cleanup_on_fail = var.cleanup_on_fail
43-
timeout = var.timeout
15+
description = var.description
16+
repository = var.repository
17+
chart_version = var.chart_version
18+
verify = var.verify
19+
wait = var.wait
20+
atomic = var.atomic
21+
cleanup_on_fail = var.cleanup_on_fail
22+
timeout = var.timeout
23+
24+
create_namespace_with_kubernetes = var.create_namespace
25+
kubernetes_namespace = var.kubernetes_namespace
26+
kubernetes_namespace_labels = merge(module.this.tags, { name = var.kubernetes_namespace })
4427

4528
eks_cluster_oidc_issuer_url = replace(module.eks.outputs.eks_cluster_identity_oidc_issuer, "https://", "")
4629

47-
set = concat([
30+
set = [
4831
{
4932
name = "ingress.hostname"
5033
value = format(var.hostname_template, var.tenant, var.stage, var.environment)
@@ -60,28 +43,11 @@ module "echo_server" {
6043
value = local.ingress_alb_enabled
6144
type = "auto"
6245
},
63-
{
64-
name = "ingress.alb.access_logs.enabled"
65-
value = local.alb_access_logs_enabled
66-
type = "auto"
67-
},
68-
{
69-
name = "ingress.alb.access_logs.s3_bucket_name"
70-
value = var.alb_access_logs_s3_bucket_name == null ? "" : var.alb_access_logs_s3_bucket_name
71-
type = "auto"
72-
},
73-
{
74-
name = "ingress.alb.access_logs.s3_bucket_prefix"
75-
value = var.alb_access_logs_s3_bucket_prefix
76-
type = "auto"
77-
}
78-
],
79-
local.ingress_controller_group_enabled
80-
)
46+
]
8147

8248
values = compact([
83-
# hardcoded values
84-
file("${path.module}/values.yaml"),
49+
# additional values
50+
try(length(var.chart_values), 0) == 0 ? null : yamlencode(var.chart_values)
8551
])
8652

8753
context = module.this.context

src/remote-state.tf

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
module "eks" {
22
source = "cloudposse/stack-config/yaml//modules/remote-state"
3-
version = "0.22.4"
3+
version = "1.3.1"
44

55
component = var.eks_component_name
66

77
context = module.this.context
88
}
9-
10-
module "alb-controller-ingress-group" {
11-
source = "cloudposse/stack-config/yaml//modules/remote-state"
12-
version = "0.22.4"
13-
14-
component = var.alb_controller_ingress_group_component_name
15-
16-
context = module.this.context
17-
}
18-

src/values.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/variables.tf

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,8 @@ variable "eks_component_name" {
99
default = "eks/cluster"
1010
}
1111

12-
variable "alb_controller_ingress_group_component_name" {
13-
type = string
14-
description = "The name of the alb-controller-ingress-group component"
15-
default = "eks/alb-controller-ingress-group"
16-
}
17-
18-
variable "enable_alb_controller_ingress_group" {
19-
type = bool
20-
description = "Uses alb-controller-ingress-group component for alb ingress group"
21-
default = false
22-
}
23-
24-
variable "alb_access_logs_enabled" {
25-
type = bool
26-
description = "Whether or not to enable access logs for the ALB"
27-
default = false
28-
}
29-
30-
variable "alb_access_logs_s3_bucket_name" {
31-
type = string
32-
description = "The name of the S3 bucket to store the access logs in"
33-
default = null
34-
}
35-
36-
variable "alb_access_logs_s3_bucket_prefix" {
37-
type = string
38-
description = "The prefix to use when storing the access logs"
39-
default = "echo-server"
12+
variable "chart_values" {
13+
type = any
14+
description = "Addition map values to yamlencode as `helm_release` values."
15+
default = {}
4016
}

src/versions.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ terraform {
1010
source = "hashicorp/helm"
1111
version = ">= 2.0"
1212
}
13+
kubernetes = {
14+
source = "hashicorp/kubernetes"
15+
version = ">= 2.7.1"
16+
}
1317
}
1418
}

0 commit comments

Comments
 (0)