Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add securityContext definitions on container level #1673

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions templates/core/core-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ spec:
{{- end }}
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10000
fsGroup: 10000
{{- if .Values.core.serviceAccountName }}
Expand All @@ -59,6 +60,14 @@ spec:
- name: core
image: {{ .Values.core.image.repository }}:{{ .Values.core.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
{{- if .Values.core.startupProbe.enabled }}
startupProbe:
httpGet:
Expand Down
9 changes: 9 additions & 0 deletions templates/core/core-pre-upgrade-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
spec:
restartPolicy: Never
securityContext:
runAsNonRoot: true
runAsUser: 10000
fsGroup: 10000
{{- if .Values.core.serviceAccountName }}
Expand All @@ -34,6 +35,14 @@ spec:
- name: core-job
image: {{ .Values.core.image.repository }}:{{ .Values.core.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
command: ["/harbor/harbor_core", "-mode=migrate"]
envFrom:
- configMapRef:
Expand Down
25 changes: 25 additions & 0 deletions templates/database/database-ss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
{{- end }}
spec:
securityContext:
runAsNonRoot: true
runAsUser: 999
fsGroup: 999
{{- if .Values.database.internal.serviceAccountName }}
Expand All @@ -48,6 +49,14 @@ spec:
- name: "data-migrator"
image: {{ .Values.database.internal.image.repository }}:{{ .Values.database.internal.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
command: ["/bin/sh"]
args: ["-c", "[ -e /var/lib/postgresql/data/postgresql.conf ] && [ ! -d /var/lib/postgresql/data/pgdata ] && mkdir -m 0700 /var/lib/postgresql/data/pgdata && mv /var/lib/postgresql/data/* /var/lib/postgresql/data/pgdata/ || true"]
{{- if .Values.database.internal.initContainer.migrator.resources }}
Expand All @@ -65,6 +74,14 @@ spec:
- name: "data-permissions-ensurer"
image: {{ .Values.database.internal.image.repository }}:{{ .Values.database.internal.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
command: ["/bin/sh"]
args: ["-c", "chmod -R 700 /var/lib/postgresql/data/pgdata || true"]
{{- if .Values.database.internal.initContainer.permissions.resources }}
Expand All @@ -79,6 +96,14 @@ spec:
- name: database
image: {{ .Values.database.internal.image.repository }}:{{ .Values.database.internal.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
livenessProbe:
exec:
command:
Expand Down
9 changes: 9 additions & 0 deletions templates/exporter/exporter-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spec:
{{- end }}
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10000
fsGroup: 10000
{{- if .Values.exporter.serviceAccountName }}
Expand All @@ -56,6 +57,14 @@ spec:
- name: exporter
image: {{ .Values.exporter.image.repository }}:{{ .Values.exporter.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
livenessProbe:
httpGet:
path: /
Expand Down
9 changes: 9 additions & 0 deletions templates/jobservice/jobservice-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ spec:
{{- end }}
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10000
fsGroup: 10000
{{- if .Values.jobservice.serviceAccountName }}
Expand All @@ -65,6 +66,14 @@ spec:
- name: jobservice
image: {{ .Values.jobservice.image.repository }}:{{ .Values.jobservice.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
livenessProbe:
httpGet:
path: /api/v1/stats
Expand Down
9 changes: 9 additions & 0 deletions templates/nginx/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ spec:
serviceAccountName: {{ .Values.nginx.serviceAccountName }}
{{- end }}
securityContext:
runAsNonRoot: true
runAsUser: 10000
fsGroup: 10000
{{- with .Values.imagePullSecrets }}
Expand All @@ -59,6 +60,14 @@ spec:
- name: nginx
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag }}"
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
{{- $_ := set . "scheme" "HTTP" -}}
{{- $_ := set . "port" "8080" -}}
{{- if .Values.expose.tls.enabled }}
Expand Down
9 changes: 9 additions & 0 deletions templates/portal/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spec:
{{- end }}
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10000
fsGroup: 10000
{{- with .Values.imagePullSecrets }}
Expand All @@ -56,6 +57,14 @@ spec:
- name: portal
image: {{ .Values.portal.image.repository }}:{{ .Values.portal.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
{{- if .Values.portal.resources }}
resources:
{{ toYaml .Values.portal.resources | indent 10 }}
Expand Down
17 changes: 17 additions & 0 deletions templates/registry/registry-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
{{- end }}
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10000
fsGroup: 10000
fsGroupChangePolicy: OnRootMismatch
Expand All @@ -68,6 +69,14 @@ spec:
- name: registry
image: {{ .Values.registry.registry.image.repository }}:{{ .Values.registry.registry.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
livenessProbe:
httpGet:
path: /
Expand Down Expand Up @@ -204,6 +213,14 @@ spec:
- name: registryctl
image: {{ .Values.registry.controller.image.repository }}:{{ .Values.registry.controller.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
livenessProbe:
httpGet:
path: /api/health
Expand Down
6 changes: 6 additions & 0 deletions templates/trivy/trivy-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
serviceAccountName: {{ .Values.trivy.serviceAccountName }}
{{- end }}
securityContext:
runAsNonRoot: true
runAsUser: 10000
fsGroup: 10000
automountServiceAccountToken: {{ .Values.trivy.automountServiceAccountToken | default false }}
Expand All @@ -61,6 +62,11 @@ spec:
securityContext:
privileged: false
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
env:
{{- if has "trivy" .Values.proxy.components }}
- name: HTTP_PROXY
Expand Down
Loading