From 8edaf9fa31068efc40fb4a4c118467be3b81e647 Mon Sep 17 00:00:00 2001 From: Rahul Khiyani Date: Fri, 22 Mar 2019 16:28:45 -0400 Subject: [PATCH] Registry: Add pod/container security context This updates the registry chart to include the pod security context on the pod template This also adds the container security context Change-Id: I36b6a2cf291dda2f991843c07ba116f3bf936d03 --- registry/templates/daemonset-registry-proxy.yaml | 2 ++ registry/templates/deployment-registry.yaml | 2 ++ registry/values.yaml | 15 +++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/registry/templates/daemonset-registry-proxy.yaml b/registry/templates/daemonset-registry-proxy.yaml index 4b1342a7c..7a3c972f6 100644 --- a/registry/templates/daemonset-registry-proxy.yaml +++ b/registry/templates/daemonset-registry-proxy.yaml @@ -41,6 +41,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }} spec: +{{ dict "envAll" $envAll "application" "registry_proxy" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} serviceAccountName: {{ $serviceAccountName }} nodeSelector: {{ .Values.labels.registry.node_selector_key }}: {{ .Values.labels.registry.node_selector_value | quote }} @@ -52,6 +53,7 @@ spec: - name: registry-proxy {{ tuple $envAll "registry_proxy" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.registry_proxy | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} +{{ dict "envAll" $envAll "application" "registry_proxy" "container" "registry_proxy" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} command: - /tmp/registry-proxy.sh volumeMounts: diff --git a/registry/templates/deployment-registry.yaml b/registry/templates/deployment-registry.yaml index e8642a214..cddc25fae 100644 --- a/registry/templates/deployment-registry.yaml +++ b/registry/templates/deployment-registry.yaml @@ -43,6 +43,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }} spec: +{{ dict "envAll" $envAll "application" "registry" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} serviceAccountName: {{ $serviceAccountName }} affinity: {{ tuple $envAll "docker" "registry" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }} @@ -54,6 +55,7 @@ spec: - name: registry {{ tuple $envAll "registry" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.registry | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} +{{ dict "envAll" $envAll "application" "registry" "container" "registry" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} ports: - name: d-reg containerPort: {{ tuple "docker_registry" "internal" "registry" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} diff --git a/registry/values.yaml b/registry/values.yaml index 4a3738d77..04bad17cc 100644 --- a/registry/values.yaml +++ b/registry/values.yaml @@ -75,6 +75,21 @@ conf: addr: null pod: + security_context: + registry_proxy: + pod: + runAsUser: 65534 + container: + registry_proxy: + runAsUser: 0 + readOnlyRootFilesystem: false + registry: + pod: + runAsUser: 65534 + container: + registry: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true affinity: anti: type: