diff --git a/deploy/helm/openshell/templates/_gateway-workload.tpl b/deploy/helm/openshell/templates/_gateway-workload.tpl index a73acc9810..1158c26d7d 100644 --- a/deploy/helm/openshell/templates/_gateway-workload.tpl +++ b/deploy/helm/openshell/templates/_gateway-workload.tpl @@ -34,8 +34,10 @@ spec: - host.docker.internal - host.openshell.internal {{- end }} + {{- with .Values.podSecurityContext }} securityContext: - {{- toYaml .Values.podSecurityContext | nindent 4 }} + {{- toYaml . | nindent 4 }} + {{- end }} containers: - name: openshell-gateway securityContext: diff --git a/deploy/helm/openshell/tests/gateway_pod_security_context_test.yaml b/deploy/helm/openshell/tests/gateway_pod_security_context_test.yaml new file mode 100644 index 0000000000..cdb70a05eb --- /dev/null +++ b/deploy/helm/openshell/tests/gateway_pod_security_context_test.yaml @@ -0,0 +1,36 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +suite: gateway pod securityContext +templates: + - templates/gateway-config.yaml + - templates/statefulset.yaml +release: + name: openshell + namespace: my-namespace + +tests: + - it: renders the pod securityContext from podSecurityContext by default + template: templates/statefulset.yaml + asserts: + - equal: + path: spec.template.spec.securityContext.fsGroup + value: 1000 + + - it: renders an explicitly set podSecurityContext + template: templates/statefulset.yaml + set: + podSecurityContext: + fsGroup: 2000 + asserts: + - equal: + path: spec.template.spec.securityContext.fsGroup + value: 2000 + + - it: omits the pod securityContext block when podSecurityContext is null + template: templates/statefulset.yaml + set: + podSecurityContext: null + asserts: + - notExists: + path: spec.template.spec.securityContext