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

fix(base-cluster/backup): make velero compliant with kyverno security policies where possible #610

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
33 changes: 24 additions & 9 deletions charts/base-cluster/templates/backup/velero.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,41 @@ spec:
volumeMounts:
- mountPath: /target
name: plugins
securityContext: &containerSecurityContext
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
seccompProfile:
type: RuntimeDefault
podSecurityContext:
fsGroup: 1000
runAsUser: 1000
runAsGroup: 1000
runAsNonRoot: true
containerSecurityContext:
readOnlyRootFilesystem: true
privileged: false
capabilities:
drop:
- ALL
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
containerSecurityContext: *containerSecurityContext
resources: {{- .Values.backup.resources | toYaml | nindent 6 }}
priorityClassName: system-cluster-critical
deployNodeAgent: true # enable FSB
nodeAgent:
resources: {{- .Values.backup.nodeAgent.resources | toYaml | nindent 8 }}
priorityClassName: system-cluster-critical
privileged: false
podSecurityContext:
fsGroup: 1337
containerSecurityContext:
<<: *containerSecurityContext
capabilities:
add:
- NET_BIND_SERVICE # needed until https://github.com/vmware-tanzu/velero/pull/6784 gets released
extraVolumes:
- name: tmp
emptyDir: {}
extraVolumeMounts:
- name: tmp
mountPath: /tmp
configuration:
{{- if .Values.backup.backupStorageLocations }}
backupStorageLocation: {{- range $name, $spec := .Values.backup.backupStorageLocations }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ spec:
- kube-system
- default
{{ $lokiPromtail := dict "resources" (dict "namespaces" (list "loki") "kinds" (list "Pod") "names" (list "loki-promtail-*")) -}}
{{- $syncEtcdSecret := dict "resources" (dict "namespaces" (list "monitoring") "kinds" (list "Pod") "names" (list "sync-etcd-secret-*")) -}}
{{- $nodeExporter := dict "resources" (dict "namespaces" (list "monitoring") "kinds" (list "Pod") "names" (list "kube-prometheus-stack-prometheus-node-exporter-*")) -}}
{{- $nfsServerProvisioner := dict "resources" (dict "namespaces" (list "nfs-server-provisioner") "kinds" (list "Pod") "names" (list "nfs-server-provisioner-0")) -}}
{{- $veleroNodeAgent := dict "resources" (dict "namespaces" (list "backup") "kinds" (list "Pod") "names" (list "node-agent-*")) -}}

{{- $disallowHostPath := list -}}
{{- $runAsNonRoot := list -}}
Expand All @@ -48,18 +48,20 @@ spec:
{{- $runAsNonRoot = append $runAsNonRoot $lokiPromtail -}}
{{- end -}}
{{- if .Values.monitoring.prometheus.enabled -}}
{{- $disallowHostPath = append $disallowHostPath $syncEtcdSecret -}}
{{- $disallowHostPath = append $disallowHostPath $nodeExporter -}}
{{- $disallowHostPorts = append $disallowHostPorts $nodeExporter -}}
{{- $disallowHostNamespaces = append $disallowHostNamespaces $nodeExporter -}}
{{- $runAsNonRoot = append $runAsNonRoot $syncEtcdSecret -}}
{{- end -}}
{{- if .Values.storage.readWriteMany.enabled -}}
{{- $restrictSeccomp = append $restrictSeccomp $nfsServerProvisioner -}}
{{- $runAsNonRoot = append $runAsNonRoot $nfsServerProvisioner -}}
{{- $disallowPrivilegeEscalation = append $disallowPrivilegeEscalation $nfsServerProvisioner -}}
{{- $disallowCapabilities = append $disallowCapabilities $nfsServerProvisioner -}}
{{- end -}}
{{- if .Values.backup.enabled }}
{{- $disallowHostPath = append $disallowHostPath $veleroNodeAgent -}}
{{- $runAsNonRoot = append $runAsNonRoot $veleroNodeAgent -}}
{{- end }}
policyExclude:
{{- if $disallowHostPath }}
disallow-host-path:
Expand Down