Searchable reference of common kubectl commands for managing Kubernetes pods, deployments, services and more.
42 of 42 commands — click any row to copy
kubectl version
Show the client and server Kubernetes versions
kubectl cluster-info
Display endpoint information about the cluster control plane
kubectl config get-contexts
List all available contexts (clusters/users/namespaces)
kubectl config use-context <name>
Switch to a different context
kubectl config set-context --current --namespace=<ns>
Set the default namespace for the current context
kubectl get nodes
List all nodes in the cluster
kubectl top nodes
Show CPU/memory usage for each node (requires metrics-server)
kubectl get pods
List pods in the current namespace
kubectl get pods -A
List pods across all namespaces
kubectl get pods -o wide
List pods with extra details such as node and IP
kubectl get all
List all common resources (pods, services, deployments, etc.) in the namespace
kubectl get svc
List services in the current namespace
kubectl get deployments
List deployments in the current namespace
kubectl describe pod <name>
Show detailed information and recent events for a pod
kubectl get pods -w
Watch pods and stream updates as their status changes
kubectl get pods -l app=<label>
List pods matching a label selector
kubectl logs <pod>
Show logs for a pod's container
kubectl logs -f <pod>
Stream (follow) logs for a pod
kubectl logs <pod> -c <container>
Show logs for a specific container in a multi-container pod
kubectl exec -it <pod> -- sh
Open an interactive shell inside a running pod
kubectl port-forward <pod> 8080:80
Forward a local port to a port on a pod
kubectl cp <pod>:<path> <dest>
Copy files between a pod and the local filesystem
kubectl apply -f <file>.yaml
Create or update resources defined in a manifest file
kubectl create -f <file>.yaml
Create resources from a manifest file (errors if they already exist)
kubectl delete -f <file>.yaml
Delete resources defined in a manifest file
kubectl delete pod <name>
Delete a specific pod
kubectl edit deployment <name>
Open a resource's manifest in your editor and apply changes on save
kubectl scale deployment <name> --replicas=3
Scale a deployment to a specific number of replicas
kubectl rollout restart deployment <name>
Trigger a rolling restart of all pods in a deployment
kubectl rollout status deployment <name>
Watch the status of a deployment rollout
kubectl rollout undo deployment <name>
Roll back a deployment to its previous revision
kubectl set image deployment/<name> <container>=<image>
Update the container image used by a deployment
kubectl create configmap <name> --from-literal=key=value
Create a ConfigMap from literal key-value pairs
kubectl create secret generic <name> --from-literal=key=value
Create a generic Secret from literal key-value pairs
kubectl get secret <name> -o yaml
View a Secret's manifest (values are base64-encoded)
kubectl create namespace <name>
Create a new namespace
kubectl get namespaces
List all namespaces
kubectl get events --sort-by=.lastTimestamp
List cluster events sorted by time, most recent last
kubectl explain <resource>
Show documentation for a resource type and its fields
kubectl api-resources
List all resource types supported by the cluster
kubectl get pod <name> -o yaml
Dump the full manifest of a pod as YAML
kubectl run debug --image=busybox -it --rm -- sh
Spin up a temporary debug pod and open a shell in it