Шпаргалка по kubectl
Команды Kubernetes CLI для инспекции подов, деплойментов, сервисов, логов, отладки через exec, выкаток (rollouts), контекстов и JSONPath-запросов на Kubernetes 1.30+.
Принцип работы
kubectl reads and reconciles declarative resource manifests against the API server: `get`/`describe`/`logs` diagnose state, while `apply`/`rollout` safely drive cluster changes.
Набор для выживания
Несколько команд, которые стоит выучить в первую очередь.
42 команды
Contexts, Namespaces & Discovery
Verify which cluster and namespace you target before reading or changing state.
- Базовый
Print the currently active cluster context before running commands
kubectl config current-contextКогда использовать
Prevents accidentally running dev commands against a production cluster.
Пример
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.