Skip to content

Commit 8bcc109

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 NVIDIA#2060 Signed-off-by: Akram <[email protected]>
1 parent 474d2d4 commit 8bcc109

4 files changed

Lines changed: 28 additions & 10 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ 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+
- {{ include "openshell.fullname" . }}
153+
- {{ include "openshell.fullname" . }}.{{ .Release.Namespace }}.svc
154+
- {{ include "openshell.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
155+
- localhost
156+
- {{ include "openshell.fullname" . }}.localhost
157+
- "*.{{ include "openshell.fullname" . }}.localhost"
158+
- host.docker.internal
159+
- host.containers.internal
160+
{{- end }}
161+
147162
{{/*
148163
Gateway workload kind. StatefulSet is the default because the default SQLite
149164
database requires persistent per-pod storage.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ spec:
5555
renewBefore: {{ .Values.certManager.certificateRenewBefore | quote }}
5656
commonName: openshell-server
5757
dnsNames:
58-
{{- toYaml .Values.certManager.serverDnsNames | nindent 4 }}
58+
{{- include "openshell.defaultServerDnsNames" . | nindent 4 }}
59+
{{- range .Values.certManager.serverDnsNames }}
60+
- {{ . }}
61+
{{- end }}
5962
{{- if .Values.certManager.serverIpAddresses }}
6063
ipAddresses:
6164
{{- 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 }}

‎deploy/helm/openshell/values.yaml‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,11 @@ certManager:
336336
certificateDuration: 8760h
337337
# -- Renewal window for cert-manager-issued certificates.
338338
certificateRenewBefore: 720h
339-
# -- DNS SANs on the cert-manager-issued server certificate.
340-
serverDnsNames:
341-
- openshell
342-
- openshell.openshell.svc
343-
- openshell.openshell.svc.cluster.local
344-
- localhost
345-
- openshell.localhost
346-
- "*.openshell.localhost"
347-
- host.docker.internal
339+
# -- Extra DNS SANs to append to the cert-manager-issued server certificate.
340+
# The template automatically includes namespace-aware SANs derived from
341+
# .Release.Namespace (e.g. openshell.<namespace>.svc.cluster.local),
342+
# localhost, and container host aliases.
343+
serverDnsNames: []
348344
# -- IP SANs on the cert-manager-issued server certificate.
349345
serverIpAddresses:
350346
- 127.0.0.1

0 commit comments

Comments
 (0)