From d600e2fe72dc7f1f778ed549d37ebd3fef2a0c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Wed, 19 Feb 2025 17:44:07 +0100 Subject: [PATCH 1/5] implement certManager automatic configuration --- .../source/common/sub_schema_values.yaml.j2 | 7 +++++ charts/matrix-stack/source/values.schema.json | 11 +++++++ .../templates/element-web/ingress.yaml | 2 +- .../templates/ess-library/_ingress.tpl | 14 +++++++-- .../ingress.yaml | 2 +- .../templates/synapse/synapse_ingress.yaml | 2 +- .../templates/well-known/ingress.yaml | 2 +- charts/matrix-stack/values.schema.json | 12 +++++++ charts/matrix-stack/values.yaml | 7 +++++ newsfragments/217.added.md | 1 + tests/manifests/test_ingresses.py | 31 +++++++++++++++++++ 11 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 newsfragments/217.added.md diff --git a/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 b/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 index f92bc8a2..42be6232 100644 --- a/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 +++ b/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 @@ -15,6 +15,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial matrixTools: {{ image(registry="ghcr.io", repository="element-hq/ess-helm/matrix-tools", tag="0.3.0") | indent(2) }} +## CertManager Issuer to configure by default automatically on all ingresses +## If configured, the chart will automatically generate the tlsSecret name for all ingresses +certManager: {} + ## Choose one of clusterIssuer or issuer + # clusterIssuer: + # issuer: + ## The server name of the Matrix Stack. This gets embedded in user IDs & room IDs ## It can not change after the initial deployment. # serverName: ess.localhost diff --git a/charts/matrix-stack/source/values.schema.json b/charts/matrix-stack/source/values.schema.json index 94f34aa5..dcc11018 100644 --- a/charts/matrix-stack/source/values.schema.json +++ b/charts/matrix-stack/source/values.schema.json @@ -12,6 +12,17 @@ "labels": { "$ref": "file://common/labels.json" }, + "certManager": { + "type": "object", + "properties": { + "clusterIssuer": { + "type": "string" + }, + "issuer": { + "type": "string" + } + } + }, "matrixTools": { "type": "object", "properties": { diff --git a/charts/matrix-stack/templates/element-web/ingress.yaml b/charts/matrix-stack/templates/element-web/ingress.yaml index ed2b1cba..d66df220 100644 --- a/charts/matrix-stack/templates/element-web/ingress.yaml +++ b/charts/matrix-stack/templates/element-web/ingress.yaml @@ -14,7 +14,7 @@ metadata: name: {{ $.Release.Name }}-element-web namespace: {{ $.Release.Namespace }} spec: -{{- include "element-io.ess-library.ingress.tlsSecret" (dict "root" $ "context" (dict "hosts" (list (required "elementWeb.ingress.host is required" .ingress.host)) "tlsSecret" .ingress.tlsSecret)) | nindent 2 }} +{{- include "element-io.ess-library.ingress.tlsSecret" (dict "root" $ "context" (dict "hosts" (list (required "elementWeb.ingress.host is required" .ingress.host)) "tlsSecret" .ingress.tlsSecret "ingressName" "element-web")) | nindent 2 }} {{- include "element-io.ess-library.ingress.className" (dict "root" $ "context" .ingress.className) | nindent 2 }} rules: - host: {{ (tpl .ingress.host $) | quote }} diff --git a/charts/matrix-stack/templates/ess-library/_ingress.tpl b/charts/matrix-stack/templates/ess-library/_ingress.tpl index 9fb38dc9..10ab6ac8 100644 --- a/charts/matrix-stack/templates/ess-library/_ingress.tpl +++ b/charts/matrix-stack/templates/ess-library/_ingress.tpl @@ -10,6 +10,14 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial {{- fail "element-io.ess-library.ingress.annotations missing context" -}} {{- end }} {{- $annotations := dict -}} +{{- with $root.Values.certManager -}} +{{- with .clusterIssuer -}} +{{- $annotations = merge $annotations (dict "cert-manager.io/cluster-issuer" .) -}} +{{- end -}} +{{- with .issuer -}} +{{- $annotations = merge $annotations (dict "cert-manager.io/issuer" .) -}} +{{- end -}} +{{- end -}} {{- $annotations = mustMergeOverwrite $annotations ($root.Values.ingress.annotations | deepCopy) -}} {{- $annotations = mustMergeOverwrite $annotations (.context | deepCopy) -}} {{- with $annotations -}} @@ -21,14 +29,16 @@ annotations: {{- define "element-io.ess-library.ingress.tlsSecret" -}} {{- $root := .root -}} {{- with required "element-io.ess-library.ingress.tlsSecret missing context" .context -}} +{{- $ingressName := required "element-io.ess-library.ingress.tlsSecret missing ingress name" .ingressName -}} {{- $hosts := .hosts -}} -{{- with coalesce .tlsSecret $root.Values.ingress.tlsSecret -}} +{{- $tlsSecret := coalesce .tlsSecret $root.Values.ingress.tlsSecret -}} +{{- if or $tlsSecret $root.Values.certManager -}} tls: - hosts: {{- range $host := $hosts }} - {{ (tpl $host $root) | quote }} {{- end }} - secretName: {{ (tpl . $root) | quote }} + secretName: {{ (tpl ($tlsSecret | default (printf "{{ .Release.Name }}-%s-certmanager-tls" $ingressName)) $root) | quote }} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/matrix-stack/templates/matrix-authentication-service/ingress.yaml b/charts/matrix-stack/templates/matrix-authentication-service/ingress.yaml index 3e55903d..f614565f 100644 --- a/charts/matrix-stack/templates/matrix-authentication-service/ingress.yaml +++ b/charts/matrix-stack/templates/matrix-authentication-service/ingress.yaml @@ -15,7 +15,7 @@ metadata: name: {{ $.Release.Name }}-matrix-authentication-service namespace: {{ $.Release.Namespace }} spec: -{{- include "element-io.ess-library.ingress.tlsSecret" (dict "root" $ "context" (dict "hosts" (list (required "matrixAuthenticationService.ingress.host is required" .ingress.host)) "tlsSecret" .ingress.tlsSecret)) | nindent 2 }} +{{- include "element-io.ess-library.ingress.tlsSecret" (dict "root" $ "context" (dict "hosts" (list (required "matrixAuthenticationService.ingress.host is required" .ingress.host)) "tlsSecret" .ingress.tlsSecret "ingressName" "matrix-authentication-service")) | nindent 2 }} {{- include "element-io.ess-library.ingress.className" (dict "root" $ "context" .ingress.className) | nindent 2 }} rules: - host: {{ (tpl .ingress.host $) | quote }} diff --git a/charts/matrix-stack/templates/synapse/synapse_ingress.yaml b/charts/matrix-stack/templates/synapse/synapse_ingress.yaml index 4e20b336..349a4e69 100644 --- a/charts/matrix-stack/templates/synapse/synapse_ingress.yaml +++ b/charts/matrix-stack/templates/synapse/synapse_ingress.yaml @@ -15,7 +15,7 @@ metadata: name: {{ $.Release.Name }}-synapse namespace: {{ $.Release.Namespace }} spec: -{{- include "element-io.ess-library.ingress.tlsSecret" (dict "root" $ "context" (dict "hosts" (list (required "synapse.ingress.host is required" .ingress.host)) "tlsSecret" .ingress.tlsSecret)) | nindent 2 }} +{{- include "element-io.ess-library.ingress.tlsSecret" (dict "root" $ "context" (dict "hosts" (list (required "synapse.ingress.host is required" .ingress.host)) "tlsSecret" .ingress.tlsSecret "ingressName" "synapse")) | nindent 2 }} {{- include "element-io.ess-library.ingress.className" (dict "root" $ "context" .ingress.className) | nindent 2 }} rules: - host: {{ (tpl .ingress.host $) | quote }} diff --git a/charts/matrix-stack/templates/well-known/ingress.yaml b/charts/matrix-stack/templates/well-known/ingress.yaml index 443dfd2a..2bb8fa56 100644 --- a/charts/matrix-stack/templates/well-known/ingress.yaml +++ b/charts/matrix-stack/templates/well-known/ingress.yaml @@ -15,7 +15,7 @@ metadata: name: {{ $.Release.Name }}-well-known namespace: {{ $.Release.Namespace }} spec: -{{- include "element-io.ess-library.ingress.tlsSecret" (dict "root" $ "context" (dict "hosts" (list (.ingress.host | default $.Values.serverName)) "tlsSecret" .ingress.tlsSecret)) | nindent 2 }} +{{- include "element-io.ess-library.ingress.tlsSecret" (dict "root" $ "context" (dict "hosts" (list (.ingress.host | default $.Values.serverName)) "tlsSecret" .ingress.tlsSecret "ingressName" "well-known")) | nindent 2 }} {{- include "element-io.ess-library.ingress.className" (dict "root" $ "context" .ingress.className) | nindent 2 }} rules: - host: "{{ tpl ($.Values.wellKnownDelegation.ingress.host | default $.Values.serverName) $ }}" diff --git a/charts/matrix-stack/values.schema.json b/charts/matrix-stack/values.schema.json index 72173f51..5386743b 100644 --- a/charts/matrix-stack/values.schema.json +++ b/charts/matrix-stack/values.schema.json @@ -19,6 +19,18 @@ ] } }, + "certManager": { + "type": "object", + "properties": { + "clusterIssuer": { + "type": "string" + }, + "issuer": { + "type": "string" + } + }, + "additionalProperties": false + }, "matrixTools": { "type": "object", "properties": { diff --git a/charts/matrix-stack/values.yaml b/charts/matrix-stack/values.yaml index f0a5e743..3d837eb4 100644 --- a/charts/matrix-stack/values.yaml +++ b/charts/matrix-stack/values.yaml @@ -36,6 +36,13 @@ matrixTools: ## - name: dockerhub pullSecrets: [] +## CertManager Issuer to configure by default automatically on all ingresses +## If configured, the chart will automatically generate the tlsSecret name for all ingresses +certManager: {} + ## Choose one of clusterIssuer or issuer + # clusterIssuer: + # issuer: + ## The server name of the Matrix Stack. This gets embedded in user IDs & room IDs ## It can not change after the initial deployment. # serverName: ess.localhost diff --git a/newsfragments/217.added.md b/newsfragments/217.added.md new file mode 100644 index 00000000..580ef92c --- /dev/null +++ b/newsfragments/217.added.md @@ -0,0 +1 @@ +Add a value to automatically configure CertManager on all ingresses. diff --git a/tests/manifests/test_ingresses.py b/tests/manifests/test_ingresses.py index 7861ee72..9dfb2f8b 100644 --- a/tests/manifests/test_ingresses.py +++ b/tests/manifests/test_ingresses.py @@ -243,3 +243,34 @@ async def test_ingress_services(templates): f"Port number {backend_service['port']['number']} " f"not found in service {backend_service['name']}" ) + +@pytest.mark.parametrize("values_file", values_files_with_ingresses) +@pytest.mark.asyncio_cooperative +async def test_ingress_certmanager_clusterissuer(make_templates, values): + values.setdefault("certManager", {})["clusterIssuer"] = "cluster-issuer-name" + for template in await make_templates(values): + if template['kind'] == 'Ingress': + assert "cert-manager.io/cluster-issuer" in template["metadata"]["annotations"], ( + f"Ingress {template['name']} does not have cert-manager annotation" + ) + assert template["metadata"]["annotations"]["cert-manager.io/cluster-issuer"] == "cluster-issuer-name" + assert template["spec"]["tls"][0]["secretName"].endswith("-certmanager-tls"), ( + f"Ingress {template['name']} does not have correct secret name for cert-manager tls" + ) + + + +@pytest.mark.parametrize("values_file", values_files_with_ingresses) +@pytest.mark.asyncio_cooperative +async def test_ingress_certmanager_issuer(make_templates, values): + values.setdefault("certManager", {})["issuer"] = "issuer-name" + for template in await make_templates(values): + if template['kind'] == 'Ingress': + assert "cert-manager.io/issuer" in template["metadata"]["annotations"], ( + f"Ingress {template['name']} does not have cert-manager annotation" + ) + assert template["metadata"]["annotations"]["cert-manager.io/issuer"] == "issuer-name" + assert template["spec"]["tls"][0]["secretName"].endswith("-certmanager-tls"), ( + f"Ingress {template['name']} does not have correct secret name for cert-manager tls" + ) + From 505eff820dc55b4538d186d724f37e873bd61de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Wed, 19 Feb 2025 18:05:24 +0100 Subject: [PATCH 2/5] ingress: dont set certManager annotation if tlsSecret is defined --- .../templates/element-web/ingress.yaml | 2 +- .../templates/ess-library/_ingress.tpl | 5 ++++- .../ingress.yaml | 2 +- .../templates/synapse/synapse_ingress.yaml | 2 +- .../templates/well-known/ingress.yaml | 2 +- tests/manifests/test_ingresses.py | 19 +++++++++++++++++-- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/charts/matrix-stack/templates/element-web/ingress.yaml b/charts/matrix-stack/templates/element-web/ingress.yaml index d66df220..b1fd21b5 100644 --- a/charts/matrix-stack/templates/element-web/ingress.yaml +++ b/charts/matrix-stack/templates/element-web/ingress.yaml @@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial apiVersion: networking.k8s.io/v1 kind: Ingress metadata: -{{- include "element-io.ess-library.ingress.annotations" (dict "root" $ "context" .ingress.annotations) | nindent 2 }} +{{- include "element-io.ess-library.ingress.annotations" (dict "root" $ "context" .ingress) | nindent 2 }} labels: {{- include "element-io.element-web.labels" (dict "root" $ "context" .) | nindent 4 }} name: {{ $.Release.Name }}-element-web diff --git a/charts/matrix-stack/templates/ess-library/_ingress.tpl b/charts/matrix-stack/templates/ess-library/_ingress.tpl index 10ab6ac8..9f6f25a7 100644 --- a/charts/matrix-stack/templates/ess-library/_ingress.tpl +++ b/charts/matrix-stack/templates/ess-library/_ingress.tpl @@ -10,6 +10,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial {{- fail "element-io.ess-library.ingress.annotations missing context" -}} {{- end }} {{- $annotations := dict -}} +{{- $tlsSecret := coalesce .context.tlsSecret $root.Values.ingress.tlsSecret -}} +{{- if and (not $tlsSecret) $root.Values.certManager -}} {{- with $root.Values.certManager -}} {{- with .clusterIssuer -}} {{- $annotations = merge $annotations (dict "cert-manager.io/cluster-issuer" .) -}} @@ -18,8 +20,9 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial {{- $annotations = merge $annotations (dict "cert-manager.io/issuer" .) -}} {{- end -}} {{- end -}} +{{- end -}} {{- $annotations = mustMergeOverwrite $annotations ($root.Values.ingress.annotations | deepCopy) -}} -{{- $annotations = mustMergeOverwrite $annotations (.context | deepCopy) -}} +{{- $annotations = mustMergeOverwrite $annotations (.context.annotations | deepCopy) -}} {{- with $annotations -}} annotations: {{- toYaml . | nindent 2 }} diff --git a/charts/matrix-stack/templates/matrix-authentication-service/ingress.yaml b/charts/matrix-stack/templates/matrix-authentication-service/ingress.yaml index f614565f..dbbb12a7 100644 --- a/charts/matrix-stack/templates/matrix-authentication-service/ingress.yaml +++ b/charts/matrix-stack/templates/matrix-authentication-service/ingress.yaml @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial apiVersion: networking.k8s.io/v1 kind: Ingress metadata: -{{- include "element-io.ess-library.ingress.annotations" (dict "root" $ "context" .ingress.annotations) | nindent 2 }} +{{- include "element-io.ess-library.ingress.annotations" (dict "root" $ "context" .ingress) | nindent 2 }} labels: {{- include "element-io.matrix-authentication-service.labels" (dict "root" $ "context" .) | nindent 4 }} name: {{ $.Release.Name }}-matrix-authentication-service diff --git a/charts/matrix-stack/templates/synapse/synapse_ingress.yaml b/charts/matrix-stack/templates/synapse/synapse_ingress.yaml index 349a4e69..7a272b45 100644 --- a/charts/matrix-stack/templates/synapse/synapse_ingress.yaml +++ b/charts/matrix-stack/templates/synapse/synapse_ingress.yaml @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial apiVersion: networking.k8s.io/v1 kind: Ingress metadata: -{{- include "element-io.ess-library.ingress.annotations" (dict "root" $ "context" .ingress.annotations) | nindent 2 }} +{{- include "element-io.ess-library.ingress.annotations" (dict "root" $ "context" .ingress) | nindent 2 }} labels: {{- include "element-io.synapse-ingress.labels" (dict "root" $ "context" $.Values.haproxy) | nindent 4 }} name: {{ $.Release.Name }}-synapse diff --git a/charts/matrix-stack/templates/well-known/ingress.yaml b/charts/matrix-stack/templates/well-known/ingress.yaml index 2bb8fa56..a0bf051d 100644 --- a/charts/matrix-stack/templates/well-known/ingress.yaml +++ b/charts/matrix-stack/templates/well-known/ingress.yaml @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial apiVersion: networking.k8s.io/v1 kind: Ingress metadata: -{{- include "element-io.ess-library.ingress.annotations" (dict "root" $ "context" .ingress.annotations) | nindent 2 }} +{{- include "element-io.ess-library.ingress.annotations" (dict "root" $ "context" .ingress) | nindent 2 }} labels: {{- include "element-io.well-known-delegation-ingress.labels" (dict "root" $ "context" $.Values.haproxy) | nindent 4 }} name: {{ $.Release.Name }}-well-known diff --git a/tests/manifests/test_ingresses.py b/tests/manifests/test_ingresses.py index 9dfb2f8b..b09cadc8 100644 --- a/tests/manifests/test_ingresses.py +++ b/tests/manifests/test_ingresses.py @@ -246,7 +246,7 @@ async def test_ingress_services(templates): @pytest.mark.parametrize("values_file", values_files_with_ingresses) @pytest.mark.asyncio_cooperative -async def test_ingress_certmanager_clusterissuer(make_templates, values): +async def test_ingress_certManager_clusterissuer(make_templates, values): values.setdefault("certManager", {})["clusterIssuer"] = "cluster-issuer-name" for template in await make_templates(values): if template['kind'] == 'Ingress': @@ -262,7 +262,7 @@ async def test_ingress_certmanager_clusterissuer(make_templates, values): @pytest.mark.parametrize("values_file", values_files_with_ingresses) @pytest.mark.asyncio_cooperative -async def test_ingress_certmanager_issuer(make_templates, values): +async def test_ingress_certManager_issuer(make_templates, values): values.setdefault("certManager", {})["issuer"] = "issuer-name" for template in await make_templates(values): if template['kind'] == 'Ingress': @@ -274,3 +274,18 @@ async def test_ingress_certmanager_issuer(make_templates, values): f"Ingress {template['name']} does not have correct secret name for cert-manager tls" ) + +@pytest.mark.parametrize("values_file", values_files_with_ingresses) +@pytest.mark.asyncio_cooperative +async def test_component_ingress_tlsSecret_beats_certManager(component, values, make_templates): + values[component].setdefault("ingress", {})["tlsSecret"] = "component" + values.setdefault("certManager", {})["issuer"] = "issuer-name" + + for template in await make_templates(values): + if template["kind"] == "Ingress": + assert "tls" in template["spec"] + assert len(template["spec"]["tls"]) == 1 + assert len(template["spec"]["tls"][0]["hosts"]) == 1 + assert template["spec"]["tls"][0]["hosts"][0] == template["spec"]["rules"][0]["host"] + assert template["spec"]["tls"][0]["secretName"] == "component" + assert not template["metadata"].get("annotations") From 900660d53d76fe22b2291bc04d3612e1180e2136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Wed, 19 Feb 2025 18:07:30 +0100 Subject: [PATCH 3/5] ingress: with certManager, check the full secret name we expect --- tests/manifests/test_ingresses.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/manifests/test_ingresses.py b/tests/manifests/test_ingresses.py index b09cadc8..fc8f3de9 100644 --- a/tests/manifests/test_ingresses.py +++ b/tests/manifests/test_ingresses.py @@ -254,7 +254,7 @@ async def test_ingress_certManager_clusterissuer(make_templates, values): f"Ingress {template['name']} does not have cert-manager annotation" ) assert template["metadata"]["annotations"]["cert-manager.io/cluster-issuer"] == "cluster-issuer-name" - assert template["spec"]["tls"][0]["secretName"].endswith("-certmanager-tls"), ( + assert template["spec"]["tls"][0]["secretName"] == f"{template["metadata"]["name"]}-certmanager-tls", ( f"Ingress {template['name']} does not have correct secret name for cert-manager tls" ) @@ -270,7 +270,7 @@ async def test_ingress_certManager_issuer(make_templates, values): f"Ingress {template['name']} does not have cert-manager annotation" ) assert template["metadata"]["annotations"]["cert-manager.io/issuer"] == "issuer-name" - assert template["spec"]["tls"][0]["secretName"].endswith("-certmanager-tls"), ( + assert template["spec"]["tls"][0]["secretName"] == f"{template["metadata"]["name"]}-certmanager-tls", ( f"Ingress {template['name']} does not have correct secret name for cert-manager tls" ) From b15106ba4c7b48db3f62b86a5074f8c5916e5a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Wed, 19 Feb 2025 18:11:16 +0100 Subject: [PATCH 4/5] fix lint --- tests/integration/test_synapse.py | 4 +++- tests/manifests/test_ingresses.py | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/integration/test_synapse.py b/tests/integration/test_synapse.py index e1fd0219..bdda3aba 100644 --- a/tests/integration/test_synapse.py +++ b/tests/integration/test_synapse.py @@ -74,7 +74,9 @@ async def test_synapse_media_upload_fetch_authenticated( ) media_pod_suffix = ( - "synapse-media-repository-0" if value_file_has("synapse.workers.media-repository.enabled", True) else "synapse-main-0" + "synapse-media-repository-0" + if value_file_has("synapse.workers.media-repository.enabled", True) + else "synapse-main-0" ) media_pod = f"{generated_data.release_name}-{media_pod_suffix}" diff --git a/tests/manifests/test_ingresses.py b/tests/manifests/test_ingresses.py index fc8f3de9..4814e4f7 100644 --- a/tests/manifests/test_ingresses.py +++ b/tests/manifests/test_ingresses.py @@ -244,33 +244,33 @@ async def test_ingress_services(templates): f"not found in service {backend_service['name']}" ) + @pytest.mark.parametrize("values_file", values_files_with_ingresses) @pytest.mark.asyncio_cooperative async def test_ingress_certManager_clusterissuer(make_templates, values): values.setdefault("certManager", {})["clusterIssuer"] = "cluster-issuer-name" for template in await make_templates(values): - if template['kind'] == 'Ingress': + if template["kind"] == "Ingress": assert "cert-manager.io/cluster-issuer" in template["metadata"]["annotations"], ( f"Ingress {template['name']} does not have cert-manager annotation" ) assert template["metadata"]["annotations"]["cert-manager.io/cluster-issuer"] == "cluster-issuer-name" - assert template["spec"]["tls"][0]["secretName"] == f"{template["metadata"]["name"]}-certmanager-tls", ( + assert template["spec"]["tls"][0]["secretName"] == f"{template['metadata']['name']}-certmanager-tls", ( f"Ingress {template['name']} does not have correct secret name for cert-manager tls" ) - @pytest.mark.parametrize("values_file", values_files_with_ingresses) @pytest.mark.asyncio_cooperative async def test_ingress_certManager_issuer(make_templates, values): values.setdefault("certManager", {})["issuer"] = "issuer-name" for template in await make_templates(values): - if template['kind'] == 'Ingress': + if template["kind"] == "Ingress": assert "cert-manager.io/issuer" in template["metadata"]["annotations"], ( f"Ingress {template['name']} does not have cert-manager annotation" ) assert template["metadata"]["annotations"]["cert-manager.io/issuer"] == "issuer-name" - assert template["spec"]["tls"][0]["secretName"] == f"{template["metadata"]["name"]}-certmanager-tls", ( + assert template["spec"]["tls"][0]["secretName"] == f"{template['metadata']['name']}-certmanager-tls", ( f"Ingress {template['name']} does not have correct secret name for cert-manager tls" ) From e0f0a00836f2f37aa989bf9d1388d74dbb839730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Wed, 19 Feb 2025 18:15:49 +0100 Subject: [PATCH 5/5] setup_test_cluster: dont create the Certificate --- .../matrix-stack/ci/test-cluster-mixin.yaml | 4 ++-- scripts/setup_test_cluster.sh | 19 ------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/charts/matrix-stack/ci/test-cluster-mixin.yaml b/charts/matrix-stack/ci/test-cluster-mixin.yaml index bae2b198..70ed26ce 100644 --- a/charts/matrix-stack/ci/test-cluster-mixin.yaml +++ b/charts/matrix-stack/ci/test-cluster-mixin.yaml @@ -6,5 +6,5 @@ # It is a mixin to be used with other values file to enable # usage of the test cluster -ingress: - tlsSecret: ess-selfsigned +certManager: + clusterIssuer: ess-selfsigned diff --git a/scripts/setup_test_cluster.sh b/scripts/setup_test_cluster.sh index 4c5c9098..55f86869 100755 --- a/scripts/setup_test_cluster.sh +++ b/scripts/setup_test_cluster.sh @@ -120,24 +120,5 @@ metadata: pod-security.kubernetes.io/audit-version: ${server_version} pod-security.kubernetes.io/warn: restricted pod-security.kubernetes.io/warn-version: ${server_version} -EOF - cat <