Stand up a local Kubernetes cluster, meet kubectl, and deploy your first application — then watch Kubernetes keep it running. The hands-on foundation for everything that follows.
A "cluster" is a set of machines Kubernetes runs your apps across. You already started a throwaway local one in "Before you start" — kind, minikube, or Docker Desktop, no real servers needed. Before going further, confirm kubectl is connected to it; the rest of the course runs against this cluster.
Confirm kubectl is connected to your cluster
kubectl cluster-infokubectl is the command-line tool you use for everything — it sends your requests to the cluster's API server. The pattern is always kubectl VERB RESOURCE: get to list, describe for detail, apply to create or update from a file. get nodes shows the machines; get pods shows the running app instances.
List the machines (nodes) in the cluster
kubectl get nodesList running app instances (pods) across all namespaces
kubectl get pods -AYou almost never run a bare container in Kubernetes — you create a Deployment, which keeps a chosen number of copies of your app running. Create one imperatively to see it work, then expose it so you can reach it. Kubernetes pulls the image, schedules it onto a node, and starts it.
Run an app: a Deployment named "web" from an image
kubectl create deployment web --image=nginxWatch the pod come up (Ctrl+C to stop watching)
kubectl get pods --watchThe core idea of Kubernetes is the "desired state": you declare what you want, and the cluster works continuously to match it. Delete the running pod and Kubernetes notices reality no longer matches your declared one replica — and immediately starts a replacement. You did not ask for that; the system did it on its own.
Find the pod's name
kubectl get podsDelete it — then list again and a NEW pod is already coming up
kubectl delete pod <pod-name>kubectl get podsWhy: imperative commands are fine for experiments, but real work is declarative — you write what you want in a YAML file and kubectl apply makes it so. The same file, re-applied, is the single source of truth you commit to git. Every lesson from here builds these manifests. Note: apiVersion + kind name the object type; metadata names it; spec describes the desired state.
# web.yaml — the same Deployment, declared in a file
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.27apply -f sends a file to the cluster and creates or updates whatever it describes. describe is your first debugging tool — it prints an object's full state and a timeline of events at the bottom. delete -f removes everything the file created. These three verbs carry you through the whole course.
Create or update from the file
kubectl apply -f web.yamlFull detail + an events timeline (read the Events at the bottom)
kubectl describe deployment webRemove everything the file declared
kubectl delete -f web.yaml