All Essential Kubernetes Commands – 2026 Updated Guide
This article provides a concise, step‑by‑step reference of the most frequently used kubectl commands for Kubernetes, explaining each command's purpose, typical scenarios, useful options, and the information it reveals to help operators troubleshoot clusters, nodes, pods, deployments, logs, and resources.
1. View cluster status
kubectl cluster-infoPurpose: Verify that core components such as the API server and DNS are functioning.
Typical scenarios: check cluster availability; troubleshoot control‑plane problems.
2. View node status
kubectl get nodesPurpose: List all nodes and their Ready/NotReady state.
Extended view: kubectl get nodes -o wide Shows node IP, OS version, container runtime, etc.
3. View Pods
kubectl get podsPurpose: List Pods in the current namespace.
All namespaces:
kubectl get pods -A4. Describe a Pod
kubectl describe pod <pod-name>Purpose: Detailed inspection of a Pod, including events, image‑pull status, restart reasons, and scheduling information.
5. View Deployments
kubectl get deploymentPurpose: Inspect the deployment status of applications.
6. Check rollout status
kubectl rollout status deployment/<name>Purpose: Verify whether a deployment rollout has completed successfully.
7. Roll back a deployment
kubectl rollout undo deployment/<name>Purpose: Revert to the previous revision, useful for failed releases or emergency rollbacks.
Applicable scenarios: release failure; production incident rollback.
8. View logs
kubectl logs <pod-name>Purpose: Stream real‑time logs from a Pod.
Multi‑container Pod:
kubectl logs <pod-name> -c <container-name>9. Execute a shell in a container
kubectl exec -it <pod-name> -- /bin/bashIf the container image uses Alpine, replace /bin/bash with /bin/sh.
Purpose: Diagnose environment issues and debug the container’s internal state.
10. Delete resources
kubectl delete pod <pod-name>Purpose: Remove a specific Pod. kubectl delete deployment <name> Purpose: Delete an entire Deployment.
11. Apply YAML configuration
kubectl apply -f app.yamlPurpose: Create or declaratively update resources defined in a YAML manifest.
Create resources
Update resources (declarative)
12. View all resources
kubectl get allPurpose: List the most important resource types in the current namespace (Pods, Services, Deployments, ReplicaSets).
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.
Architect Chen
Sharing over a decade of architecture experience from Baidu, Alibaba, and Tencent.
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.
