|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +{{/* |
| 5 | +Gateway pod template shared by the StatefulSet and Deployment workload shapes. |
| 6 | +*/}} |
| 7 | +{{- define "openshell.gatewayPodTemplate" -}} |
| 8 | +metadata: |
| 9 | + annotations: |
| 10 | + # Roll the gateway workload when the rendered gateway TOML changes - the |
| 11 | + # gateway only reads /etc/openshell/gateway.toml at startup, so without |
| 12 | + # this annotation a `helm upgrade` that only mutates the ConfigMap would |
| 13 | + # leave pods running with stale config. |
| 14 | + checksum/gateway-config: {{ include (print $.Template.BasePath "/gateway-config.yaml") . | sha256sum }} |
| 15 | + {{- with .Values.podAnnotations }} |
| 16 | + {{- toYaml . | nindent 4 }} |
| 17 | + {{- end }} |
| 18 | + labels: |
| 19 | + {{- include "openshell.labels" . | nindent 4 }} |
| 20 | + {{- with .Values.podLabels }} |
| 21 | + {{- toYaml . | nindent 4 }} |
| 22 | + {{- end }} |
| 23 | +spec: |
| 24 | + terminationGracePeriodSeconds: {{ .Values.podLifecycle.terminationGracePeriodSeconds }} |
| 25 | + {{- with .Values.imagePullSecrets }} |
| 26 | + imagePullSecrets: |
| 27 | + {{- toYaml . | nindent 4 }} |
| 28 | + {{- end }} |
| 29 | + serviceAccountName: {{ include "openshell.serviceAccountName" . }} |
| 30 | + {{- if .Values.server.hostGatewayIP }} |
| 31 | + hostAliases: |
| 32 | + - ip: {{ .Values.server.hostGatewayIP | quote }} |
| 33 | + hostnames: |
| 34 | + - host.docker.internal |
| 35 | + - host.openshell.internal |
| 36 | + {{- end }} |
| 37 | + securityContext: |
| 38 | + {{- toYaml .Values.podSecurityContext | nindent 4 }} |
| 39 | + containers: |
| 40 | + - name: openshell-gateway |
| 41 | + securityContext: |
| 42 | + {{- toYaml .Values.securityContext | nindent 8 }} |
| 43 | + image: {{ include "openshell.image" . | quote }} |
| 44 | + imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 45 | + args: |
| 46 | + - --config |
| 47 | + - /etc/openshell/gateway.toml |
| 48 | + {{- if not .Values.server.externalDbSecret }} |
| 49 | + - --db-url |
| 50 | + - {{ .Values.server.dbUrl | quote }} |
| 51 | + {{- end }} |
| 52 | + env: |
| 53 | + {{- if .Values.server.externalDbSecret }} |
| 54 | + - name: OPENSHELL_DB_URL |
| 55 | + valueFrom: |
| 56 | + secretKeyRef: |
| 57 | + name: {{ .Values.server.externalDbSecret }} |
| 58 | + key: uri |
| 59 | + {{- end }} |
| 60 | + # All gateway settings live in the ConfigMap-backed TOML file |
| 61 | + # mounted at /etc/openshell/gateway.toml. The only env var below |
| 62 | + # is a process-level setting consumed by libraries outside |
| 63 | + # gateway code (currently just SSL_CERT_FILE for OIDC issuer TLS). |
| 64 | + {{- if and .Values.server.oidc.issuer .Values.server.oidc.caConfigMapName }} |
| 65 | + # OIDC issuer custom-CA: rustls/reqwest read SSL_CERT_FILE for |
| 66 | + # outbound TLS verification. This is a process-level env var |
| 67 | + # consumed by the TLS stack itself, not by gateway code, so it |
| 68 | + # cannot be represented in the gateway TOML schema. |
| 69 | + - name: SSL_CERT_FILE |
| 70 | + value: /etc/openshell-tls/oidc-ca/ca.crt |
| 71 | + {{- end }} |
| 72 | + volumeMounts: |
| 73 | + {{- if eq (include "openshell.workloadKind" .) "statefulset" }} |
| 74 | + - name: openshell-data |
| 75 | + mountPath: /var/openshell |
| 76 | + {{- end }} |
| 77 | + - name: gateway-config |
| 78 | + mountPath: /etc/openshell |
| 79 | + readOnly: true |
| 80 | + - name: sandbox-jwt |
| 81 | + mountPath: /etc/openshell-jwt |
| 82 | + readOnly: true |
| 83 | + {{- if not .Values.server.disableTls }} |
| 84 | + - name: tls-cert |
| 85 | + mountPath: /etc/openshell-tls/server |
| 86 | + readOnly: true |
| 87 | + {{- if or .Values.server.tls.clientCaSecretName (and .Values.pkiInitJob.enabled (not .Values.certManager.enabled)) (and .Values.certManager.enabled .Values.certManager.clientCaFromServerTlsSecret) }} |
| 88 | + - name: tls-client-ca |
| 89 | + mountPath: /etc/openshell-tls/client-ca |
| 90 | + readOnly: true |
| 91 | + {{- end }} |
| 92 | + {{- end }} |
| 93 | + {{- if and .Values.server.oidc.issuer .Values.server.oidc.caConfigMapName }} |
| 94 | + - name: oidc-ca |
| 95 | + mountPath: /etc/openshell-tls/oidc-ca |
| 96 | + readOnly: true |
| 97 | + {{- end }} |
| 98 | + ports: |
| 99 | + - name: grpc |
| 100 | + containerPort: {{ .Values.service.port }} |
| 101 | + protocol: TCP |
| 102 | + - name: health |
| 103 | + containerPort: {{ .Values.service.healthPort }} |
| 104 | + protocol: TCP |
| 105 | + {{- if .Values.service.metricsPort }} |
| 106 | + - name: metrics |
| 107 | + containerPort: {{ .Values.service.metricsPort }} |
| 108 | + protocol: TCP |
| 109 | + {{- end }} |
| 110 | + startupProbe: |
| 111 | + httpGet: |
| 112 | + path: /healthz |
| 113 | + port: health |
| 114 | + periodSeconds: {{ .Values.probes.startup.periodSeconds }} |
| 115 | + timeoutSeconds: {{ .Values.probes.startup.timeoutSeconds }} |
| 116 | + failureThreshold: {{ .Values.probes.startup.failureThreshold }} |
| 117 | + livenessProbe: |
| 118 | + httpGet: |
| 119 | + path: /healthz |
| 120 | + port: health |
| 121 | + initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }} |
| 122 | + periodSeconds: {{ .Values.probes.liveness.periodSeconds }} |
| 123 | + timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }} |
| 124 | + failureThreshold: {{ .Values.probes.liveness.failureThreshold }} |
| 125 | + readinessProbe: |
| 126 | + httpGet: |
| 127 | + path: /readyz |
| 128 | + port: health |
| 129 | + initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }} |
| 130 | + periodSeconds: {{ .Values.probes.readiness.periodSeconds }} |
| 131 | + timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }} |
| 132 | + failureThreshold: {{ .Values.probes.readiness.failureThreshold }} |
| 133 | + resources: |
| 134 | + {{- toYaml .Values.resources | nindent 8 }} |
| 135 | + volumes: |
| 136 | + - name: gateway-config |
| 137 | + configMap: |
| 138 | + name: {{ include "openshell.fullname" . }}-config |
| 139 | + - name: sandbox-jwt |
| 140 | + secret: |
| 141 | + secretName: {{ include "openshell.sandboxJwtSecretName" . }} |
| 142 | + defaultMode: {{ .Values.server.sandboxJwt.secretDefaultMode | default 0400 }} |
| 143 | + {{- if not .Values.server.disableTls }} |
| 144 | + - name: tls-cert |
| 145 | + secret: |
| 146 | + secretName: {{ .Values.server.tls.certSecretName }} |
| 147 | + {{- if or .Values.server.tls.clientCaSecretName (and .Values.pkiInitJob.enabled (not .Values.certManager.enabled)) (and .Values.certManager.enabled .Values.certManager.clientCaFromServerTlsSecret) }} |
| 148 | + - name: tls-client-ca |
| 149 | + secret: |
| 150 | + {{- if or (and .Values.pkiInitJob.enabled (not .Values.certManager.enabled)) (and .Values.certManager.enabled .Values.certManager.clientCaFromServerTlsSecret) }} |
| 151 | + secretName: {{ .Values.server.tls.certSecretName }} |
| 152 | + items: |
| 153 | + - key: ca.crt |
| 154 | + path: ca.crt |
| 155 | + {{- else }} |
| 156 | + secretName: {{ .Values.server.tls.clientCaSecretName }} |
| 157 | + {{- end }} |
| 158 | + {{- end }} |
| 159 | + {{- end }} |
| 160 | + {{- if and .Values.server.oidc.issuer .Values.server.oidc.caConfigMapName }} |
| 161 | + - name: oidc-ca |
| 162 | + configMap: |
| 163 | + name: {{ .Values.server.oidc.caConfigMapName }} |
| 164 | + {{- end }} |
| 165 | + {{- with .Values.nodeSelector }} |
| 166 | + nodeSelector: |
| 167 | + {{- toYaml . | nindent 4 }} |
| 168 | + {{- end }} |
| 169 | + {{- with .Values.affinity }} |
| 170 | + affinity: |
| 171 | + {{- toYaml . | nindent 4 }} |
| 172 | + {{- end }} |
| 173 | + {{- with .Values.tolerations }} |
| 174 | + tolerations: |
| 175 | + {{- toYaml . | nindent 4 }} |
| 176 | + {{- end }} |
| 177 | +{{- end }} |
0 commit comments