Phase 1: Local Cluster + kubectl Fluency
Time: week 1. Goal: a running cluster on your Mac and muscle memory with kubectl.
Install a local cluster
Recommendation: kind (Kubernetes-in-Docker, lightweight, disposable), or just enable Kubernetes in Docker Desktop / OrbStack since you already run Docker.
brew install kind kubectl k9s
kind create cluster --name k8dev
kubectl cluster-infoInstall k9s too - it's a TUI for the cluster and you'll thank me later. You learn resource relationships just by navigating it.
The kubectl verbs that matter
These cover 95% of day-to-day usage:
kubectl get pods # list resources
kubectl describe pod <name> # details + events (your #1 debugging tool)
kubectl logs <pod> # container logs
kubectl exec -it <pod> -- sh # shell into a container
kubectl apply -f file.yaml # declare desired state
kubectl delete -f file.yaml # remove it
kubectl port-forward svc/x 8080:80 # tunnel to a service
kubectl explain deployment.spec # offline field docs, underratedKubeconfig and contexts
kubectl decides which cluster to talk to via ~/.kube/config. This matters the moment you have more than one cluster (local + work).
kubectl config get-contexts
kubectl config use-context kind-k8devExercise
Full playbook with the kind config, expected output, and verify checklist: Lab 1. Use the lab - it creates the cluster with the port mappings that Lab 4 needs.
Run an nginx pod imperatively, poke at it, then delete it:
kubectl run web --image=nginx
kubectl get pods -w
kubectl port-forward pod/web 8080:80 # open http://localhost:8080
kubectl logs web
kubectl exec -it web -- sh
kubectl delete pod webNotice the pod does not come back after deletion. That's the lesson leading into Phase 2: bare pods have no controller watching them. Nothing declared that this pod should exist, so nothing recreates it.
Checkpoint
- You can create and destroy a kind cluster without looking anything up.
- You can get, describe, log, and exec against a pod from memory.
- You know what file kubectl reads to find your cluster.