{ "id": "rootnode-probe-port-mismatch", "title": "Stuck Not-Ready: The Probe Port Mismatch", "category": "Observability & Ops", "difficulty": "Medium", "type": "task", "weight": 8, "description": "## Stuck Not-Ready: The Probe Port Mismatch\n\nA deployment named `api-gateway` was rolled out to the `default` namespace. The pods start, the container runs — but the deployment never reaches Ready. Traffic won't be routed to it, and the on-call alert is firing.\n\nThis is a class of incident that is easy to miss: the container is actually healthy, but Kubernetes disagrees because the readiness probe is checking the **wrong port**. In production this pattern silently blocks rollouts, causes zero-downtime deploys to stall, and is tricky to diagnose if you go straight to logs instead of reading events.\n\n**Your task:** Diagnose why the pods are failing their readiness check, correct the probe configuration, and restore the deployment to **2/2 Ready**.\n\n> Tip: start with pod status and events — the scheduler and kubelet leave a clear trail. Read before you patch.", "hints": [ { "title": "1. See the failure", "body": "List pods and look at the READY column. Then describe one of the failing pods and read the Events section at the bottom — kubelet reports readiness probe failures there with the exact port it tried.", "command": "kubectl get pods\nkubectl describe pod -l app=api-gateway" }, { "title": "2. Inspect the probe config", "body": "Pull the readiness probe definition from the live deployment. You are looking for the httpGet port — compare it to the port nginx actually listens on (80).", "command": "kubectl get deployment api-gateway -o jsonpath='{.spec.template.spec.containers[0].readinessProbe}'" }, { "title": "3. Patch the probe port", "body": "Use a JSON patch to correct the readiness probe port to 80. The deployment will trigger a new rollout and the pods should become Ready within a few seconds.", "command": "kubectl patch deployment api-gateway --type='json' -p='[{\"op\":\"replace\",\"path\":\"/spec/template/spec/containers/0/readinessProbe/httpGet/port\",\"value\":80}]'" } ], "setup_commands": [ { "command": "kubectl create deployment api-gateway --image=nginx:1.25 --replicas=2" }, { "command": "kubectl patch deployment api-gateway --type='json' -p='[{\"op\":\"add\",\"path\":\"/spec/template/spec/containers/0/readinessProbe\",\"value\":{\"httpGet\":{\"path\":\"/\",\"port\":8080},\"initialDelaySeconds\":3,\"periodSeconds\":5}}]'" } ], "validation": { "description": "Checks that the probe port is corrected and both replicas are Ready.", "commands": [ { "description": "Readiness probe port is 80", "command": "kubectl get deployment api-gateway -o jsonpath='{.spec.template.spec.containers[0].readinessProbe.httpGet.port}'", "expected_output": "80", "match": "exact" }, { "description": "Deployment has 2 ready replicas", "command": "kubectl get deployment api-gateway -o jsonpath='{.status.readyReplicas}' 2>/dev/null | grep -v '^$' || echo 0", "expected_output": "2", "match": "exact" }, { "description": "No pods stuck in non-Running state", "command": "kubectl get pods -l app=api-gateway --no-headers 2>/dev/null | awk '{print $3}' | grep -cv 'Running' || true", "expected_output": "0", "match": "exact" } ] }, "default_namespace": "default", "teardown_commands": [ { "command": "kubectl delete deployment api-gateway --ignore-not-found" } ] }