Skip to content

Commit

Permalink
Added the security context at pod and container level for kainster op…
Browse files Browse the repository at this point in the history
…erator

Signed-off-by: Anish Bista <[email protected]>
  • Loading branch information
anishbista60 committed Aug 29, 2024
1 parent 195bb1b commit 6836d0d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions helm/kanister-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ spec:
labels:
{{ include "kanister-operator.helmLabels" . | indent 8}}
spec:
{{- if .Values.podSecurityContext }}
securityContext: {{ toYaml .Values.podSecurityContext | indent 8 }}
{{- end }}
serviceAccountName: {{ template "kanister-operator.serviceAccountName" . }}
{{- if or .Values.bpValidatingWebhook.enabled .Values.validatingWebhook.repositoryserver.enabled }}
volumes:
Expand All @@ -29,6 +32,9 @@ spec:
- name: {{ template "kanister-operator.fullname" . }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.containerSecurityContext }}
securityContext: {{ toYaml .Values.containerSecurityContext | indent 12 }}
{{- end }}
{{- if .Values.bpValidatingWebhook.enabled }}
volumeMounts:
- name: webhook-certs
Expand All @@ -53,6 +59,9 @@ spec:
- name: {{ template "repository-server-controller.name" . }}
image: {{ .Values.repositoryServerControllerImage.registry }}/{{ .Values.repositoryServerControllerImage.name }}:{{ .Values.repositoryServerControllerImage.tag }}
imagePullPolicy: {{ .Values.repositoryServerControllerImage.pullPolicy }}
{{- if .Values.containerSecurityContext }}
securityContext: {{ toYaml .Values.containerSecurityContext | indent 12 }}
{{- end }}
{{- if .Values.validatingWebhook.repositoryserver.enabled }}
volumeMounts:
- name: webhook-certs
Expand Down
19 changes: 19 additions & 0 deletions helm/kanister-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,22 @@ tolerations: []
#
# node labels for pod assignment. Evaluated as template
nodeSelector: {}

# Pod-level security context settings
podSecurityContext:
runAsUser: 1000
fsGroup: 2000
runAsNonRoot: true
# SELinux options can be specified here if required
# seLinuxOptions:
# level: "s0:c123,c456"

# Container-level security context settings
containerSecurityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
# AllowPrivilegeEscalation should be disabled for security
allowPrivilegeEscalation: false

0 comments on commit 6836d0d

Please sign in to comment.