This is the flagship project. Everything from Day 1 comes together here -- LLM tool-calling, Kubernetes operations, and now Temporal for durable execution.
KubeHealer is an AI agent that finds broken Kubernetes pods, diagnoses them with Claude, and fixes them automatically. Every step runs inside Temporal workflows, so the agent is crash-proof, retryable, and fully observable.
Repo: https://github.com/TrainWithShubham/kubehealer
- Temporal workflows -- durable execution that survives crashes. If the worker dies mid-diagnosis, it picks up exactly where it left off.
- Claude tool-calling -- the LLM doesn't just explain problems. It picks remediation actions (restart pod, fix image, adjust resources) and we execute them.
- Crash recovery -- kill the worker mid-workflow, restart it, watch it resume. This is the key demo.
- Audit trail -- every Claude call, every tool use, every fix is recorded in Temporal's event history. Open the UI and see exactly what the agent did.
CLI (you type here)
|
v
Temporal Workflow (ConversationWorkflow)
|
+-- activity: call_claude (sends your message to Claude)
+-- activity: list_pods / get_pod_details / get_pod_logs (Claude's tool calls)
+-- activity: call_claude (Claude sees tool results, responds)
+-- activity: scan_cluster -> diagnose_pod -> execute_fix (healing flow)
|
v
Kubernetes API (applies the fix)
Every box above is a Temporal activity -- individually retryable, observable in the UI, with its own timeout.
| Broken App | Problem | AI Diagnosis | Auto-Fix |
|---|---|---|---|
| web-app | Image "nginx:latestt" (typo) | Detects typo in image name | Patches to nginx:latest |
| memory-hog | 10Mi memory limit + stress 100M | OOMKilled | Patches to 256Mi |
| config-app | Missing ConfigMap | Cannot auto-fix | Skips with explanation |
The agent knows its limits. config-app needs a ConfigMap created -- that's beyond what a pod patch can do, so the agent skips it and tells you why.
You need one new thing for this module:
Temporal CLI -- install it:
# macOS
brew install temporal
# Linux
curl -sSf https://temporal.download/cli.sh | shVerify:
temporal --versionYou also need an Anthropic API key. Get one at https://console.anthropic.com/
cd ~
git clone https://github.com/TrainWithShubham/kubehealer.git
cd kubehealerpip install -r requirements.txtcp .env.example .envEdit .env and paste your Anthropic API key.
Terminal 1:
./setup.shThis creates a Kind cluster called kubehealer and deploys 3 intentionally broken apps. You should see:
Pod status:
web-app-xxx 0/1 ErrImagePull
memory-hog-xxx 0/1 CrashLoopBackOff
config-app-xxx 0/1 CreateContainerConfigError
Terminal 2:
temporal server start-devWait for "Temporal server is running". The UI will be at http://localhost:8233
Terminal 3:
python worker.pyYou should see:
[OK] Anthropic API key
[OK] Kubernetes cluster
KubeHealer worker started. Waiting for tasks...
Terminal 4:
python cli.pyYou're in.
In the CLI, start by exploring:
you> how many pods are running?
The agent calls list_pods and shows you the cluster status.
you> what's wrong with web-app?
The agent calls get_pod_details, reads the events, and spots the image typo.
you> show me the logs for memory-hog
The agent calls get_pod_logs and shows the OOMKill.
Now heal everything:
you> heal my cluster
The agent scans all pods, diagnoses each one, and presents its findings with severity, root cause, and proposed fix.
you> approve all fixes
The agent patches web-app's image and memory-hog's resource limits. config-app gets skipped (needs a ConfigMap that doesn't exist).
Verify:
kubectl get podsweb-app and memory-hog should be Running. config-app is still broken (expected).
The agent told you config-app needs a ConfigMap. Create it:
kubectl create configmap app-config --from-literal=APP_ENV=production --from-literal=APP_DEBUG=false
kubectl rollout restart deployment config-appNow all 3 pods should be healthy.
This is the key Temporal demo. We'll prove the agent survives crashes.
./setup.shIn the CLI:
you> heal my cluster
Watch the agent start scanning and diagnosing.
While the agent is mid-diagnosis, go to Terminal 3 (worker) and press Ctrl+C.
The workflow is now stuck. Open http://localhost:8233 -- you'll see the workflow in "Running" state with some activities completed and the current one pending.
python worker.pyGo back to the Temporal UI. The workflow resumes immediately. Activities that already completed (scan, some diagnoses) are NOT re-executed -- Temporal replays them from cached results. Only the remaining work runs.
The CLI gets the response as if nothing happened.
This is durable execution. The agent's state lives in Temporal, not in the Python process.
You can also kill the CLI (Ctrl+C) and restart it:
python cli.pyIt reconnects to the same conversation. Your chat history is preserved.
Open http://localhost:8233 in your browser.
Click on any completed workflow. Go to the History tab. You'll see every event:
WorkflowExecutionStartedActivityTaskScheduled(call_claude)ActivityTaskCompleted(Claude's response)ActivityTaskScheduled(list_pods -- Claude called a tool)ActivityTaskCompleted(pod list returned)ActivityTaskScheduled(call_claude -- with tool result)ActivityTaskCompleted(Claude's final answer)- ...and so on for every interaction
This is your audit trail. Every Claude call, every tool invocation, every fix -- all recorded with zero custom logging code. If someone asks "what did the AI agent do to our cluster?", the answer is in the workflow history.
Remember the concepts from Module 4:
Guardrails (Kiro incident): KubeHealer has a constrained action space -- only 4 possible actions (restart_pod, fix_image, patch_resources, skip). No arbitrary kubectl commands. The agent asks for approval before executing. Compare this to AWS Kiro, which had unbounded production access and deleted an environment.
Durability (Temporal): Module 4 showed the problem: naive agents lose state on crash. KubeHealer proves the solution: every step is a Temporal activity, every result is persisted, crashes are invisible to the workflow.
Alert fatigue: Module 4 talked about thousands of alerts per day. KubeHealer doesn't just alert -- it diagnoses and fixes. The human only needs to approve.
| Component | Role |
|---|---|
| Temporal | Durable workflow orchestration |
| Claude (Sonnet 4) | LLM diagnosis + conversational agent |
| Kubernetes | Target environment |
| Kind | Local K8s cluster |
| Python 3.11+ | Everything glued together |
kind delete cluster --name kubehealerStop Temporal (Ctrl+C in Terminal 2), worker (Ctrl+C in Terminal 3).
- Change the broken apps in
chaos/to create different failures - Add a new remediation action (e.g., scale a deployment)
- Try
python starter.pyfor auto-heal mode (no interaction needed) - Modify the system prompt in the chat activities to make the agent more/less conservative
- Run
kubectl get pods -win a separate terminal to watch pods heal in real time