Core objects
kubectl
14 / 82

Three commands answer most questions: get, describe, and logs.

Every kubectl command is an HTTP call to the API server. Start with the cheapest read and move deeper only when needed.

zsh: shop / gke-eu-prod
$ kubectl apply -f deployment.yaml
deployment.apps/checkout created
$ kubectl get pods -l app=checkout -o wide
NAME              READY  STATUS   NODE        IP
checkout-7d9f8-a  1/1    Running  gke-np1-x2  10.244.1.5
checkout-7d9f8-b  0/1    Pending  <none>
$ kubectl describe pod checkout-7d9f8-b
Events:
  Warning  FailedScheduling  0/3 nodes: Insufficient cpu
$ kubectl logs checkout-7d9f8-a -c app --tail=20
$ kubectl rollout status deployment/checkout
1 get

What exists and what state is it in? Add -o wide, -o yaml, -l label, -A.

2 describe

Why is it in that state? The Events at the bottom name the failing step.

3 logs

What did the application say? Use -c for a container and --previous after a crash.

4 apply and diff

kubectl diff -f then apply -f. Declarative, repeatable, reviewable.

Local practice: kind, minikube or k3d give you a real cluster on a laptop in a minute. Production uses the same commands.