Kubernetes kubectl Cheatsheet
Command sequences for kubectl pod scheduling, namespace configs, logs diagnostics, deployments, and cluster management.
Pod Management
kubectl get pods -n [ns]
List all pods within the specified namespace.
kubectl get pods -n production
kubectl logs -f [pod]
Stream logs from the specified pod running on the cluster.
kubectl logs -f my-web-app-843a
kubectl describe pod [name]
Inspect events, resource limits, and metadata of a pod.
kubectl describe pod my-web-app-843a
kubectl exec -it [pod] -- bash
Run interactive terminal shell commands inside pods.
kubectl exec -it api-pod-9932 -- /bin/bash
kubectl delete pod [name]
Force delete a failing pod container inside namespaces.
kubectl delete pod api-pod-9932
Deployments & Services
kubectl apply -f [file.yaml]
Apply configurations to cluster nodes using local YAML maps.
kubectl apply -f deployment.yaml
kubectl scale deployment [dep] --replicas=[count]
Scale pod replication factors on active deployment scripts.
kubectl scale deployment web-api --replicas=5
kubectl expose deployment [dep] --port=[port]
Expose deployment ports to generate internal services.
kubectl expose deployment web-api --port=8080 --target-port=80
Cluster Diagnostics
kubectl get configmaps
List configuration maps inside the active namespace.
kubectl get configmaps -n production
kubectl create secret generic [name] --from-literal=k=v
Generate generic secrets dynamically inside cluster registers.
kubectl create secret generic db-pass --from-literal=password=foo
No matching syntax found
Verify your query spelling or try searching another keyword.