Skip to content

Commit 4e65dc8

Browse files
committed
fix(helm): generate namespace-aware SANs in certgen and cert-manager templates
The certgen hook and cert-manager Certificate template hardcoded openshell.openshell.svc.cluster.local in server certificate SANs, breaking deployments in any namespace other than openshell. Use .Release.Namespace in the templates so the SANs match the actual service FQDN regardless of the target namespace. Closes #2060 Signed-off-by: Akram <[email protected]>
1 parent 474d2d4 commit 4e65dc8

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎deploy/helm/openshell/templates/_helpers.tpl‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ init-container
144144
{{- end -}}
145145
{{- end }}
146146

147+
{{/*
148+
Default server certificate DNS SANs derived from the release name and namespace.
149+
Returns a YAML list. Append extra SANs from values with range loops.
150+
*/}}
151+
{{- define "openshell.defaultServerDnsNames" -}}
152+
{{- $name := include "openshell.fullname" . -}}
153+
{{- $ns := .Release.Namespace -}}
154+
{{- list $name
155+
(printf "%s.%s.svc" $name $ns)
156+
(printf "%s.%s.svc.cluster.local" $name $ns)
157+
"localhost"
158+
(printf "%s.localhost" $name)
159+
(printf "*.%s.localhost" $name)
160+
"host.docker.internal"
161+
"host.containers.internal"
162+
| toYaml }}
163+
{{- end }}
164+
147165
{{/*
148166
Gateway workload kind. StatefulSet is the default because the default SQLite
149167
database requires persistent per-pod storage.

‎deploy/helm/openshell/templates/cert-manager-pki.yaml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ spec:
5555
renewBefore: {{ .Values.certManager.certificateRenewBefore | quote }}
5656
commonName: openshell-server
5757
dnsNames:
58-
{{- toYaml .Values.certManager.serverDnsNames | nindent 4 }}
58+
{{- range (include "openshell.defaultServerDnsNames" . | fromYamlArray) }}
59+
- {{ . | quote }}
60+
{{- end }}
61+
{{- range .Values.certManager.serverDnsNames }}
62+
- {{ . | quote }}
63+
{{- end }}
5964
{{- if .Values.certManager.serverIpAddresses }}
6065
ipAddresses:
6166
{{- toYaml .Values.certManager.serverIpAddresses | nindent 4 }}

‎deploy/helm/openshell/templates/certgen.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ spec:
103103
{{- end }}
104104
- --jwt-secret-name={{ include "openshell.sandboxJwtSecretName" . }}
105105
{{- if and .Values.pkiInitJob.enabled (not .Values.certManager.enabled) }}
106+
{{- range (include "openshell.defaultServerDnsNames" . | fromYamlArray) }}
107+
- --server-san={{ . }}
108+
{{- end }}
109+
- --server-san=127.0.0.1
106110
{{- range .Values.pkiInitJob.serverDnsNames }}
107111
- --server-san={{ . }}
108112
{{- end }}

0 commit comments

Comments
 (0)