Lab 4: Self-Healing
Delete a pod
Section titled “Delete a pod”make chaos # deletes a random demo podmake watch shows a new pod with a new name created immediately. The ReplicaSet saw 2 ≠ 3 and fixed it. In the visualizer one card goes gone and a fresh one appears.
Crash the process
Section titled “Crash the process”Click Crash a pod in the visualizer (or curl -X POST localhost:8080/api/crash).
This time the pod keeps its name, but RESTARTS goes 0 → 1. The kubelet restarted the container inside the same pod.
kubectl logs -n demo <pod-name> --previous # logs from the crashed containerCrash the same pod repeatedly and you’ll see CrashLoopBackOff: Kubernetes waits 10s, 20s, 40s… between restarts so a broken app doesn’t burn the node.
Kill a whole node
Section titled “Kill a whole node”kubectl get pods -n demo -o wide # note which pods are on learn-worker2docker stop learn-worker2 # "unplug" a serverkubectl get nodes -w # NotReady after ~40sAfter the node is unreachable, its pods are marked for eviction and recreated on learn-worker. (This takes a few minutes by default, so be patient.) The Service stops routing to them as soon as they fail readiness.
docker start learn-worker2 # plug it back inDelete everything?
Section titled “Delete everything?”kubectl delete pods -n demo -l app=demo # all of them at onceThey all come back. To actually stop the app you delete the Deployment (the desired state), not the pods.