Listen to this Post

Managing Kubernetes clusters efficiently requires mastering `kubectl` commands. Below is a comprehensive list of essential commands for daily operations, troubleshooting, and advanced Kubernetes management.
Basic Kubernetes Commands
1. List all pods
kubectl get pods
2. Describe a pod
kubectl describe pod <pod-name>
3. Check cluster nodes
kubectl get nodes
4. View services
kubectl get svc
5. Access pod logs
kubectl logs <pod-name>
Advanced Kubernetes Commands
6. Restart pods without downtime (rolling restart)
kubectl rollout restart deployment <deployment-name>
7. Force delete a stuck pod
kubectl delete pod <pod-name> --grace-period=0 --force
8. Port-forwarding to a pod
kubectl port-forward <pod-name> <local-port>:<pod-port>
9. Debug a pod using ephemeral container
kubectl debug -it <pod-name> --image=busybox --target=<container-name>
10. Apply a YAML manifest with server-side apply
kubectl apply --server-side -f deployment.yaml
You Should Know:
- Custom JSONPath Queries
kubectl get pods -o jsonpath='{.items[].metadata.name}' - Using `jq` for JSON Processing
kubectl get pods -o json | jq '.items[].metadata.name'
- Taint a Node
kubectl taint nodes <node-name> key=value:NoSchedule
- Check Resource Usage
kubectl top pods kubectl top nodes
Expected Output:
- For
kubectl get pods:NAME READY STATUS RESTARTS AGE nginx-7cdbd8cdc9-2xz4l 1/1 Running 0 2d
- For
kubectl logs:Starting Nginx server... Listening on port 80
What Undercode Say:
Kubernetes is a powerful orchestration tool, but mastering its commands is crucial for DevOps efficiency. This handbook provides real-world commands for troubleshooting, scaling, and debugging. Automation with `kubectl` and `jq` can significantly enhance productivity.
Prediction:
As Kubernetes adoption grows, AI-powered tools will likely integrate with `kubectl` for predictive debugging and auto-remediation, reducing manual intervention.
Relevant URLs:
References:
Reported By: Adityajaiswal7 Devops – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅


