# Run from this lesson's examples directory. Requires Docker, kind, and kubectl. # All cluster commands explicitly target a disposable local cluster. kind create cluster --name probes-lesson docker build -t probes-lesson:v1 . kind load docker-image probes-lesson:v1 --name probes-lesson kubectl --context kind-probes-lesson create namespace probes-lesson kubectl --context kind-probes-lesson apply -f deployment.yaml kubectl --context kind-probes-lesson -n probes-lesson rollout status deployment/tickets --timeout=180s # Observe before injecting a failure. Record restart counts for each Pod. kubectl --context kind-probes-lesson -n probes-lesson get pods -l app=tickets kubectl --context kind-probes-lesson -n probes-lesson get endpointslices -l kubernetes.io/service-name=tickets -o yaml # Start an in-cluster client. Its image is already loaded; this adds no new image. kubectl --context kind-probes-lesson -n probes-lesson run request-check --image=probes-lesson:v1 --image-pull-policy=Never --restart=Never --command -- node -e 'setInterval(() => {}, 1000)' kubectl --context kind-probes-lesson -n probes-lesson wait --for=condition=Ready pod/request-check --timeout=60s # Repeat this request before, during, and after the drill. Record status and replica. kubectl --context kind-probes-lesson -n probes-lesson exec request-check -- node -e "fetch('http://tickets/tickets').then(async r => console.log(r.status, r.headers.get('x-replica'), await r.text()))" # A marker simulates an unavailable dependency for ONE replica. kubectl --context kind-probes-lesson -n probes-lesson exec deployment/tickets -- node -e "require('node:fs').writeFileSync('/tmp/database-down', '')" # Wait at least 15 seconds, then inspect readiness, restarts, and endpoint conditions. # No restart is expected. Save the affected Pod name from this output. kubectl --context kind-probes-lesson -n probes-lesson get pods -l app=tickets kubectl --context kind-probes-lesson -n probes-lesson get endpointslices -l kubernetes.io/service-name=tickets -o yaml # Replace AFFECTED_POD with that name; do not let exec choose a different replica. kubectl --context kind-probes-lesson -n probes-lesson exec AFFECTED_POD -- node -e "require('node:fs').unlinkSync('/tmp/database-down')" # After recovery, simulate a local progress failure in that same replica. kubectl --context kind-probes-lesson -n probes-lesson exec AFFECTED_POD -- node -e "require('node:fs').writeFileSync('/tmp/stuck', '')" kubectl --context kind-probes-lesson -n probes-lesson describe pod AFFECTED_POD # Expect a liveness failure, one container restart, startup gating, then Ready. # Marker files live in the container writable layer and disappear on restart. # Cleanup only this disposable cluster when observations are complete. kind delete cluster --name probes-lesson