mirror of
https://github.com/element-hq/ess-helm.git
synced 2026-11-21 09:31:28 -08:00
implement certManager automatic configuration
This commit is contained in:
11 files changed
+85
-6
No files matched your search
@@ -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
|
||||
|
||||
@@ -12,6 +12,17 @@
|
||||
"labels": {
|
||||
"$ref": "file://common/labels.json"
|
||||
},
|
||||
"certManager": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"clusterIssuer": {
|
||||
"type": "string"
|
||||
},
|
||||
"issuer": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"matrixTools": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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 -}}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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) $ }}"
|
||||
|
||||
@@ -19,6 +19,18 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"certManager": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"clusterIssuer": {
|
||||
"type": "string"
|
||||
},
|
||||
"issuer": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"matrixTools": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Add a value to automatically configure CertManager on all ingresses.
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user