← All bricks

kubectl · Beginner

kubectl: Kubernetes from the Command Line

Get fluent with kubectl — the client you actually drive Kubernetes with. Deploy and scale nginx, expose it, read logs, exec into pods, watch the cluster heal itself, then do it all again declaratively from a manifest.

Kubernetes is run from the terminal, and kubectl is the one tool that talks to every cluster you will ever touch — local, staging, production. Most people learn it by copy-pasting commands they half understand. We go slower and build real fluency one command at a time: look at the nodes, create a deployment, read what the cluster made for you, scale it, expose it, follow its logs and step inside a pod. Then we watch it heal a deleted pod by itself, and finally rebuild the whole thing the way you run it for real — from a YAML manifest under version control. Writing a manifest and applying it are taught as separate things, so each idea lands on its own.

What you'll build

  • Inspect a cluster and the workloads running on it
  • Create, scale and expose a deployment imperatively
  • Read logs and exec into running pods
  • Watch Kubernetes self-heal a deleted pod
  • Write a Deployment manifest and apply it declaratively
  • Drive rollouts, namespaces and port-forwarding from kubectl
  • Pull single values out with -o jsonpath for scripting

Contents

  1. See the cluster's machines
  2. Confirm client and server versions
  3. Create your first deployment
  4. Check the deployment is ready
  5. Look at the pods underneath
  6. Describe a pod in full
  7. Read the container's logs
  8. Step inside a running pod
  9. Scale to three replicas
  10. Watch the new pods appear
  11. Tail logs across all the pods
  12. Expose the deployment
  13. Find the NodePort
  14. Delete a pod on purpose
  15. Watch the cluster heal itself
  16. Tear down the imperative deployment
  17. Write a Deployment manifest
  18. Apply the manifest
  19. Change the file and apply again
  20. See it with extra columns
  21. See everything at once
  22. Read the live object as YAML
  23. Roll out a new image
  24. Watch the rollout finish
  25. Restart the pods cleanly
  26. Undo a bad rollout
  27. List pods in every namespace
  28. Target a specific namespace
  29. Reach a pod from your laptop
  30. Pull one value out for a script
  31. Delete what the file created
  32. Where to go from here