KubeAgent Kubernetes CLI documentation
Everything you need to get KubeAgent running — from installation to approvals and incident alerts.
Written and reviewed by Hadi Farnoud · Updated July 16, 2026
Installation
KubeAgent runs as a CLI. Install it with npx for zero setup, or globally if you prefer.
Run once (no install)
Install globally
npm install -g kubeagent kubeagent --version
kubectl installed and pointing at your cluster, a KubeAgent account (free plan available).
Quick start
The fastest way to get started is npx kubeagent onboard — it handles login, cluster scanning, and knowledge base setup in one step.
Or step-by-step:
- Authenticate:
npx kubeagent login - Scan cluster and build knowledge base:
npx kubeagent onboard - Start the monitoring loop:
npx kubeagent watch - Connect a notification channel (Slack, Discord, Teams, Telegram, PagerDuty, or Webhook) to receive incident and recovery alerts.
# Onboard handles everything at once npx kubeagent onboard Opening browser to complete login… ✓ Logged in as [email protected] ✓ Cluster: hetzner-prod (3 nodes, 12 namespaces) ✓ Detected: 18 deployments across 6 projects ✓ Knowledge base written to ~/.kubeagent/kb/ # Then start watching npx kubeagent watch ✓ Watching cluster hetzner-prod (Ctrl+C to stop) ✓ Issues resolved will be reported to Slack → #oncall
Login & auth
KubeAgent uses a browser-based login flow. Your credentials are stored locally in ~/.kubeagent/auth.json.
kubeagent login # opens browser kubeagent login --device # device-code flow for headless/SSH machines kubeagent logout # removes local credentials
Headless & SSH machines
On headless machines (SSH sessions, containers, servers without a browser), use --device. KubeAgent will display a URL and code — open the URL on any device, enter the code, and your CLI session is authenticated. Headless/SSH environments are auto-detected, so the flag is often applied automatically.
kubeagent status
Runs a one-shot health check and prints all detected issues. Useful in scripts and CI pipelines.
kubeagent status Checking cluster hetzner-prod… [critical] pod_crash_loop: retime-api-worker-6b4d9 has restarted 42 times [warning] pod_oom: dove-worker-7c8f2 was OOM-killed (last 1h) [info] pod_pending: solidtime-worker pending for 2m (scheduling) 3 issues found.
| Flag | Description |
|---|---|
| --context <name> | Use a specific kubectl context (overrides current-context) |
| --namespace <ns> | Limit checks to one namespace |
| --json | Output issues as JSON (for scripting) |
kubeagent onboard
Onboarding scans your cluster topology and any local code repositories you point it at. It then asks a few clarifying questions (powered by AI) and writes a knowledge base to ~/.kubeagent/kb/ that the diagnoser uses as context.
Run onboarding once when you first set up, then again whenever you add new services or significantly change your infrastructure.
kubeagent onboard ✓ Cluster scanned: 3 nodes, 12 namespaces, 18 deployments ✓ Code projects found: retime-api (PHP/Laravel), dove (Go) ✓ Answering questions about your stack… What is the primary purpose of the "dove" service? > Transactional email delivery for all products Which services are most critical (cannot tolerate any downtime)? > dove-web, falcon, retime-api-web ✓ Knowledge base written to ~/.kubeagent/kb/
| Flag | Description |
|---|---|
| -t, --timeout <sec> | Max seconds to wait for the cluster scan (default: 120) |
kubeagent watch
kubeagent watch checks your cluster from your terminal every 300 seconds by default (-i to change it). When it finds an issue, it runs the AI diagnoser, proposes a fix, and — if the fix is on your allow-list (remediation.safe_actions in ~/.kubeagent/config.yaml) — applies it. Other supported writes ask for approval in that terminal; with --no-interactive they are denied. For always-on monitoring use the in-cluster agent, which sends approvals to Slack and the dashboard instead.
✓ Watching cluster hetzner-prod [11:42:01] Detected: pod_crash_loop on retime-api-worker-6b4d9 [11:42:03] Fetching logs… describing pod… checking events… [11:42:09] Root cause: OOM (memory limit 256Mi, heap spiked to 300Mi) [11:42:09] Proposed fix: increase memory limit to 512Mi [11:42:10] Requires approval → waiting in the active terminal [11:43:00] ✓ Approved in terminal — applying set_resources… [11:43:04] ✓ Done. Pod restarted cleanly.
| Flag | Description |
|---|---|
| -i, --interval <sec> | Check interval in seconds (default: 300, from onboarding) |
| --no-interactive | Run headless — approval-required actions are denied |
| -c, --context <name> | Use a specific kubectl context (skips the prompt) |
kubeagent demo
Creates an isolated kubeagent-demo namespace with one deliberately broken pod (it crash-loops with a clear error in its logs), waits for KubeAgent to detect it, sends the alert to your connected notification channels, and runs the AI diagnosis. Nothing outside the demo namespace is touched — the namespace is labeled at creation and only ever deleted when it carries that label. Auto-fix is off for the demo run, and the namespace is removed at the end (--keep retains it, kubeagent demo --cleanup removes it any time, --yes skips prompts). Requires login — the diagnosis uses a small amount of your AI credits.
kubeagent diagnose
Runs a one-shot diagnosis on whatever issues currently exist in the cluster. Same AI loop as watch but triggered manually.
kubeagent diagnose Scanning for issues… 2 issues found. Starting diagnosis… ── Issue 1: pod_crash_loop ── Root cause: application startup failure due to missing DB_HOST env var Fix: Secret "retime-env" is missing key DB_HOST — add it and rollout restart Verification: pod should reach Running state within 60s with 0 restarts ── Issue 2: pod_pending ── Root cause: insufficient CPU (requested 2000m, node has 1800m available) Fix: Scale down retime-api-worker to 3 replicas to free headroom
kubeagent query
Use query for ad-hoc questions that don't fit neatly into a diagnosis flow. The AI has full access to the same cluster tools (logs, describe, events) and the knowledge base.
kubeagent query "why is dove-worker using so much memory?" kubeagent query "show me all deployments that haven't restarted in 7 days" kubeagent query "what would happen if I scaled retime-api-web to 1 replica?"
kubeagent onboard after adding new services.
kubeagent scan
Scans a local directory and suggests which subdirectory maps to which deployment in your cluster. Useful for setting up the knowledge base or verifying project-to-deployment mappings.
kubeagent scan ~/Code/devops Scanning ~/Code/devops… retime-api/ → retime-api-web (prod) dove/ → dove-web (prod) offka/ → offka-web (prod) ajimaji-api/ → ajimaji-v1 (ajimaji) 4 matches found.
| Flag | Description |
|---|---|
| --context <name> | Use a specific kubectl context |
kubeagent notify
Add, list, test, and remove notification channels without leaving the terminal.
kubeagent notify add # interactive setup — pick channel type and configure kubeagent notify list # show all configured channels kubeagent notify test # send a test alert to all channels kubeagent notify remove 1 # remove channel by index
Supported channels: Slack, Discord, Microsoft Teams, Telegram, PagerDuty, and custom webhooks. See the notification sections below for detailed setup instructions.
kubeagent account
Shows your current plan, monthly token allocation, remaining balance, and extra credits. Includes a low-balance warning when you're below 20% of your monthly tokens.
kubeagent account Token Balance Plan: Pro Monthly tokens: 75,000 / 100,000 (25% used) Total remaining: 75,000 Resets: May 1, 2026
kubeagent account Token Balance Plan: Starter Monthly tokens: 2,000 / 10,000 (80% used) Total remaining: 2,000 Resets: May 1, 2026 ⚠ Low balance: 20% of monthly tokens remaining. Upgrade or buy extra credits: app.kubeagent.net/billing
Slack setup
When KubeAgent detects an issue, it sends a message to your Slack channel. With the in-cluster agent, Slack also receives approval requests: an action your allow-list refuses (or a rollback after a bad deploy) arrives with Approve and Deny buttons that open a dashboard review page. Only the account owner can decide, the link works once, and it expires after 24 hours. kubeagent watch on a laptop asks in its terminal instead.
Connect Slack
- Go to app.kubeagent.net → Settings → Notifications
- Click Connect Slack and authorize the KubeAgent app in your workspace
- Select the channel to post alerts to (e.g.,
#oncallor#infra-alerts) - Click Save
What you'll see
🔴 KubeAgent — Incident detected
Issue: pod_crash_loop on retime-api-worker-6b4d9
Root cause: OOM kill (heap 300Mi > limit 256Mi)
Approval needed: set_resources (memory 256Mi → 512Mi)
[ Approve ] [ Deny ]
Both buttons open the dashboard review page, which shows the exact action and parameters. The agent picks up the decision on its next check and runs only the approved action; every approval and run is audit-logged. With kubeagent watch the same request appears in the terminal instead, and headless runs deny it.
Discord setup
KubeAgent posts alerts to a Discord channel using an Incoming Webhook. No bot to install — just paste the webhook URL.
Connect Discord
- In Discord, open Server Settings → Integrations → Webhooks
- Click New Webhook, pick a channel (e.g.,
#infra-alerts), and copy the webhook URL - Go to app.kubeagent.net → Dashboard
- Paste the URL in the Discord card and click Connect
KubeAgent sends a test message to verify the webhook works. If you see a confirmation in your Discord channel, you're all set.
Microsoft Teams setup
KubeAgent sends alerts to Microsoft Teams using an Incoming Webhook connector.
Connect Teams
- In Teams, open the target channel and click ⋯ → Connectors (or Manage channel → Connectors)
- Search for Incoming Webhook and click Configure
- Give it a name (e.g., "KubeAgent") and copy the webhook URL
- Go to app.kubeagent.net → Dashboard
- Paste the URL in the Teams card and click Connect
KubeAgent sends a test message to verify the webhook works. If you see a card in your Teams channel, you're connected.
Telegram setup
Prefer Telegram? KubeAgent has a bot you can add to any group or use in a private chat for incident and recovery notifications.
Connect Telegram
- Go to app.kubeagent.net → Settings → Notifications
- Click Connect Telegram
- Start a chat with
@KubeAgentBotor add it to a group - Send the one-time verification code shown on the settings page
Approval requests
Approval requests from the in-cluster agent arrive here too, as a message with a link to the dashboard review page.
PagerDuty setup
KubeAgent integrates with PagerDuty using the Events API v2. Since KubeAgent is a custom integration, you need to add it manually to your PagerDuty service.
Connect PagerDuty
- Log in to your PagerDuty account.
- Navigate to Services → Service Directory.
- Select an existing service or click + New Service.
- Inside the service, click the Integrations tab.
- Click + Add another integration.
- Search for "Events API v2" and select it, then click Add.
- Copy the 32-character Integration Key.
- Paste it into app.kubeagent.net → Dashboard or run
kubeagent notify add.
How it works
KubeAgent triggers an incident for every detected issue. When the issue is resolved in your cluster (e.g., a pod stops crash-looping), KubeAgent automatically sends a resolve event to PagerDuty to close the incident.
Custom Webhooks
If none of the built-in integrations fit, KubeAgent can POST a JSON payload to any URL you provide — your own API, Zapier, n8n, or any webhook-compatible service.
Connect a Webhook
- Go to app.kubeagent.net → Dashboard
- In the Generic Webhook card, paste your endpoint URL
- Click Connect
Payload format
{
"issue": "pod_crash_loop",
"resource": "retime-api-worker-6b4d9",
"namespace": "prod",
"severity": "critical",
"diagnosis": "OOM kill (heap 300Mi > limit 256Mi)",
"proposedFix": "set memory limit to 512Mi",
"cluster": "hetzner-prod",
"timestamp": "2026-04-09T11:42:10Z"
}
KubeAgent sends a test POST when you first connect. Your endpoint should return a 2xx status to confirm delivery.
Run inside your cluster
The CLI on a laptop stops watching when the laptop sleeps. For 24/7 coverage, run the agent inside the cluster as a Deployment — it uses the pod's service account (no kubeconfig, no onboarding) and reports to the same dashboard and notification channels.
helm install kubeagent ./charts/kubeagent-agent \
--namespace kubeagent --create-namespace \
--set apiKey=<Agent-scope API key from app.kubeagent.net > API keys> \
--set clusterName=my-prod-cluster
kubectl create namespace kubeagent
kubectl -n kubeagent create secret generic kubeagent-agent \
--from-literal=api-key=<Agent-scope API key>
kubectl apply -f https://kubeagent.net/install/kubeagent-agent.yaml
Configuration is env-based: KUBEAGENT_CLUSTER_NAME (display name in alerts), KUBEAGENT_INTERVAL (seconds, default 300), KUBEAGENT_AUTO_FIX (false = read-only diagnosis; approval-gated actions are always denied in agent mode and surface as notifications), KUBEAGENT_SAFE_ACTIONS (comma list of actions auto-fix may run without approval; default restart_pod,rollout_restart; valid: restart_pod, rollout_restart, scale_deployment, set_resources; unknown names are ignored with a warning). set_resources (the OOMKilled fix) is off by default and is not auto-applied unless you list it. kubeagent agent install writes the allow-list for you: it uses your kubeagent onboard answer for that cluster (remediation.safe_actions), or the default plus a hint when the cluster was never onboarded; --safe-actions restart_pod,rollout_restart,set_resources overrides it (none = nothing runs unattended). With Helm set safeActions (--set 'safeActions={restart_pod,rollout_restart,set_resources}'). kubeagent agent status shows the active policy, and when the agent refuses an action by policy the notification names KUBEAGENT_SAFE_ACTIONS (Helm safeActions) and the exact value to set. kubeagent agent install --upgrade rolls the agent to the newest image keeping its settings (cluster name, interval, auto-fix policy, RBAC) and without a new API key; On a Helm-managed install --upgrade refuses and prints the helm upgrade <release> <the chart you installed from> --reuse-values --set image.pullPolicy=Always command for your release. The agent reports its version to the dashboard, which shows an update banner (and kubeagent agent status says "update available") when it is a minor or major version behind; you get one email per release, with an unsubscribe link. The Helm chart's rbac.readOnly=true value installs a read-only ClusterRole for teams that want zero write access. One replica per cluster — two agents would double-diagnose every incident.
Token control. Monitoring never calls a model: no log line and no healthy check reaches an LLM, and a diagnosis runs only when an incident is new or changed. Each issue gets a fingerprint (kind, namespace, owning workload, reason, restart bucket); an unchanged issue is not diagnosed again until a cooldown passes (KUBEAGENT_DIAGNOSE_COOLDOWN_HOURS, default 6). History and give-up state survive agent restarts in a ConfigMap named kubeagent-state in the agent's namespace (the agent's Role allows get and patch on that one name only). Each workload is diagnosed on its own so a routine warning does not use the strong model because of a critical issue elsewhere; a diagnosis is capped at KUBEAGENT_MAX_TURNS model round-trips (default 4) and at KUBEAGENT_MAX_DIAGNOSES_PER_TICK workloads per check (default 3). With KUBEAGENT_AUTO_FIX=false nothing is diagnosed automatically: you get one notification with the plain issue text, and you ask for a diagnosis when you want one (Slack "Diagnose with AI", or kubectl -n kubeagent exec deploy/kubeagent-agent -- kubeagent agent --once --diagnose).
Application signals (on by default). The agent ships two deterministic detectors that need no log access: ingress 5xx rate from Prometheus (KUBEAGENT_PROMETHEUS_URL, or in-cluster discovery) and a rollout-regression check that compares the 5xx rate and restarts after a new Deployment revision with the baseline before it. They cost zero AI tokens and are enabled by default; turn them off with kubeagent agent install --no-signals, Helm signals.enabled=false, or KUBEAGENT_SIGNALS=false. KUBEAGENT_ALERT_INTAKE=true (--alert-intake, Helm alertIntake.enabled with alertIntake.existingSecret) starts a receiver for Alertmanager webhooks (/alerts/alertmanager) and a generic JSON webhook (/alerts/generic); it needs a shared secret of 16+ characters in the X-KubeAgent-Secret header, is limited to Alertmanager pods by a NetworkPolicy, caps the body at 256 KiB and 60 requests a minute, and stays off by default. Onboarding asks about signals when it finds Prometheus in the cluster (default yes); without Prometheus the question is skipped but signals stay on — the rollout-restart check needs no Prometheus, only the 5xx check idles — and no answer is saved, so agent install follows (--signals / --no-signals override; a fresh install with no saved answer turns signals on). agent status shows the state. Signals add no RBAC and never read Secrets; the "what changed" context for a diagnosis lists only rollouts and ConfigMap changes in the namespace in the last 30 minutes.
Approvals. When policy refuses an action, or a bad rollout has a recorded previous revision, the owner gets an Approve/Deny request through the connected channels. The link opens a dashboard page that requires login, is limited to the owner, expires after 24 hours and works once. The agent picks up the decision on its next check and runs only the approved action with exactly the approved parameters; every approval and run is audit-logged. A rollback is kubectl rollout undo --to-revision=N to the recorded revision and runs only after approval.
KubeAgent can also detect kubelet node.fs approaching eviction pressure and attribute excessive ephemeral usage to visible pods, container writable layers/logs, or local-volume and other bytes not explained by containers. CLI checks use the current kubectl identity. The in-cluster agent does not collect it: Kubernetes has no stats-only API-server RBAC, and get nodes/proxy can reach other kubelet endpoints (including exec) while bypassing admission control, so the agent is never granted it. Existing checks continue when stats are unavailable.
KubeAgent also detects TLS certificate problems (cert_expiring), one issue per certificate: expired, cert-manager renewals that are late (renewalTime passed by over 1 hour) or not Ready (not during the first 10 minutes of a new Certificate), and certificates close to expiry. Expiry thresholds are 14 days (warning) and 3 days (critical) for a ~90-day certificate and shrink to 1/3 and 1/9 of the lifetime for short-lived ones (a 6-day or 24-hour certificate is not flagged while it is healthy). For cert-manager Certificates, closeness to expiry alone is not reported while a renewal is scheduled; a late or Ready=False one shows the blocking ACME challenge (type, state, age, reason). The agent needs read-only get/list on certificates and certificaterequests (cert-manager.io) and orders and challenges (acme.cert-manager.io); a cluster without cert-manager reports nothing, and a failed or forbidden read keeps the previous state instead of resolving open issues. Checking kubernetes.io/tls Secrets not managed by cert-manager is opt-in (kubeagent agent install --cert-secrets or Helm certificates.scanSecrets=true; --no-cert-secrets on upgrade turns it off) because it grants get/list on all Secrets: the API returns tls.key with each secret, but only tls.crt is requested (go-template), never tls.key. KUBEAGENT_CERT_CHECK_ENABLED=false (Helm certificates.enabled=false) disables the check and its RBAC. Certificate issues are never auto-fixed and never create approval requests.
CI/CD API
KubeAgent exposes a public API for use in GitHub Actions, GitLab CI, and other CI/CD pipelines. Authenticate with your API key (Bearer scheme).
POST /v1/checks/run
Submit a Kubernetes resource snapshot and get back health findings with an overall status (healthy, degraded, or critical).
curl -X POST https://api.kubeagent.net/v1/checks/run \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"resources": [...]}'
GET /v1/incidents
Query recent incidents for pipeline gate decisions. Use the since parameter to filter by time.
curl https://api.kubeagent.net/v1/incidents?since=2026-04-15T00:00:00Z \ -H "Authorization: Bearer YOUR_API_KEY"
API Documentation
Interactive docs and the full OpenAPI spec are available at:
api.kubeagent.net/v1/docs— interactive API explorerapi.kubeagent.net/v1/openapi.json— OpenAPI 3.0 spec
Knowledge base
The knowledge base (KB) is a set of Markdown files in ~/.kubeagent/kb/. The AI diagnoser loads them as system context before every diagnosis run.
What's in the KB
cluster.md— nodes, namespaces, cluster contextservices.md— your deployments, languages, frameworks, criticalitynotes.md— your answers from the onboarding interviewprojects/*.md— per-project code scan summaries
Editing the KB manually
All files are plain Markdown. You can edit them directly to add context the scanner missed — known quirks, deployment runbooks, escalation contacts.
# Service notes ## puffin - PHP 7.2 — do NOT upgrade to 7.3+, breaks Yii 1.x compat - High memory usage during campaign sends is expected - Scheduled jobs in "puffin" namespace are maintenance, not errors ## dove - OOM on dove-worker during large batch sends is a known issue - Escalate to #pakat-oncall, not #general
Re-running onboard
Run kubeagent onboard again at any time to refresh the KB. Your manual edits to notes.md are preserved.
Action safety tiers
Every action the diagnoser can take is classified into one of three tiers. This determines whether it runs automatically, requires your approval, or is never automated.
| Action | Tier | Description |
|---|---|---|
| get_logs | safe | Read pod logs — always automatic, no approval needed |
| describe_resource | safe | Describe any resource — always automatic |
| get_events | safe | Fetch namespace events — always automatic |
| restart_pod | allow-list · on | Delete and recreate a pod — automatic by default |
| rollout_restart | allow-list · on | Trigger a rolling restart — automatic by default |
| set_resources | allow-list · off | Raise CPU/memory values (raise-only, capped) — approval unless you allow it |
| scale_deployment | allow-list · off | Change replica count — approval unless you allow it; never to 0 |
| rollback_deployment | approval only | Roll back to the recorded previous revision after a bad deploy — never automatic, never offered to the model |
| Delete namespace, edit ConfigMap, apply manifest, etc. | unavailable | Outside KubeAgent's supported action surface |
Promoting actions to safe
Choose the allow-list during kubeagent onboard. For the in-cluster agent, override it with kubeagent agent install --safe-actions restart_pod,rollout_restart,set_resources (none = nothing runs unattended) or Helm safeActions; kubeagent agent status shows the active policy. For kubeagent watch, edit remediation.safe_actions in ~/.kubeagent/config.yaml.
llms.txt
KubeAgent publishes llms.txt — a standard that helps AI assistants like ChatGPT, Claude, and Perplexity understand what KubeAgent does and recommend it accurately.
/llms.txt— concise overview with links to key pages/llms-full.txt— complete documentation inlined for deep AI context/docs.md— markdown version of this docs page
/llms.txt and AI crawlers use it to accurately describe and recommend your product. Learn more at llmstxt.org.