vmware-tanzu / velero

Backup and migrate Kubernetes applications and their persistent volumes
https://velero.io
Apache License 2.0
8.61k stars 1.39k forks source link

File system restore cannot work in PSA enabled Kubernetes cluster #8229

Open ywk253100 opened 1 week ago

ywk253100 commented 1 week ago

Got the following error:

time="2024-09-16T17:14:27Z" level=error msg="Namespace wordpress, resource restore error: error restoring pods/wordpress/wordpress-845697cddc-pcpqw: pods \"wordpress-845697cddc-pcpqw\" is forbidden: violates PodSecurity \"restricted:latest\": allowPrivilegeEscalation != false (container \"restore-wait\" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container \"restore-wait\" must set securityContext.capabilities.drop=[\"ALL\"]), runAsNonRoot != true (pod or container \"restore-wait\" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container \"restore-wait\" must set securityContext.seccompProfile.type to \"RuntimeDefault\" or \"Localhost\")" logSource="pkg/controller/restore_controller.go:580" restore=velero/restore-from-bl-dev-01
time="2024-09-16T17:14:27Z" level=error msg="Namespace wordpress, resource restore error: error restoring pods/wordpress/wordpress-mariadb-0: pods \"wordpress-mariadb-0\" is forbidden: violates PodSecurity \"restricted:latest\": allowPrivilegeEscalation != false (container \"restore-wait\" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container \"restore-wait\" must set securityContext.capabilities.drop=[\"ALL\"]), runAsNonRoot != true (pod or container \"restore-wait\" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container \"restore-wait\" must set securityContext.seccompProfile.type to \"RuntimeDefault\" or \"Localhost\")" logSource="pkg/controller/restore_controller.go:580" restore=velero/restore-from-bl-dev-01

The necessary SecurityContext should be added to the init container to not break the pod security policy.

Environment:

Vote on this issue!

This is an invitation to the Velero community to vote on issues, you can see the project's top voted issues listed here.
Use the "reaction smiley face" up to the right of this comment to vote.

reasonerjt commented 1 week ago

If we can't make it in v1.15.0, the fix should be cherry-picked in v1.15.1

kaovilai commented 6 days ago

Would this also apply to datamover?

blackpiglet commented 6 days ago

IMO, the data mover's intermediate pod is created in the Velero installed namespace. There are some differences from the PodVolumeBackup scenario, we already applied the privileged PSA by default to it by velero install CLI.