Your handy guide for troubleshooting Kubernetes clusters with a list of commonly used kubectl commands to display one or many resources when running commands against clusters. Click to copy to clipboard easily, or download the PDF cheatsheet as a useful reference.
Cluster
kubectl version
kubectl cluster-info
kubectl config view
kubectl config get-contexts
kubectl config current-context
kubectl config use-context [cluster_context_name]
kubectl api-versions
kubectl api-resources
Logs
kubectl logs [pod_name] -n [namespace]
kubectl logs -f [pod_name] -n [namespace]
kubectl logs -f [pod_name] -c [container_name] -n [namespace]
kubectl logs --tail=20 [pod_name] -n [namespace]
kubectl logs --since=1h [pod_name] -n [namespace]
kubectl logs --previous [pod_name] -n [namespace]
kubectl logs -l name=[label_name] -n [namespace]
Resources
kubectl top node
kubectl top pod
kubectl cordon node [node_name]
kubectl uncordon node [node_name]
kubectl drain node [node_name]
Events
kubectl get events
kubectl get events --field-selector type=Warning
Not keen to commit these commands to memory? Let CAEPE handle them for you. CAEPE is a Continuous Deployment platform purpose built for Kubernetes. CAEPE supports both push and pull approaches and fits seamlessly into your existing pipelines to simplify application deployment for Kubernetes.