Difference between revisions of "Kubectl cp"
Jump to navigation
Jump to search
(35 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{lc}} | {{lc}} | ||
+ | kubectl cp Copy files and directories to and from containers and between containers. https://spacelift.io/blog/kubectl-cp | ||
* https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#cp | * https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#cp | ||
[[kubectl]] cp | [[kubectl]] cp | ||
+ | [[kubectl cp --help]] | ||
+ | |||
+ | kubectl cp YourRemoteContainer:/yourdestinationdatafolder/ /your/local/folder/ | ||
+ | kubectl cp YourNamespace/YourRemoteContainer:/yourdestinationdata/ /your/local/folder/ | ||
+ | |||
+ | kubectl cp youfile.txt YourRemoteContainer:/yourdestinationdata | ||
+ | kubectl cp /your/local/folder/* [[YourRemoteContainer]]:/yourdestinationdata | ||
+ | |||
+ | |||
+ | |||
− | |||
[[kubectl apply -f]] | [[kubectl apply -f]] | ||
https://stackoverflow.com/questions/50375826/kubernetes-how-to-download-a-persistentvolumes-content | https://stackoverflow.com/questions/50375826/kubernetes-how-to-download-a-persistentvolumes-content | ||
− | + | {{alpine cp example}} | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | kubectl cp | + | kubectl cp myalpinedataaccess:/data data/ |
[[tar]]: removing leading '/' from member names | [[tar]]: removing leading '/' from member names | ||
+ | |||
+ | [[kubectl exec]] <pod_name> -- ls -la / | ||
+ | |||
+ | |||
+ | [[kubectl exec myalpine -- df -kh]] | ||
+ | [[mount]] | [[grep ^/dev/]] | grep -v /etc | awk '{print $3}' | ||
+ | |||
+ | |||
+ | == Errors == | ||
+ | |||
+ | [[error: source and destination are required]] | ||
+ | Solution: remove trailing /* from your local directory name | ||
+ | |||
+ | [[error: unable to upgrade connection]]: [[container not found]]("your-container") | ||
+ | |||
+ | |||
+ | == Related == | ||
+ | * [[Velero]] | ||
+ | * <code>[[docker cp]]</code> | ||
+ | * [[Kube-dump]] | ||
+ | * <code>[[kubectl.kubernetes.io/default-container]]</code> | ||
+ | * [[kubectl exec]] | ||
== See also == | == See also == | ||
+ | * {{kubectl cp}} | ||
* {{cp}} | * {{cp}} | ||
− | |||
[[Category:Kubectl]] | [[Category:Kubectl]] |
Latest revision as of 12:34, 8 February 2024
kubectl cp Copy files and directories to and from containers and between containers. https://spacelift.io/blog/kubectl-cp
kubectl cp kubectl cp --help
kubectl cp YourRemoteContainer:/yourdestinationdatafolder/ /your/local/folder/ kubectl cp YourNamespace/YourRemoteContainer:/yourdestinationdata/ /your/local/folder/
kubectl cp youfile.txt YourRemoteContainer:/yourdestinationdata kubectl cp /your/local/folder/* YourRemoteContainer:/yourdestinationdata
kubectl apply -f
https://stackoverflow.com/questions/50375826/kubernetes-how-to-download-a-persistentvolumes-content
apiVersion: v1 kind: Pod metadata: name: myalpinewithvolume spec: containers: - name: alpine image: alpine:latest command: ['ash'] tty: true stdin: true volumeMounts: - name: myvolume mountPath: /myvolume volumes: - name: myvolume persistentVolumeClaim: claimName: myPVCtoMount
kubectl cp myalpinedataaccess:/data data/ tar: removing leading '/' from member names
kubectl exec <pod_name> -- ls -la /
kubectl exec myalpine -- df -kh mount | grep ^/dev/ | grep -v /etc | awk '{print $3}'
Errors[edit]
error: source and destination are required Solution: remove trailing /* from your local directory name
error: unable to upgrade connection: container not found("your-container")
Related[edit]
See also[edit]
kubectl cp
cp
,dd
,sftp
,scp
,rsync
,casync
,mv
,fio
,ln
,docker cp, kubectl cp
,minikube cp
,multipass transfer
,Copy-Item
,Xcopy
Advertising: