Cheatsheet do kubectl
Comandos da CLI do Kubernetes para inspecionar pods, deployments, services, logs, depuração com exec, rollouts, contextos e consultas JSONPath no Kubernetes 1.30+.
Como funciona
kubectl reads and reconciles declarative resource manifests against the API server: `get`/`describe`/`logs` diagnose state, while `apply`/`rollout` safely drive cluster changes.
Kit de sobrevivência
Os principais comandos para aprender primeiro.
42 comandos
Contexts, Namespaces & Discovery
Verify which cluster and namespace you target before reading or changing state.
- Essencial
Print the currently active cluster context before running commands
kubectl config current-contextQuando usar
Prevents accidentally running dev commands against a production cluster.
Exemplo
kubectl config current-context
Inspect, Logs & Events
Diagnose CrashLoopBackOff, ImagePullBackOff, pending pods, and probe failures.
Shell, Port-Forward & Copy
Connect to cluster services locally, exec into pods, and transfer files.
Apply, Dry-Run & Rollouts
Validate manifests safely, watch rollouts, scale, and roll back cleanly.
Nodes, RBAC & Cleanup
Verify permissions, check resource usage, cordon nodes, and clean pods.