Master Kubectl: Commands for Troubleshooting Kubernetes Clusters

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 config get-contexts
kubectl config current-context
kubectl config use-context [cluster_context_name]

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 cordon node [node_name]
kubectl uncordon node [node_name]
kubectl drain node [node_name]

Events

kubectl get events --field-selector type=Warning

Download the PDF version of this kubectl cheat sheet

CAEPE Continuous Deployment

Manage workloads on Kubernetes anywhere robustly and securely.

  • Shores up security by simplifying deployment anywhere, supporting managed services, native Kubernetes, self-hosted, edge and secure airgapped deployment targets. 
  • Supports GitOps and provides guided, UI-driven workflows for all major progressive delivery strategies
  • Has RBAC built-in, providing inherent enterprise access control for who can deploy.
  • Supports extended testing capabilities enabling your team to run different tests quickly and easily.

Check out these other resources:

Scroll to Top