Skip to content

Commit de1451b

Browse files
committed
fix(helm): complete legacy gateway config compatibility
Signed-off-by: Gaizka Menendez Hernandez <[email protected]>
1 parent b6c5b17 commit de1451b

26 files changed

Lines changed: 554 additions & 249 deletions

‎deploy/helm/openshell/README.md‎

Lines changed: 39 additions & 35 deletions
Large diffs are not rendered by default.

‎deploy/helm/openshell/README.md.gotmpl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ gatewayConfig:
252252
credential_drivers:
253253
- vault
254254
openshell.credential_drivers.vault:
255-
address: http://vault.vault.svc.cluster.local:8200
255+
address: https://vault.vault.svc.cluster.local:8200
256256
mount: secret
257257
kv_version: "2"
258258
auth_method: kubernetes

‎deploy/helm/openshell/ci/values-credential-driver-vault.yaml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ gatewayConfig:
1616
credential_drivers:
1717
- vault
1818
openshell.credential_drivers.vault:
19-
address: https://openbao.openbao.svc.cluster.local:8200
19+
# The local E2E fixture exposes this alias in the gateway namespace. It
20+
# also matches the DNS SAN in OpenBao's development TLS certificate.
21+
address: https://openbao-0:8200
2022
role: openshell-gateway
2123

2224
credentialDrivers:

‎deploy/helm/openshell/ci/values-keycloak.yaml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ gatewayConfig:
2525
openshell.gateway.oidc:
2626
# Must match KC_HOSTNAME set by keycloak:k8s:setup (in-cluster service hostname).
2727
issuer: "https://keycloak.keycloak.svc.cluster.local:443/realms/openshell"
28-
caConfigMapName: "openshell-keycloak-ca"
2928
# Must match the client ID in the imported realm (openshell-cli).
3029
audience: "openshell-cli"
3130
# Short TTL for dev so JWKS key rotation is picked up quickly.
@@ -36,3 +35,9 @@ gatewayConfig:
3635
# Leave both empty for authentication-only mode (any valid token is accepted).
3736
admin_role: "openshell-admin"
3837
user_role: "openshell-user"
38+
39+
# This is a Kubernetes ConfigMap mounted by the chart, not a gateway TOML
40+
# field, so it remains a chart-owned resource reference.
41+
server:
42+
oidc:
43+
caConfigMapName: "openshell-keycloak-ca"

‎deploy/helm/openshell/templates/_gateway-workload.tpl‎

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ Gateway pod template shared by the StatefulSet and Deployment workload shapes.
66
*/}}
77
{{- define "openshell.gatewayPodTemplate" -}}
88
{{- $gatewayConfig := .Values.gatewayConfig | default dict -}}
9-
{{- $gatewayRuntimeConfig := get $gatewayConfig "openshell.gateway" | default dict -}}
109
{{- $oidcRuntimeConfig := get $gatewayConfig "openshell.gateway.oidc" | default dict -}}
11-
{{- $kubernetesRuntimeConfig := get $gatewayConfig "openshell.drivers.kubernetes" | default dict -}}
10+
{{- if not (get $oidcRuntimeConfig "issuer") -}}{{- $oidcRuntimeConfig = .Values.server.oidc | default dict -}}{{- end -}}
11+
{{- $kubernetesRuntimeConfig := include "openshell.effectiveKubernetesConfig" . | fromYaml -}}
1212
{{- $spiffeSocketPath := get $kubernetesRuntimeConfig "provider_spiffe_workload_api_socket_path" -}}
1313
{{- $hasExternalCredentialDriver := or (eq (include "openshell.credentialDriverEnabled" (list . "kubernetes-secrets")) "true") (eq (include "openshell.credentialDriverEnabled" (list . "vault")) "true") -}}
1414
{{- $vaultCredentialDriverEnabled := eq (include "openshell.credentialDriverEnabled" (list . "vault")) "true" -}}
1515
{{- $credentialDrivers := .Values.credentialDrivers | default dict -}}
1616
{{- $vaultResources := get $credentialDrivers "vault" | default dict -}}
17-
{{- $vaultCaConfigMapName := get $vaultResources "caConfigMapName" -}}
17+
{{- $legacyCredentialDrivers := .Values.server.credentialDrivers | default dict -}}
18+
{{- $legacyVaultResources := get $legacyCredentialDrivers "vault" | default dict -}}
19+
{{- $vaultCaConfigMapName := get $vaultResources "caConfigMapName" | default (get $legacyVaultResources "caConfigMapName") -}}
1820
metadata:
1921
annotations:
2022
# Roll the gateway workload when the rendered gateway TOML changes - the
@@ -62,6 +64,50 @@ spec:
6264
- {{ .Values.server.dbUrl | quote }}
6365
{{- end }}
6466
env:
67+
- name: OPENSHELL_REPLICA_ID
68+
valueFrom:
69+
fieldRef:
70+
fieldPath: metadata.name
71+
- name: OPENSHELL_POD_NAME
72+
valueFrom:
73+
fieldRef:
74+
fieldPath: metadata.name
75+
- name: OPENSHELL_POD_NAMESPACE
76+
valueFrom:
77+
fieldRef:
78+
fieldPath: metadata.namespace
79+
{{- if eq (include "openshell.workloadKind" .) "deployment" }}
80+
- name: OPENSHELL_POD_IP
81+
valueFrom:
82+
fieldRef:
83+
fieldPath: status.podIP
84+
- name: OPENSHELL_PEER_ENDPOINT
85+
value: {{ printf "%s://$(OPENSHELL_POD_IP):%d" (ternary "http" "https" (default false .Values.server.disableTls)) (int .Values.service.port) | quote }}
86+
{{- end }}
87+
- name: OPENSHELL_SERVICE_ACCOUNT_NAME
88+
value: {{ include "openshell.serviceAccountName" . | quote }}
89+
- name: OPENSHELL_PEER_SERVICE_NAME
90+
value: {{ include "openshell.peerServiceName" . | quote }}
91+
- name: OPENSHELL_PEER_TOKEN_AUDIENCE
92+
value: "openshell-gateway-peer"
93+
- name: OPENSHELL_PEER_SERVICE_ACCOUNT_TOKEN_FILE
94+
value: /var/run/secrets/openshell-peer/token
95+
- name: OPENSHELL_PEER_POD_LABELS
96+
value: {{ printf "app.kubernetes.io/name=%s,app.kubernetes.io/instance=%s" (include "openshell.name" .) .Release.Name | quote }}
97+
{{- if not .Values.server.disableTls }}
98+
- name: OPENSHELL_PEER_TLS_SERVER_NAME
99+
value: {{ printf "%s.%s.svc.cluster.local" (include "openshell.fullname" .) .Release.Namespace | quote }}
100+
{{- if or .Values.pkiInitJob.enabled .Values.certManager.enabled }}
101+
- name: OPENSHELL_PEER_TLS_CA_FILE
102+
value: /etc/openshell-tls/server/ca.crt
103+
{{- end }}
104+
{{- if eq (include "openshell.gatewayClientCaEnabled" .) "true" }}
105+
- name: OPENSHELL_PEER_TLS_CERT_FILE
106+
value: /etc/openshell-tls/peer-client/tls.crt
107+
- name: OPENSHELL_PEER_TLS_KEY_FILE
108+
value: /etc/openshell-tls/peer-client/tls.key
109+
{{- end }}
110+
{{- end }}
65111
{{- if not $hasExternalCredentialDriver }}
66112
- name: {{ include "openshell.credentialStorageKeyEncryptionKeyEnvName" . }}
67113
valueFrom:
@@ -80,7 +126,7 @@ spec:
80126
# mounted at /etc/openshell/gateway.toml. Secret-bearing settings use
81127
# env vars that the TOML references by name. Some process-level
82128
# settings consumed by libraries outside gateway code also remain here.
83-
{{- if and (get $oidcRuntimeConfig "issuer") .Values.oidc.caConfigMapName }}
129+
{{- if and (get $oidcRuntimeConfig "issuer") .Values.server.oidc.caConfigMapName }}
84130
# OIDC issuer custom-CA: rustls/reqwest read SSL_CERT_FILE for
85131
# outbound TLS verification. This is a process-level env var
86132
# consumed by the TLS stack itself, not by gateway code, so it
@@ -109,6 +155,9 @@ spec:
109155
- name: sandbox-jwt
110156
mountPath: /etc/openshell-jwt
111157
readOnly: true
158+
- name: gateway-peer-token
159+
mountPath: /var/run/secrets/openshell-peer
160+
readOnly: true
112161
{{- if not .Values.server.disableTls }}
113162
- name: tls-cert
114163
mountPath: /etc/openshell-tls/server
@@ -119,19 +168,22 @@ spec:
119168
readOnly: true
120169
{{- end }}
121170
{{- if eq (include "openshell.gatewayClientCaEnabled" .) "true" }}
171+
- name: peer-client-tls
172+
mountPath: /etc/openshell-tls/peer-client
173+
readOnly: true
122174
- name: tls-client-ca
123175
mountPath: /etc/openshell-tls/client-ca
124176
readOnly: true
125177
{{- end }}
126178
{{- end }}
127-
{{- if and (get $oidcRuntimeConfig "issuer") .Values.oidc.caConfigMapName }}
179+
{{- if and (get $oidcRuntimeConfig "issuer") .Values.server.oidc.caConfigMapName }}
128180
- name: oidc-ca
129181
mountPath: /etc/openshell-tls/oidc-ca
130182
readOnly: true
131183
{{- end }}
132184
{{- if and $vaultCredentialDriverEnabled $vaultCaConfigMapName }}
133185
- name: vault-ca
134-
mountPath: /etc/openshell-tls/vault
186+
mountPath: /etc/openshell-tls/vault-ca
135187
readOnly: true
136188
{{- end }}
137189
{{- if .Values.upstreamProxy.caBundle.configMapName }}
@@ -192,6 +244,14 @@ spec:
192244
secret:
193245
secretName: {{ include "openshell.sandboxJwtSecretName" . }}
194246
defaultMode: {{ .Values.server.sandboxJwt.secretDefaultMode | default 0400 }}
247+
- name: gateway-peer-token
248+
projected:
249+
defaultMode: 0400
250+
sources:
251+
- serviceAccountToken:
252+
path: token
253+
audience: openshell-gateway-peer
254+
expirationSeconds: 3600
195255
{{- if not .Values.server.disableTls }}
196256
- name: tls-cert
197257
secret:
@@ -202,6 +262,9 @@ spec:
202262
secretName: {{ include "openshell.fullname" . }}-server-external-tls
203263
{{- end }}
204264
{{- if eq (include "openshell.gatewayClientCaEnabled" .) "true" }}
265+
- name: peer-client-tls
266+
secret:
267+
secretName: {{ .Values.server.tls.clientTlsSecretName }}
205268
- name: tls-client-ca
206269
secret:
207270
{{- if or (and .Values.pkiInitJob.enabled (not .Values.certManager.enabled)) (and .Values.certManager.enabled .Values.certManager.clientCaFromServerTlsSecret) }}
@@ -214,10 +277,10 @@ spec:
214277
{{- end }}
215278
{{- end }}
216279
{{- end }}
217-
{{- if and (get $oidcRuntimeConfig "issuer") .Values.oidc.caConfigMapName }}
280+
{{- if and (get $oidcRuntimeConfig "issuer") .Values.server.oidc.caConfigMapName }}
218281
- name: oidc-ca
219282
configMap:
220-
name: {{ .Values.oidc.caConfigMapName }}
283+
name: {{ .Values.server.oidc.caConfigMapName }}
221284
{{- end }}
222285
{{- if and $vaultCredentialDriverEnabled $vaultCaConfigMapName }}
223286
- name: vault-ca

0 commit comments

Comments
 (0)