KUBERNETES / PRACTICEFree access

Kubernetes practice

Explore the cluster, simulate Pod recovery, and try the kubectl exercise. The browser simulations need no setup; the command-line exercise requires a disposable local cluster.

Review Kubernetes foundations
INTERACTIVE ARCHITECTURE

Inside a Kubernetes cluster

Select a component to inspect its role, or follow a request through the cluster.

KUBERNETES CLUSTERSelect a component
CONTROL PLANECoordination
Communication through the API server
↔ Cloud provider API
Worker agents ↔ API server
WORKER 1Server / VM
WORKER 2Server / VM

Outer frame = Pod; inner block = container. Connections describe control communication, not application traffic. Pod placement is illustrative.

Teaching model: real controllers operate asynchronously through the API. This is not a live cluster. Cloud integration is optional; networking implementations vary. The diagram omits CNI, DNS, storage and control-plane replicas to keep the core roles readable.

LAB 02 · RECONCILIATION

Keep the promise of three replicas

Predict first, then step through. Set replicas to 4 and worker slots to 2. Why do two Pods stay Pending?

Desired replicas3
Pod objects0
Running0

No Pod objects

Browser simulation, not a live cluster. One slot represents an entire Pod request. Real scheduling considers CPU, memory, constraints and policies. Steps run concurrently in real clusters; readiness, image failures, retries and termination delays are omitted.

PRACTICE · 15 MINUTES

Observe reconciliation in a real cluster

Optional on your first read. You need kubectl, a disposable local cluster (kind or minikube), permission to create a namespace and workloads, and internet access from the cluster to pull the image. Cluster installation is covered in Your first cluster. The browser labs above work without any installation.

Use only your own disposable local cluster. Confirm the context before creating anything. If academy-foundations already exists, stop and choose an unused lab namespace, replacing it in every command and in the manifest.

Check the target, then create the lab namespaceRun the first two commands and inspect the context and nodes before the third. Outputs below are illustrative, not a live execution log.
kubectl config current-context
kubectl get nodes
kubectl create namespace academy-foundations
Example output
kind-kind
NAME                 STATUS   ROLES           AGE   VERSION
kind-control-plane   Ready    control-plane   ...   v1.x.y
namespace/academy-foundations created

Read the contract before applying it

Save this as foundations-web.yaml. apiVersion and kind choose the resource type; metadata names it. spec.replicas requests three copies. The selector matches the template labels, which let the ReplicaSet identify its Pods. template describes each Pod. The HTTP readiness probe tests whether nginx can answer; containerPort alone does not expose a Service or publish a host port.

foundations-web.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: foundations-web
  namespace: academy-foundations
spec:
  replicas: 3
  selector:
    matchLabels:
      app: foundations-web
  template:
    metadata:
      labels:
        app: foundations-web
    spec:
      containers:
        - name: web
          image: nginx:stable-alpine
          ports:
            - containerPort: 80
          resources:
            requests:
              cpu: 100m
              memory: 64Mi
            limits:
              memory: 128Mi
          readinessProbe:
            httpGet:
              path: /
              port: 80
            initialDelaySeconds: 2
            periodSeconds: 3

The stable-alpine tag is convenient for this disposable lab but can change. Production releases should use a reviewed version or immutable digest. CPU and memory requests are scheduling inputs; these small example values are not production sizing guidance.

Apply intent, then wait for readinesscreated means the API accepted the object. rollout status waits for the Deployment to become available. A timeout is a reason to inspect, not proof that apply failed.
kubectl apply -f foundations-web.yaml
kubectl -n academy-foundations rollout status deployment/foundations-web --timeout=120s
kubectl -n academy-foundations get deployment,replicaset,pods
Example output (abridged)
deployment.apps/foundations-web created
...
deployment "foundations-web" successfully rolled out
...
NAME                              READY   UP-TO-DATE   AVAILABLE
 deployment.apps/foundations-web   3/3     3            3
Delete one Pod and compare identitiesIn a second terminal, run the watch command first. In the first terminal, record names and UIDs, then select and delete one Pod. The replacement gets a new name and UID. Press Ctrl+C to stop watching.
# Terminal 2
kubectl -n academy-foundations get pods -l app=foundations-web -w

# Terminal 1
kubectl -n academy-foundations get pods -l app=foundations-web -o custom-columns=NAME:.metadata.name,UID:.metadata.uid
LAB_POD=$(kubectl -n academy-foundations get pods -l app=foundations-web -o jsonpath='{.items[0].metadata.name}')
kubectl -n academy-foundations delete pod "$LAB_POD"
kubectl -n academy-foundations rollout status deployment/foundations-web --timeout=120s
kubectl -n academy-foundations get pods -l app=foundations-web -o custom-columns=NAME:.metadata.name,UID:.metadata.uid
Expected observations
A deleted Pod disappears.
A new Pod progresses from Pending toward Running.
After recovery, three Pods exist again.
The replacement UID differs from the deleted Pod's UID.
Exact names, event order and timings vary.
Change the desired stateEdit replicas: 3 to replicas: 2 in the saved YAML, then reapply. Predict which controller removes the surplus Pod. Unlike deleting a Pod, this changes the desired count itself.
kubectl apply -f foundations-web.yaml
kubectl -n academy-foundations rollout status deployment/foundations-web --timeout=120s
kubectl -n academy-foundations get deployment foundations-web
Example output (abridged)
deployment.apps/foundations-web configured
...
NAME              READY   UP-TO-DATE   AVAILABLE
foundations-web    2/2     2            2

If the expected state never arrives

Terminal
kubectl -n academy-foundations describe deployment foundations-web
kubectl -n academy-foundations describe pods -l app=foundations-web
kubectl -n academy-foundations get events --sort-by=.metadata.creationTimestamp
Remove only the namespace you createdThis deletes every resource in academy-foundations. Run it only if this is the disposable namespace you created for the exercise.
kubectl delete namespace academy-foundations
Example output
namespace "academy-foundations" deleted
Exercise: explain the result before reading the answer

Deleting a managed Pod changes observed state, so the ReplicaSet creates a replacement. Editing replicas changes desired state, so the ReplicaSet keeps the new count.