Last active
October 21, 2024 16:55
-
-
Save tallclair/9217e2694b5fdf27b55d6bd1fda01b53 to your computer and use it in GitHub Desktop.
kubectl cp equivalents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace | |
kubectl cp /tmp/foo_dir <some-pod>:/tmp/foo_dir | |
tar cf - /tmp/foo_dir | kubectl exec -i <some-pod> -- tar xf - | |
# Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container | |
kubectl cp /tmp/foo <some-pod>:/tmp/foo -c <specific-container> | |
tar cf - /tmp/foo | kubectl exec -i <some-pod> -c <specific-container> -- tar xf - | |
# Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace> | |
kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/foo | |
tar cf - /tmp/foo | kubectl exec -i -n <some-namespace> <some-pod> -- tar xf - | |
# Copy /tmp/foo from a remote pod to /tmp/bar locally | |
kubectl cp <some-namespace>/<some-pod>:/tmp/foo foo | |
kubectl exec -n <some-namespace> <some-pod> -- tar cf - /tmp/foo | tar xf - | |
# You can even copy a file from one pod to another! | |
kubectl exec <some-pod> -- tar cf - /tmp/foo | kubectl exec -i <other-pod> -- tar xf - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment