Kubernetes cp gives permission denied error

I am trying to copy a local file owned by root to one pod in cert-manager using kubectl cp command as below -

kubectl cp Docker_dbfiles.zip maas-oracle-65df4f64c7-xbn5d:/data01/oracle/oradata -c oracle-docker --namespace=cert-manager

It give the below error -

tar: Docker_dbfiles.zip: Cannot open: Permission denied
tar: Exiting with failure status due to previous errors
command terminated with exit code 2

can someone help me here. The file has 777 permissions and owned by root.

For kubectl cp try copying first to /tmp folder and then mv the file to the path required by shifting to root user

then exec into the pod and change to root and copy to the path required.

Guessing as to the reason for this, which is probably important to know.

You’re running the kubectl command and got an error from tar. Should probably check the permissions on the present working directory. You don’t have write permissions to that folder and kubectl cp uses tar to compress files…