diff --git a/resources/nats/templates/statefulset.yaml b/resources/nats/templates/statefulset.yaml index 9d5e4bd2..6fd2c449 100644 --- a/resources/nats/templates/statefulset.yaml +++ b/resources/nats/templates/statefulset.yaml @@ -94,6 +94,15 @@ spec: # reload to the server without restarting the pod. shareProcessNamespace: true + initContainers: + - name: change-storage-permissions + securityContext: + runAsUser: 0 + image: alpine:latest + command: ["sh", "-c", "chown -R 1000:10001 {{ .Values.nats.jetstream.fileStorage.storageDirectory }} && chmod -R 755 {{ .Values.nats.jetstream.fileStorage.storageDirectory }} && echo 'Done!'"] + volumeMounts: + - name: {{ include "nats.fullname" . }}-js-pvc + mountPath: {{ .Values.nats.jetstream.fileStorage.storageDirectory }} ################# # # # NATS Server # diff --git a/resources/nats/values.yaml b/resources/nats/values.yaml index 65b98d32..a246139d 100644 --- a/resources/nats/values.yaml +++ b/resources/nats/values.yaml @@ -38,6 +38,7 @@ global: # # #################################### podSecurityContext: + runAsUser: 1000 fsGroup: 10001 seccompProfile: type: RuntimeDefault