Kubectl cp command
Kubernetes troubleshooting tales#
While debugging a tough problem with buildkit-rootless mode for building a Docker image on a pod provisioned via the Jenkins Kubernetes Plugin, I discovered a handy Kubernetes command to copy the contents of a specific container pod to another pod.
Copy the content of a problematic pod to a local directory:
kubectl cp <pod_name>:<path_of_container_want_to_copy> <local_path> -c <specific_container>
Then, copy the local content to the fresh pod, for example, into the /tmp directory:
kubectl cp <local_path> <new_pod>:/tmp
You can run your problematic command in a fresh pod through exec, see if the error persists, and debug from there.
PS: Still figuring out why a rootless pod with buildkit doesn’t work when provisioned via Jenkins (even though it has the same specs as the fresh one). Perhaps this will be another Kubernetes troubleshooting tale :)
There are no articles to list here yet.