100 Essential kubectl Commands to Master Kubernetes (PDF Included)
This guide compiles 100 practical kubectl commands for diagnosing Kubernetes clusters, covering cluster info, pod inspection, service checks, deployments, statefulsets, ConfigMaps, Secrets, and more, providing concise examples for each operation and troubleshooting.
Cluster Information
Show Kubernetes version: kubectl version Show cluster info: kubectl cluster-info List all nodes: kubectl get nodes Describe a specific node: kubectl describe node <node-name> List all namespaces: kubectl get namespaces List all pods in all namespaces:
kubectl get pods --all-namespacesPod Diagnosis
List pods in a namespace: kubectl get pods -n <namespace> Describe a pod: kubectl describe pod <pod-name> -n <namespace> View pod logs: kubectl logs <pod-name> -n <namespace> Tail pod logs: kubectl logs -f <pod-name> -n <namespace> Execute a command in a pod:
kubectl exec -it <pod-name> -n <namespace> -- <command>Pod Health Check
Check pod readiness:
kubectl get pods <pod-name> -n <namespace> -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'Check pod events:
kubectl get events -n <namespace> --field-selector involvedObject.name=<pod-name>Service Diagnosis
List services in a namespace: kubectl get svc -n <namespace> Describe a service:
kubectl describe svc <service-name> -n <namespace>Deployment Diagnosis
List deployments in a namespace: kubectl get deployments -n <namespace> Describe a deployment:
kubectl describe deployment <deployment-name> -n <namespace>Check rollout status:
kubectl rollout status deployment/<deployment-name> -n <namespace>View rollout history:
kubectl rollout history deployment/<deployment-name> -n <namespace>StatefulSet Diagnosis
List StatefulSets in a namespace: kubectl get statefulsets -n <namespace> Describe a StatefulSet:
kubectl describe statefulset <statefulset-name> -n <namespace>ConfigMap and Secret Diagnosis
List ConfigMaps: kubectl get configmaps -n <namespace> Describe a ConfigMap:
kubectl describe configmap <configmap-name> -n <namespace>List Secrets: kubectl get secrets -n <namespace> Describe a Secret:
kubectl describe secret <secret-name> -n <namespace>Namespace Diagnosis
Describe a namespace:
kubectl describe namespace <namespace-name>Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Golang Shines
We share daily the latest Golang technical articles, practical resources, language news, tutorials, and real-world projects to help everyone learn and improve.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
