What it does
When a pod crashes, gets OOMKilled or stays Pending, kubectl tells you
the symptom. KubeTective looks for the cause. It reads the pod, its events, its logs and
its owners. It can also read Prometheus, Loki and your Git history. Then it builds a
timeline, ranks the possible causes and prints the evidence for each one.
$ kubectl investigate deployment/checkout -n prod
╭──────────────────────────────────────────────────╮
│ INCIDENT: deployment/prod/checkout │
│ Status: OOMKILLED │
│ Severity: HIGH │
│ Confidence: 97% │
╰──────────────────────────────────────────────────╯
ROOT CAUSE
Configuration regression: commit 9f2c1a7d (checkout: bump CACHE_SIZE
5000 -> 50000) preceded the failure
EVIDENCE
✓ commit 9f2c1a7d: checkout: bump CACHE_SIZE 5000 -> 50000 (+30)
✓ commit 6 min before onset (+25)
✓ workload observed changed in window (+10)
✓ mechanism: failure follows the change (+30)
RECOMMENDATION
roll back deployment/prod/checkout to the last known-good revision [MEDIUM]
The verdict comes from rules, not from a language model. The same recording always gives the same answer, and every point of the score is printed.
Read-only by default
Investigating never changes the
cluster. A fix runs only when you approve it with --yes.
Every run is saved
Each investigation is stored as a file. You can replay it later, share it, or turn it into a test.
Works offline
No account, no API key, no telemetry. An LLM is optional and can only reword the result.
Install
Homebrew (macOS and Linux)
brew install gledilami/kubetective/kubetective
This installs kubetective and the kubectl investigate
plugin. Update with brew upgrade kubetective.
Go
go install github.com/GlediLami/kubetective/cmd/kubetective@latest
go install github.com/GlediLami/kubetective/cmd/kubectl-investigate@latest
Needs Go 1.26 or newer. The binaries land in ~/go/bin.
Download a binary or package
The release page
has archives for Linux and macOS (amd64 and arm64), and .deb and
.rpm packages.
# Debian or Ubuntu
sudo apt install ./kubetective_1.0.2_linux_amd64.deb
# Fedora, RHEL or SUSE
sudo dnf install ./kubetective_1.0.2_linux_amd64.rpm
Container image
docker pull ghcr.io/gledilami/kubetective:latest
Which one should I use?
- Homebrew on your laptop. It is the simplest and updates easily.
- go install if you already work with Go and have no Homebrew.
- .deb or .rpm on a Linux server or a jump host.
- Container image to run the REST server inside a cluster, or in CI.
Try it without a cluster
The repository ships recorded incidents. Replay one to see real output in a minute:
git clone https://github.com/GlediLami/kubetective.git
cd kubetective
make build
bin/kubetective replay scenarios/config-regression/record.jsonl
Other recordings to try:
bin/kubetective replay scenarios/crashloop/record.jsonl
bin/kubetective replay scenarios/imagepull/record.jsonl
bin/kubetective replay scenarios/pending-unschedulable/record.jsonl
bin/kubetective replay scenarios/dns-failure/record.jsonl
Then check that your own setup works:
kubetective doctor
doctor checks your kubeconfig, cluster access, the incident store and
any Prometheus or Loki you configured. It exits with an error if something fails.
Everyday use
KubeTective uses your current kubeconfig, like kubectl. Targets can be a
deployment, a pod or a namespace. Without
-n, the namespace of your current context is used.
Investigate something that is broken
# a deployment
kubectl investigate deployment/checkout -n prod
# one pod
kubectl investigate pod/checkout-7f84c9 -n prod
# the worst problem in a whole namespace
kubectl investigate namespace/prod
# look further back (default: 30 minutes)
kubectl investigate deployment/checkout -n prod --since=2h
# another cluster
kubectl investigate deployment/checkout -n prod --context=staging
Link the failure to a commit
Point it at the Git checkout of your manifests. Then it can name the commit that came right before the failure:
kubectl investigate deployment/checkout -n prod --git-repo ~/code/manifests
Flux and Argo CD are read from the cluster automatically.
Add metrics and logs
# reach Prometheus and Loki from your laptop first
kubectl -n monitoring port-forward svc/prometheus 9090:9090 &
kubectl -n monitoring port-forward svc/loki 3100:3100 &
kubectl investigate deployment/checkout -n prod \
--prometheus-url http://localhost:9090 \
--loki-url http://localhost:3100
Every source is optional. A missing one shows up under EVIDENCE GAPS.
Use the result in scripts
kubetective investigate deployment/checkout -n prod --format=json \
| jq '{status: .incident.status, cause: .hypotheses[0].claim}'
{
"status": "OOMKILLED",
"cause": "Memory exhaustion: container terminated with OOMKilled 1 time(s) (memory limit 32Mi) - 3 restart(s)"
}
Look at past investigations
# newest first
kubetective incidents list
# filter
kubetective incidents search --target checkout --since 24h
kubetective incidents search --analyzer oom --severity HIGH
# has this happened before?
kubetective incidents similar incident-1792155417-checkout
# show one again
kubetective replay incident-1792155417-checkout
Records are stored in ~/.kubetective/incidents.
Fix it, with approval
# preview: shows the action and the kubectl command it equals
kubetective action incident-1792155417-checkout
ACTION PREVIEW (read-only - nothing has been applied)
act-41cd35a3 rollback
target: deployment/prod/checkout
dry run: kubectl rollout undo deployment/checkout -n prod --dry-run=client
risk: MEDIUM
# apply it (nothing happens without --yes)
kubetective action incident-1792155417-checkout --apply act-41cd35a3 --yes
Available actions are a deployment rollback and a pod restart.
Share an incident safely
kubetective sanitize incident-1792155417-checkout
# writes incident-1792155417-checkout.sanitized.jsonl
Names and identifiers are replaced and secrets are scrubbed, but the verdict stays the same. Read the file before you share it: scrubbing free text is pattern-based.
Plain-language summary with an LLM (optional)
# any OpenAI-compatible API, including a local Ollama
kubectl investigate deployment/checkout -n prod --llm \
--llm-base-url http://localhost:11434/v1 --llm-model llama3.1
The LLM gets a digest of the result and rewrites it. It cannot change the score, the cause or the action.
Reading the output
- Status, Severity, Confidence
- What state the workload is in, how bad it is, and how sure the engine is about the top cause.
- ROOT CAUSE
- The cause with the highest score.
- EVIDENCE
- The facts behind that score.
✓ ... (+25)supports it,! ... (-6)argues against it or marks something missing. - EVIDENCE GAPS
- Sources that could not be read, for example no Prometheus configured or no access to logs. A gap is shown, never hidden.
- TIMELINE
- Everything that happened in the window, relative to the start of the failure
(
t+0m). - WHAT CHANGED
- Changes in the window, ranked by how relevant they are.
- RECOMMENDATION
- What to do next, with a risk level. Nothing is applied automatically.
The last line prints the record id. Use it with replay,
action or sanitize.
What it detects
- OOM kills
- Crash loops
- Image pull failures
- Unschedulable pods
- Node pressure
- Failing liveness and readiness probes
- Unbound PVCs
- Service selector mismatches
- HPA at its maximum
- DNS failures
- Changes linked to a Git or GitOps commit
Config file
Put defaults in ~/.kubetective/kubetective.yaml so you do not repeat
flags:
namespace: payments
since: 1h
git_repo: ~/code/payments-manifests
prometheus_url: http://localhost:9090
loki_url: http://localhost:3100
# different defaults per kubeconfig context
clusters:
staging:
namespace: staging
loki_url: http://staging-loki:3100
Flags win over environment variables, which win over the file. All options are in the configuration reference.
Start from an alert
Give it the webhook body of an alert, and it investigates the workload the alert names. No API keys are needed: the payload is read locally.
Grafana
cat alert.json
{"alerts":[{"labels":{"namespace":"prod","deployment":"checkout"}}]}
kubetective alert grafana --file alert.json
Slack slash command
echo '{"text":"deployment/checkout namespace=prod since=2h"}' | kubetective alert slack
The text understands deployment/prod/checkout,
namespace=prod, -n prod and since=2h.
PagerDuty
echo '{"event":"incident.triggered","data":{"incident":{"title":"OOMKilled deployment/prod/checkout"}}}' \
| kubetective alert pagerduty
Get notified when it is done
# kubetective.yaml
webhook_url: https://ops.example.com/kubetective
webhook_secret: change-me
After every investigation, KubeTective sends a POST signed with HMAC-SHA256 in the
X-Kubetective-Signature header. Check the signature before you trust the
body.
REST and MCP
REST server
kubetective serve --listen 127.0.0.1:8080
curl -s localhost:8080/v1/investigate \
-H 'content-type: application/json' \
-d '{"target":"deployment/checkout","namespace":"prod","since_minutes":30}' \
| jq '.hypotheses[0].claim'
curl -s localhost:8080/v1/incidents # list records
curl -s localhost:8080/v1/incidents/<id> # one record
open http://localhost:8080/ # read-only web view
The server has no login. Keep it on localhost, or put it behind something that handles auth. Details: API reference and the OpenAPI spec.
MCP server (for AI assistants)
Lets an assistant such as Claude call KubeTective. The tools are
investigate, replay, list_incidents,
read_incident and action_preview. None of them changes the
cluster.
# Claude Code
claude mcp add kubetective -- kubetective mcp
// other clients: add to the client's MCP config
{
"mcpServers": {
"kubetective": { "command": "kubetective", "args": ["mcp"] }
}
}
Run it inside a cluster
deploy/rbac.yaml gives read access to what KubeTective needs. Write
access (rollback, restart) is limited to the namespaces you choose. Edit the
prod namespace in the file first.
kubectl create namespace kubetective
kubectl apply -f https://raw.githubusercontent.com/GlediLami/kubetective/main/deploy/rbac.yaml
kubectl -n kubetective create deployment kubetective \
--image=ghcr.io/gledilami/kubetective:latest --port=8080
kubectl -n kubetective set serviceaccount deployment/kubetective kubetective
kubectl -n kubetective port-forward deployment/kubetective 8080:8080
The image runs kubetective serve --listen :8080 as a non-root user.
Or run the image locally
docker run --rm --user "$(id -u)" \
-v ~/.kube/config:/kube/config:ro -e KUBECONFIG=/kube/config \
ghcr.io/gledilami/kubetective:latest investigate deployment/checkout -n prod
For a local kind or minikube cluster, add --network host.
Known limits
- When no analyzer matches, the engine can fall back to "Configuration regression: a change preceded the incident" at about 65 to 79%, without naming a commit. A missing Secret mount is one such case. Read that verdict as "unknown".
namespace/...shows only the strongest problem. Investigate a deployment or pod to see the others.service/...targets are not supported yet. Investigate the deployment behind the service.
The engine is tested on 25 recorded incidents on every commit. It gets 17 right. The 8 misses stay in the suite on purpose, so the confidence numbers stay honest. See the evaluation report.
Verify a release
Releases are signed with Sigstore cosign, without a long-lived key. The signature proves the files were built by the release workflow of this repository. Each archive also comes with an SBOM, a list of every library inside it.
VERSION=v1.0.2
gh release download "$VERSION" --repo GlediLami/kubetective --pattern '*checksums.txt*'
cosign verify-blob kubetective_1.0.2_checksums.txt \
--signature kubetective_1.0.2_checksums.txt.sig \
--certificate kubetective_1.0.2_checksums.txt.pem \
--certificate-identity-regexp '^https://github\.com/GlediLami/kubetective/\.github/workflows/release\.yml@refs/tags/' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
# then check a downloaded file against the list
sha256sum --ignore-missing -c kubetective_1.0.2_checksums.txt
More in SECURITY.md.
More
- CLI reference: every command and flag
- Architecture: how the pipeline works
- Benchmark scenarios: how the engine is tested
- Contributing: the most useful contribution is a real incident (
kubetective scenario new <id>)