Skip to content

Commit b9380c1

Browse files
agfunderburg10Nuru
andauthored
fix: allow component to deploy correctly when create_namespace is false (#1011)
Co-authored-by: Nuru <[email protected]>
1 parent 902271c commit b9380c1

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

modules/eks/metrics-server/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,13 @@ components:
6262
|------|--------|---------|
6363
| <a name="module_eks"></a> [eks](#module\_eks) | cloudposse/stack-config/yaml//modules/remote-state | 1.5.0 |
6464
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../../account-map/modules/iam-roles | n/a |
65-
| <a name="module_metrics_server"></a> [metrics\_server](#module\_metrics\_server) | cloudposse/helm-release/aws | 0.10.0 |
65+
| <a name="module_metrics_server"></a> [metrics\_server](#module\_metrics\_server) | cloudposse/helm-release/aws | 0.10.1 |
6666
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
6767
6868
## Resources
6969
7070
| Name | Type |
7171
|------|------|
72-
| [kubernetes_namespace.default](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
7372
| [aws_eks_cluster_auth.eks](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source |
7473
7574
## Inputs
@@ -86,7 +85,7 @@ components:
8685
| <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` | `"6.2.6"` | no |
8786
| <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 |
8887
| <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 |
89-
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Create the namespace if it does not yet exist. Defaults to `false`. | `bool` | `true` | no |
88+
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Create the namespace if it does not yet exist. Defaults to `true`. | `bool` | `true` | no |
9089
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
9190
| <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 |
9291
| <a name="input_eks_component_name"></a> [eks\_component\_name](#input\_eks\_component\_name) | The name of the eks component | `string` | `"eks/cluster"` | no |

modules/eks/metrics-server/main.tf

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,27 @@ locals {
22
enabled = module.this.enabled
33
}
44

5-
resource "kubernetes_namespace" "default" {
6-
count = local.enabled && var.create_namespace ? 1 : 0
7-
8-
metadata {
9-
name = var.kubernetes_namespace
10-
11-
labels = module.this.tags
12-
}
5+
moved {
6+
from = kubernetes_namespace.default
7+
to = module.metrics_server.kubernetes_namespace.default
138
}
149

1510
module "metrics_server" {
1611
source = "cloudposse/helm-release/aws"
17-
version = "0.10.0"
12+
version = "0.10.1"
13+
14+
name = "" # avoids hitting length restrictions on IAM Role names
15+
chart = var.chart
16+
repository = var.chart_repository
17+
description = var.chart_description
18+
chart_version = var.chart_version
19+
wait = var.wait
20+
atomic = var.atomic
21+
cleanup_on_fail = var.cleanup_on_fail
22+
timeout = var.timeout
1823

19-
name = "" # avoids hitting length restrictions on IAM Role names
20-
chart = var.chart
21-
repository = var.chart_repository
22-
description = var.chart_description
23-
chart_version = var.chart_version
24-
kubernetes_namespace = join("", kubernetes_namespace.default.*.id)
25-
create_namespace = false
26-
wait = var.wait
27-
atomic = var.atomic
28-
cleanup_on_fail = var.cleanup_on_fail
29-
timeout = var.timeout
24+
kubernetes_namespace = var.kubernetes_namespace
25+
create_namespace_with_kubernetes = var.create_namespace
3026

3127
eks_cluster_oidc_issuer_url = replace(module.eks.outputs.eks_cluster_identity_oidc_issuer, "https://", "")
3228

@@ -47,7 +43,9 @@ module "metrics_server" {
4743
# metrics-server-specific values
4844
yamlencode({
4945
podLabels = merge({
50-
chart = var.chart
46+
chart = var.chart
47+
# TODO: These should be configurable
48+
# Chart should default to https://kubernetes-sigs.github.io/metrics-server/
5149
repo = "bitnami"
5250
component = "hpa"
5351
namespace = var.kubernetes_namespace

modules/eks/metrics-server/variables.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ variable "chart" {
1818
variable "chart_repository" {
1919
type = string
2020
description = "Repository URL where to locate the requested chart."
21-
default = "https://charts.bitnami.com/bitnami"
21+
# TODO: Chart should default to https://kubernetes-sigs.github.io/metrics-server/
22+
default = "https://charts.bitnami.com/bitnami"
2223
}
2324

2425
variable "chart_version" {
@@ -53,7 +54,7 @@ variable "resources" {
5354

5455
variable "create_namespace" {
5556
type = bool
56-
description = "Create the namespace if it does not yet exist. Defaults to `false`."
57+
description = "Create the namespace if it does not yet exist. Defaults to `true`."
5758
default = true
5859
}
5960

0 commit comments

Comments
 (0)