Copy a file from a pod

Copies a file from a running container to your machine

kubectl cp <ns>/<pod>:/remote/path ./local-path

tool
kubectl73 commands
tags
debug

More kubectl commands

  • kubectl cordon <node>

    Marks the node as unschedulable, so no new pods start there

  • kubectl drain <node> --ignore-daemonsets --delete-emptydir-data

    Safely evicts all pods from the node before maintenance

  • kubectl edit deployment/<name> -n <ns>

    Opens the resource in $EDITOR and applies the changes when you save

  • kubectl auth can-i list pods --as=system:serviceaccount:<ns>:<sa> -n <ns>

    Checks if a ServiceAccount can list pods; change the verb and resource to check other actions

  • kubectl get pods -n <ns> -o custom-columns='NAME:.metadata.name,NODE:.spec.nodeName,STATUS:.status.phase'

    Prints only the fields you need, no jq required

all 73 kubectl commands