100 Essential kubectl Commands for Kubernetes Diagnostics
This guide lists 100 practical kubectl commands for diagnosing Kubernetes clusters, covering cluster information, pod inspection, service checks, deployment status, StatefulSet details, ConfigMap and Secret queries, and namespace analysis.
Overview
This article provides a concise reference of 100 kubectl commands useful for diagnosing Kubernetes clusters, covering cluster information, pod inspection, service checks, deployment status, StatefulSet details, ConfigMap and Secret inspection, and namespace queries.
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 Diagnostics
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 Checks
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 Diagnostics
List services in a namespace: kubectl get svc -n <namespace> Describe a service:
kubectl describe svc <service-name> -n <namespace>Deployment Diagnostics
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 Diagnostics
List StatefulSets: kubectl get statefulsets -n <namespace> Describe a StatefulSet:
kubectl describe statefulset <statefulset-name> -n <namespace>ConfigMap and Secret Diagnostics
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 Diagnostics
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.
