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 containerSecurityContext to components #1304

Closed
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
15 changes: 14 additions & 1 deletion README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions templates/chartmuseum/chartmuseum-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
securityContext:
runAsUser: 10000
fsGroup: 10000
runAsNonRoot: true
{{- if .Values.chartmuseum.serviceAccountName }}
serviceAccountName: {{ .Values.chartmuseum.serviceAccountName }}
{{- end -}}
Expand Down Expand Up @@ -141,6 +142,10 @@ spec:
{{- if .Values.caBundleSecretName }}
{{ include "harbor.caBundleVolumeMount" . | indent 8 }}
{{- end }}
{{- with .Values.chartmuseum.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: chartmuseum-data
{{- if and .Values.persistence.enabled (eq .Values.persistence.imageChartStorage.type "filesystem") }}
Expand Down
5 changes: 5 additions & 0 deletions templates/core/core-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ spec:
securityContext:
runAsUser: 10000
fsGroup: 10000
runAsNonRoot: true
{{- if .Values.core.serviceAccountName }}
serviceAccountName: {{ .Values.core.serviceAccountName }}
{{- end -}}
Expand Down Expand Up @@ -144,6 +145,10 @@ spec:
resources:
{{ toYaml .Values.core.resources | indent 10 }}
{{- end }}
{{- with .Values.core.containerSecurityContext }}
securityContext:
{{ toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: config
configMap:
Expand Down
13 changes: 13 additions & 0 deletions templates/database/database-ss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
securityContext:
runAsUser: 999
fsGroup: 999
runAsNonRoot: true
{{- if .Values.database.internal.serviceAccountName }}
serviceAccountName: {{ .Values.database.internal.serviceAccountName }}
{{- end -}}
Expand All @@ -51,6 +52,10 @@ spec:
resources:
{{ toYaml .Values.database.internal.initContainer.migrator.resources | indent 10 }}
{{- end }}
{{- with .Values.database.internal.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumeMounts:
- name: database-data
mountPath: /var/lib/postgresql/data
Expand All @@ -68,6 +73,10 @@ spec:
resources:
{{ toYaml .Values.database.internal.initContainer.permissions.resources | indent 10 }}
{{- end }}
{{- with .Values.database.internal.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumeMounts:
- name: database-data
mountPath: /var/lib/postgresql/data
Expand Down Expand Up @@ -106,6 +115,10 @@ spec:
subPath: {{ $database.subPath }}
- name: shm-volume
mountPath: /dev/shm
{{- with .Values.database.internal.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: shm-volume
emptyDir:
Expand Down
5 changes: 5 additions & 0 deletions templates/exporter/exporter-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
securityContext:
runAsUser: 10000
fsGroup: 10000
runAsNonRoot: true
{{- if .Values.exporter.serviceAccountName }}
serviceAccountName: {{ .Values.exporter.serviceAccountName }}
{{- end -}}
Expand Down Expand Up @@ -80,6 +81,10 @@ spec:
# There are some metric data are collectd from harbor core.
# When internal TLS is enabled, the Exporter need the CA file to collect these data.
{{- end }}
{{- with .Values.exporter.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: config
secret:
Expand Down
2 changes: 1 addition & 1 deletion templates/exporter/exporter-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
{{ include "harbor.labels" . | indent 4 }}
spec:
ports:
- name: {{ template "harbor.metricsPortName" . }}
- name: metrics
port: {{ .Values.metrics.exporter.port }}
selector:
{{ include "harbor.matchLabels" . | indent 4 }}
Expand Down
5 changes: 5 additions & 0 deletions templates/jobservice/jobservice-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ spec:
securityContext:
runAsUser: 10000
fsGroup: 10000
runAsNonRoot: true
{{- if .Values.jobservice.serviceAccountName }}
serviceAccountName: {{ .Values.jobservice.serviceAccountName }}
{{- end -}}
Expand Down Expand Up @@ -117,6 +118,10 @@ spec:
{{- if .Values.caBundleSecretName }}
{{ include "harbor.caBundleVolumeMount" . | indent 8 }}
{{- end }}
{{- with .Values.jobservice.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: jobservice-config
configMap:
Expand Down
5 changes: 5 additions & 0 deletions templates/nginx/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ spec:
securityContext:
runAsUser: 10000
fsGroup: 10000
runAsNonRoot: true
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
Expand Down Expand Up @@ -82,6 +83,10 @@ spec:
- name: certificate
mountPath: /etc/nginx/cert
{{- end }}
{{- with .Values.nginx.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: config
configMap:
Expand Down
5 changes: 5 additions & 0 deletions templates/notary/notary-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
securityContext:
runAsUser: 10000
fsGroup: 10000
runAsNonRoot: true
{{- if .Values.notary.server.serviceAccountName }}
serviceAccountName: {{ .Values.notary.server.serviceAccountName }}
{{- end -}}
Expand Down Expand Up @@ -75,6 +76,10 @@ spec:
- name: signer-certificate
mountPath: /etc/ssl/notary/ca.crt
subPath: ca.crt
{{- with .Values.notary.server.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: config
secret:
Expand Down
5 changes: 5 additions & 0 deletions templates/notary/notary-signer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
securityContext:
runAsUser: 10000
fsGroup: 10000
runAsNonRoot: true
{{- if .Values.notary.signer.serviceAccountName }}
serviceAccountName: {{ .Values.notary.signer.serviceAccountName }}
{{- end -}}
Expand Down Expand Up @@ -76,6 +77,10 @@ spec:
- name: signer-certificate
mountPath: /etc/ssl/notary/tls.key
subPath: tls.key
{{- with .Values.notary.signer.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: config
secret:
Expand Down
5 changes: 5 additions & 0 deletions templates/portal/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
securityContext:
runAsUser: 10000
fsGroup: 10000
runAsNonRoot: true
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
Expand Down Expand Up @@ -70,6 +71,10 @@ spec:
- name: portal-internal-certs
mountPath: /etc/harbor/ssl/portal
{{- end }}
{{- with .Values.portal.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: portal-config
configMap:
Expand Down
5 changes: 5 additions & 0 deletions templates/redis/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
securityContext:
runAsUser: 999
fsGroup: 999
runAsNonRoot: true
{{- if .Values.redis.internal.serviceAccountName }}
serviceAccountName: {{ .Values.redis.internal.serviceAccountName }}
{{- end -}}
Expand Down Expand Up @@ -58,6 +59,10 @@ spec:
- name: data
mountPath: /var/lib/redis
subPath: {{ $redis.subPath }}
{{- with .Values.redis.internal.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- if not .Values.persistence.enabled }}
volumes:
- name: data
Expand Down
9 changes: 9 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:
runAsUser: 10000
fsGroup: 10000
fsGroupChangePolicy: OnRootMismatch
runAsNonRoot: true
{{- if .Values.registry.serviceAccountName }}
serviceAccountName: {{ .Values.registry.serviceAccountName }}
{{- end -}}
Expand Down Expand Up @@ -137,6 +138,10 @@ spec:
{{- if .Values.caBundleSecretName }}
{{ include "harbor.caBundleVolumeMount" . | indent 8 }}
{{- end }}
{{- with .Values.registry.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
- name: registryctl
image: {{ .Values.registry.controller.image.repository }}:{{ .Values.registry.controller.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
Expand Down Expand Up @@ -237,6 +242,10 @@ spec:
{{- if .Values.caBundleSecretName }}
{{ include "harbor.caBundleVolumeMount" . | indent 8 }}
{{- end }}
{{- with .Values.registry.controller.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
- name: registry-htpasswd
secret:
Expand Down
2 changes: 1 addition & 1 deletion templates/registry/registry-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
{{ include "harbor.labels" . | indent 4 }}
spec:
ports:
- name: {{ ternary "https-registry" "http-registry" .Values.internalTLS.enabled }}
- name: registry
port: {{ template "harbor.registry.servicePort" . }}

- name: {{ ternary "https-controller" "http-controller" .Values.internalTLS.enabled }}
Expand Down
8 changes: 5 additions & 3 deletions templates/trivy/trivy-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ spec:
securityContext:
runAsUser: 10000
fsGroup: 10000
runAsNonRoot: true
automountServiceAccountToken: {{ .Values.trivy.automountServiceAccountToken | default false }}
containers:
- name: trivy
image: {{ .Values.trivy.image.repository }}:{{ .Values.trivy.image.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
{{- with .Values.trivy.containerSecurityContext }}
securityContext:
privileged: false
allowPrivilegeEscalation: false
{{- toYaml . | nindent 12 }}
{{- end }}
env:
{{- if has "trivy" .Values.proxy.components }}
- name: HTTP_PROXY
Expand Down Expand Up @@ -144,7 +146,7 @@ spec:
failureThreshold: 3
resources:
{{ toYaml .Values.trivy.resources | indent 12 }}
{{- if or (or .Values.internalTLS.enabled .Values.caBundleSecretName) (or (not .Values.persistence.enabled) $trivy.existingClaim) }}
{{- if or (or .Values.internalTLS.enabled .Values.caBundleSecretName) (or (not .Values.persistence.enabled) $trivy.existingClaim) }}
volumes:
{{- if .Values.internalTLS.enabled }}
- name: trivy-internal-certs
Expand Down
Loading