ceph-osd: Fix security context

This PS fixes the use of the security context macros for the
ceph-osd chart

Change-Id: I75cb057d08831fb39e9846fbab53e3ee6e113ada
This commit is contained in:
RAHUL KHIYANI 2019-04-23 23:00:41 -05:00 committed by Pete Birley
parent 0ed4f0de5e
commit a881f3def4
4 changed files with 36 additions and 6 deletions

View File

@ -43,6 +43,7 @@ spec:
{{ dict "envAll" $envAll "podName" "ceph-osd-default" "containerNames" (list "ceph-osd-default") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }} {{ dict "envAll" $envAll "podName" "ceph-osd-default" "containerNames" (list "ceph-osd-default") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }}
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }} {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }}
spec: spec:
{{ dict "envAll" $envAll "application" "osd" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }}
serviceAccountName: {{ $serviceAccountName }} serviceAccountName: {{ $serviceAccountName }}
nodeSelector: nodeSelector:
{{ .Values.labels.osd.node_selector_key }}: {{ .Values.labels.osd.node_selector_value }} {{ .Values.labels.osd.node_selector_key }}: {{ .Values.labels.osd.node_selector_value }}
@ -53,6 +54,7 @@ spec:
{{ tuple $envAll "osd" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} {{ tuple $envAll "osd" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
- name: ceph-init-dirs - name: ceph-init-dirs
{{ tuple $envAll "ceph_osd" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll "ceph_osd" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ dict "envAll" $envAll "application" "osd" "container" "ceph_init_dirs" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
command: command:
- /tmp/init-dirs.sh - /tmp/init-dirs.sh
env: env:
@ -102,8 +104,7 @@ spec:
readOnly: false readOnly: false
- name: ceph-log-ownership - name: ceph-log-ownership
{{ tuple $envAll "ceph_osd" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll "ceph_osd" | include "helm-toolkit.snippets.image" | indent 10 }}
securityContext: {{ dict "envAll" $envAll "application" "osd" "container" "ceph_log_ownership" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
runAsUser: 0
env: env:
# NOTE(portdirect): These environment variables will be populated # NOTE(portdirect): These environment variables will be populated
# dynamicly at the point of render and added to all containers in the # dynamicly at the point of render and added to all containers in the
@ -138,8 +139,7 @@ spec:
- name: osd-init - name: osd-init
{{ tuple $envAll "ceph_osd" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll "ceph_osd" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ tuple $envAll $envAll.Values.pod.resources.osd | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.osd | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
securityContext: {{ dict "envAll" $envAll "application" "osd" "container" "osd_init" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
privileged: true
env: env:
# NOTE(portdirect): These environment variables will be populated # NOTE(portdirect): These environment variables will be populated
# dynamicly at the point of render and added to all containers in the # dynamicly at the point of render and added to all containers in the
@ -214,8 +214,7 @@ spec:
- name: osd-pod - name: osd-pod
{{ tuple $envAll "ceph_osd" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll "ceph_osd" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ tuple $envAll $envAll.Values.pod.resources.osd | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.osd | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
securityContext: {{ dict "envAll" $envAll "application" "osd" "container" "osd_pod" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
privileged: true
env: env:
# NOTE(portdirect): These environment variables will be populated # NOTE(portdirect): These environment variables will be populated
# dynamicly at the point of render. # dynamicly at the point of render.

View File

@ -32,6 +32,7 @@ spec:
labels: labels:
{{ tuple $envAll "ceph" "bootstrap" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} {{ tuple $envAll "ceph" "bootstrap" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec: spec:
{{ dict "envAll" $envAll "application" "bootstrap" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }}
serviceAccountName: {{ $serviceAccountName }} serviceAccountName: {{ $serviceAccountName }}
restartPolicy: OnFailure restartPolicy: OnFailure
nodeSelector: nodeSelector:
@ -42,6 +43,7 @@ spec:
- name: ceph-osd-bootstrap - name: ceph-osd-bootstrap
{{ tuple $envAll "ceph_bootstrap" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll "ceph_bootstrap" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ tuple $envAll $envAll.Values.pod.resources.jobs.bootstrap | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.jobs.bootstrap | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
{{ dict "envAll" $envAll "application" "bootstrap" "container" "ceph_osd_bootstrap" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
command: command:
- /tmp/bootstrap.sh - /tmp/bootstrap.sh
volumeMounts: volumeMounts:

View File

@ -29,6 +29,7 @@ metadata:
annotations: annotations:
"helm.sh/hook": test-success "helm.sh/hook": test-success
spec: spec:
{{ dict "envAll" $envAll "application" "test" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 2 }}
restartPolicy: Never restartPolicy: Never
serviceAccountName: {{ $serviceAccountName }} serviceAccountName: {{ $serviceAccountName }}
initContainers: initContainers:
@ -37,6 +38,7 @@ spec:
- name: ceph-cluster-helm-test - name: ceph-cluster-helm-test
{{ tuple $envAll "ceph_config_helper" | include "helm-toolkit.snippets.image" | indent 6 }} {{ tuple $envAll "ceph_config_helper" | include "helm-toolkit.snippets.image" | indent 6 }}
{{ tuple $envAll $envAll.Values.pod.resources.jobs.tests | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }} {{ tuple $envAll $envAll.Values.pod.resources.jobs.tests | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }}
{{ dict "envAll" $envAll "application" "test" "container" "ceph_cluster_helm_test" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 6 }}
env: env:
- name: CEPH_DEPLOYMENT_NAMESPACE - name: CEPH_DEPLOYMENT_NAMESPACE
value: {{ .Release.Namespace }} value: {{ .Release.Namespace }}

View File

@ -40,6 +40,33 @@ labels:
node_selector_value: enabled node_selector_value: enabled
pod: pod:
security_context:
osd:
pod:
runAsUser: 0
container:
ceph_init_dirs:
readOnlyRootFilesystem: true
ceph_log_ownership:
readOnlyRootFilesystem: true
osd_init:
privileged: true
readOnlyRootFilesystem: true
osd_pod:
privileged: true
readOnlyRootFilesystem: false
bootstrap:
pod:
runAsUser: 0
container:
ceph_osd_bootstrap:
readOnlyRootFilesystem: true
test:
pod:
runAsUser: 0
container:
ceph_cluster_helm_test:
readOnlyRootFilesystem: true
dns_policy: "ClusterFirstWithHostNet" dns_policy: "ClusterFirstWithHostNet"
affinity: affinity:
anti: anti: