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 a running process in a pod
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 including previous instances.
kubectl logs <pod>
Print pod logs (stdout)
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 each pod matching label (add --tail=-1 for all)

List

List pods across namespaces with filtering by label, field selector, or 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 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