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
- See the cluster's machines
- Confirm client and server versions
- Create your first deployment
- Check the deployment is ready
- Look at the pods underneath
- Describe a pod in full
- Read the container's logs
- Step inside a running pod
- Scale to three replicas
- Watch the new pods appear
- Tail logs across all the pods
- Expose the deployment
- Find the NodePort
- Delete a pod on purpose
- Watch the cluster heal itself
- Tear down the imperative deployment
- Write a Deployment manifest
- Apply the manifest
- Change the file and apply again
- See it with extra columns
- See everything at once
- Read the live object as YAML
- Roll out a new image
- Watch the rollout finish
- Restart the pods cleanly
- Undo a bad rollout
- List pods in every namespace
- Target a specific namespace
- Reach a pod from your laptop
- Pull one value out for a script
- Delete what the file created
- Where to go from here