From ed0a77828116725e1848b13d2c0321e3c2f98269 Mon Sep 17 00:00:00 2001 From: erikfuego Date: Mon, 4 Mar 2024 12:36:40 -0500 Subject: [PATCH] Add missing fields for Security context and secrets --- templates/cronjob.yaml | 7 ++++--- templates/deployment.yaml | 7 ++++--- values.yaml | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/templates/cronjob.yaml b/templates/cronjob.yaml index 3a04680..80b18d5 100644 --- a/templates/cronjob.yaml +++ b/templates/cronjob.yaml @@ -38,9 +38,7 @@ spec: priorityClassName: "{{ .Values.priorityClassName }}" {{- end }} {{- if .Values.securityContext.enabled }} - securityContext: - fsGroup: {{ .Values.securityContext.fsGroup }} - runAsUser: {{ .Values.securityContext.runAsUser }} + securityContext: {{ omit .Values.securityContext "enabled" | toYaml | nindent 12 }} {{- end }} containers: - name: {{ .Chart.Name }} @@ -52,6 +50,9 @@ spec: - --delete-untagged={{ .Values.garbageCollect.deleteUntagged }} - /etc/docker/registry/config.yml env: {{ include "docker-registry.envs" . | nindent 16 }} + {{- if .Values.containerSecurityContext.enabled }} + securityContext: {{ omit .Values.containerSecurityContext "enabled" | toYaml | nindent 16 }} + {{- end }} volumeMounts: {{ include "docker-registry.volumeMounts" . | nindent 16 }} restartPolicy: OnFailure {{- if .Values.nodeSelector }} diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 6d2ff0e..55d4b42 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -43,9 +43,7 @@ spec: priorityClassName: "{{ .Values.priorityClassName }}" {{- end }} {{- if .Values.securityContext.enabled }} - securityContext: - fsGroup: {{ .Values.securityContext.fsGroup }} - runAsUser: {{ .Values.securityContext.runAsUser }} + securityContext: {{ omit .Values.securityContext "enabled" | toYaml | nindent 8 }} {{- end }} {{- with .Values.initContainers }} initContainers: @@ -82,6 +80,9 @@ spec: port: 5000 resources: {{ toYaml .Values.resources | nindent 12 }} env: {{ include "docker-registry.envs" . | nindent 12 }} + {{- if .Values.containerSecurityContext.enabled }} + securityContext: {{ omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} volumeMounts: {{ include "docker-registry.volumeMounts" . | nindent 12 }} {{- if .Values.nodeSelector }} nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }} diff --git a/values.yaml b/values.yaml index 7f9c558..1d877cc 100644 --- a/values.yaml +++ b/values.yaml @@ -152,6 +152,9 @@ configData: interval: 10s threshold: 3 +containerSecurityContext: + enabled: false + securityContext: enabled: true runAsUser: 1000