Command
kubectl get podsExplanation
The 'kubectl get pods' command lists all pods within a namespace, showing their names, statuses, restarts, and ages. It helps administrators quickly assess the state of workloads. Adding the '-o wide' flag shows additional details such as node assignments and IP addresses. It's commonly used for monitoring running services and verifying pod deployments.
Common Use Cases
- •Verify deployment of applications
- •Check pod readiness and restart count
- •Monitor workloads in different namespaces
Best Practices
- ✓Use '-o wide' for more context on node scheduling and IPs
- ✓Combine with 'watch' to monitor pods in real-time
Common Mistakes to Avoid
- ⚠Forgetting to specify '-n <namespace>' when looking for pods in non-default namespaces
- ⚠Misinterpreting the STATUS field without checking events or logs
Troubleshooting
Problem: Pod stuck in 'Pending' or 'CrashLoopBackOff'
Solution: Run 'kubectl describe pod <name>' or 'kubectl logs <name>' to identify scheduling or container issues.
Examples
List pods in the default namespace
kubectl get podsList pods in the kube-system namespace
kubectl get pods -n kube-system