kubernetes kubectl ·

Essential kubectl Commands Cheat Sheet

A quick reference for the most commonly used kubectl commands covering pods, deployments, services, and debugging.

Essential kubectl Commands Cheat Sheet
Advertisement

Pod Management

CommandDescription
kubectl get podsList all pods in current namespace
kubectl get pods -AList pods across all namespaces
kubectl describe pod <name>Show detailed pod information
kubectl delete pod <name>Delete a specific pod
kubectl logs <pod>View pod logs
kubectl logs <pod> -fStream pod logs
kubectl exec -it <pod> -- shOpen shell in pod

Deployments

CommandDescription
kubectl get deploymentsList all deployments
kubectl scale deploy <name> --replicas=3Scale a deployment
kubectl rollout status deploy/<name>Check rollout status
kubectl rollout undo deploy/<name>Rollback a deployment
kubectl set image deploy/<name> <container>=<image>Update container image

Services and Networking

CommandDescription
kubectl get svcList all services
kubectl get ingressList all ingress resources
kubectl port-forward svc/<name> 8080:80Forward local port to service
kubectl get endpointsList service endpoints

Debugging

CommandDescription
kubectl get events --sort-by=.metadata.creationTimestampView cluster events
kubectl top podsShow pod resource usage
kubectl top nodesShow node resource usage
kubectl logs <pod> --previousView logs from crashed container
kubectl describe node <name>Check node conditions

Context and Config

CommandDescription
kubectl config get-contextsList all contexts
kubectl config use-context <name>Switch context
kubectl config current-contextShow current context
kubectl get nsList namespaces
kubectl config set-context --current --namespace=<ns>Set default namespace
Advertisement

Stay up to date

Get DevOps tips, tutorials, and guides delivered to your inbox.