kubectl Pods commands
41 commands in 5 groups: Manage, Access, Logs, List, Inspect. Click or tap any command to copy it. Official documentation: kubernetes.io.
Open in the interactive cheat sheet search, stars and every other section
Manage
Apply manifests, run standalone Pods imperatively, and remove them by name, file, or label.
kubectl apply -f <pod.yaml>
Create or update Pod from manifest
kubectl delete pod <name>
Delete a Pod gracefully
kubectl delete -f <pod.yaml>
Delete Pod defined in manifest
kubectl delete pods -l <key>=<value>
Delete Pods by label selector
kubectl delete pod <name> --force --grace-period=0
Force-delete a stuck Pod
kubectl diff -f <pod.yaml>
Preview changes before applying Pod manifest
kubectl run <name> --image=<image>
Create a standalone Pod
kubectl run <name> --image=<image> --rm -it -- bash
Ephemeral debug Pod (auto-deletes)
Access
Get inside a running Pod to execute commands, transfer files, or forward ports locally.
kubectl attach -it <pod>
Attach to the main process of a Pod container
kubectl attach -it <pod> -c <container>
Attach to a specific container
kubectl cp ./local <pod>:/path/to/file
Copy file from local to Pod
kubectl cp <pod>:/path/to/file ./local
Copy file from Pod to local
kubectl exec <pod> -- <command>
Run a one-off command in Pod
kubectl exec -it <pod> -- bash
Open interactive shell in Pod
kubectl exec -it <pod> -c <container> -- sh
Shell into a specific container
kubectl port-forward pod/<name> <local>:<remote>
Forward local port to Pod
kubectl port-forward pod/<name> 8080:80
Forward localhost:8080 → pod:80
kubectl port-forward svc/<name> 8080:80
Forward localhost:8080 → service:80
Logs
Stream, filter, and retrieve logs from Pod containers.
kubectl logs <pod>
Print Pod logs (stdout and stderr)
kubectl logs <pod> --since=1h
Logs from the last hour
kubectl logs <pod> --tail=100
Print last 100 lines
kubectl logs <pod> -c <container>
Logs from a specific container
kubectl logs <pod> -f
Follow / stream Pod logs
kubectl logs -l app=<name> --all-containers=true
Last 10 lines from every container of each Pod matching the label (add --tail=-1 for all)
List
List Pods across Namespaces, filter them by label or field selector, and pick the output format.
kubectl get pods
List Pods in current Namespace
kubectl get pods --field-selector=status.phase=Running
Filter Pods by field selector
kubectl get pods --watch
Watch Pod status changes in real time
kubectl get pods -A
List all Pods across all Namespaces
kubectl get pods -l <key>=<value>
Filter Pods by label selector
kubectl get pods -n <namespace>
Pods in a specific Namespace
kubectl get pods -o wide
Show IP, Node and Nominated Node
kubectl get pods -A --field-selector=status.phase!=Running
Find all non-Running Pods across the cluster
Inspect
Examine a specific Pod, including its manifest, container layout, Node placement, and resource usage.
kubectl describe pod <name>
Full Pod details, events and status
kubectl get pod <name> -o jsonpath='{.spec.containers[*].name}'
List all container names in a Pod
kubectl get pod <name> -o jsonpath='{.spec.nodeName}'
Which Node the Pod is running on
kubectl get pod <name> -o jsonpath='{.status.podIP}'
Get Pod IP as a one-liner
kubectl get pod <name> -o yaml
Get Pod manifest as YAML
kubectl top pod
CPU and memory usage for Pods
kubectl top pod --sort-by=cpu
Sort Pods by CPU usage
kubectl wait --for=condition=Ready pod -l <key>=<value>
Wait for all matching Pods to be Ready
kubectl wait --for=condition=Ready pod/<name> --timeout=60s
Wait until Pod is Ready