Operate Kubernetes clusters via kubectl with a user-supplied kubeconfig (local file path or remote URL). This skill should be used when users want to inspect...
Memory
k8s-aiops
Try itUse this skill whenever the user needs to operate a Kubernetes cluster — list/inspect pods, deployments, statefulsets, daemonsets, replicasets, jobs, cronjobs, services, ingresses, endpoints, configmaps, secrets (names/keys only), PVCs/PVs/storageclasses, nodes, namespaces, and events; read pod logs; describe pods/nodes; pod/node top (metrics); read-only diagnostics / RCA (pod-health, workload-readiness); scale deployments/statefulsets; rollout status/history/undo/pause/resume and set image; delete pods/deployments/jobs; create/delete namespaces; and cordon/uncordon/drain nodes. Works with any kubeconfig-reachable cluster (standard Kubernetes, k3s, EKS, GKE, AKS). Always use this skill for "list k8s pods", "scale deployment", "kubernetes pod logs", "describe pod", "why is my pod crashing", "diagnose pods", "which deployments are unhealthy", "rollout undo", "set image", "top pods", "drain node", "cordon node", "restart deployment", "k3s", or "kubectl"-style tasks when the context is exp
What it does
Use this skill whenever the user needs to operate a Kubernetes cluster — list/inspect pods, deployments, statefulsets, daemonsets, replicasets, jobs, cronjobs, services, ingresses, endpoints, configmaps, secrets (names/keys only), PVCs/PVs/storageclasses, nodes, namespaces, and events; read pod logs; describe pods/nodes; pod/node top (metrics); read-only diagnostics / RCA (pod-health, workload-readiness); scale deployments/statefulsets; rollout status/history/undo/pause/resume and set image; delete pods/deployments/jobs; create/delete namespaces; and cordon/uncordon/drain nodes. Works with any kubeconfig-reachable cluster (standard Kubernetes, k3s, EKS, GKE, AKS). Always use this skill for "list k8s pods", "scale deployment", "kubernetes pod logs", "describe pod", "why is my pod crashing", "diagnose pods", "which deployments are unhealthy", "rollout undo", "set image", "top pods", "drain node", "cordon node", "restart deployment", "k3s", or "kubectl"-style tasks when the context is explicitly Kubernetes / a cluster. Do NOT use when the target is not a Kubernetes cluster (hypervisor VM lifecycle, backup products, or cloud-provider consoles are out of scope). Common Kubernetes operations with a built-in governance harness (audit, token budget, undo, risk-tier labels).
The skill document
k8s AIops
Disclaimer: This is a community-maintained open-source project and is not affiliated with, endorsed by, or sponsored by the Cloud Native Computing Foundation, the Kubernetes project, or k3s/Rancher. "Kubernetes" and "k3s" are trademarks of their respective owners. Source code is publicly auditable at github.com/AIops-tools/K8s-AIops under the MIT license.
Governed Kubernetes operations — 55 MCP tools, every one wrapped with the bundled @governed_tool harness: a local unified audit log under ~/.k8s-aiops/, a token/runaway budget guard, undo-token recording, and a descriptive risk-tier label on every audit row. Works with any kubeconfig-reachable cluster (standard Kubernetes, k3s, EKS, GKE, AKS). Run k8s-aiops init for a friendly onboarding wizard that registers your kube contexts as named targets.
Standalone: the governance harness is bundled in the package (
k8s_aiops.governance) — k8s-aiops has no external skill-family dependency. Coverage focuses on common operations and is not yet exhaustive.
What This Skill Does
| Category | Tools | Count | Read or Write |
|---|---|---|---|
| Pods | list, get, logs, describe, delete | 5 | 4 read / 1 write |
| Deployments | list, get, scale, rollout restart, delete | 5 | 2 read / 3 write |
| Rollout | status, history, undo, pause, resume, set-image | 6 | 2 read / 4 write |
| StatefulSets | list, get, scale | 3 | 2 read / 1 write |
| DaemonSets | list, get | 2 | 2 read |
| ReplicaSets | list | 1 | 1 read |
| Jobs / CronJobs | job list/get/delete, cronjob list/get | 5 | 4 read / 1 write |
| Services / Ingress / Endpoints | service list, ingress list/get, endpoints list | 4 | 4 read |
| Config / Secrets | configmap list/get, secret list (names/keys only) | 3 | 3 read |
| Storage | pvc list/get, pv list, storageclass list | 4 | 4 read |
| Nodes | list, describe, cordon, uncordon, drain | 5 | 2 read / 3 write |
| Namespaces | list, create, delete | 3 | 1 read / 2 write |
| Metrics (top) | pod, node | 2 | 2 read |
| Cluster | cluster_info, api_resources | 2 | 2 read |
| Events | list | 1 | 1 read |
| Diagnostics / RCA | pod-health, workload-readiness | 2 | 2 read |
Quick Install
uv tool install k8s-aiops
k8s-aiops init # friendly wizard: register your kube contexts as targets
k8s-aiops doctor # or skip init — works with your current kube-context too
When to Use This Skill
- List/inspect pods, deployments, services, nodes, namespaces and recent events
- Read a pod's recent log lines to diagnose a crash loop
- Run a read-only RCA sweep (
diagnose pod-health/diagnose workload-readiness) to find the root cause worst-first - Scale a deployment up/down, or trigger a rolling restart
- Delete a stuck pod (a controller recreates it) or a deployment
- Cordon a node before maintenance, then uncordon it after
Do NOT use when the target is not a Kubernetes cluster (hypervisor VM lifecycle, backup products, or cloud-provider consoles are out of scope for this skill).
Related Skills — Skill Routing
| If the user wants… | Use |
|---|---|
| Kubernetes pods / deployments / nodes | k8s-aiops (this skill) |
| Hypervisor VM lifecycle (power, snapshot, migrate) | a hypervisor ops skill |
| Backup & restore | a backup ops skill |
Common Workflows
Diagnose a crash-looping pod and restart its deployment
k8s-aiops pod list -n prod→ find the pod with highrestarts/ non-Runningphasek8s-aiops pod logs -n prod --tail 200→ read the recent logs for the crash causek8s-aiops events -n prod→ check forFailedScheduling/ image-pull eventsk8s-aiops deployment restart -n prod→ roll the deployment after fixing the cause- Failure branch: if logs/events show an RBAC
403, the kube context lacks the verb — runkubectl auth can-i get pods -n prodand switch to a context with adequate RBAC; the skill never retries a denied auth.
Triage an unhealthy namespace with RCA, then act on the worst finding
k8s-aiops diagnose pod-health -n prod→ worst-first findings; acriticalCrashLoopBackOffonprod/apicitesrestarts=9and the exactkubectl logs … --previousactionk8s-aiops diagnose workload-readiness -n prod→ confirm the blast radius: e.g.Deployment web ready 0/3(critical, under-replicated)k8s-aiops pod logs api- -n prod --tail 200 --previous-equivalent viak8s-aiops pod describe api- -n prod→ read the crash cause the RCA pointed you atk8s-aiops deployment restart web -n prod→ roll the deployment once the root cause is fixed- Failure branch: if
diagnosereturns an RBAC403, the kube context cannot list pods/deployments in that namespace — runkubectl auth can-i list pods -n prodand switch to a context with adequate RBAC; the RCA tools are read-only and never retry a denied auth.
Drain a node for maintenance, safely reversible
k8s-aiops node list→ identify the node and confirm it isReady/schedulablek8s-aiops node cordon --dry-run→ preview, thenk8s-aiops node cordon(double confirm) — records an inverseuncordon_nodeundo descriptor- After maintenance:
k8s-aiops node uncordon→ re-enable scheduling - Failure branch: if
doctorshows the cluster unreachable, fix the kubeconfig context (kubectl config get-contexts) before retrying — cordon is never issued against an unauthenticated session.
Usage Mode
| Scenario | Recommended | Why |
|---|---|---|
| Local/small models | CLI | fewer tokens than MCP |
| Cloud models (Claude, GPT) | Either | MCP gives structured JSON I/O |
| Automated pipelines | MCP | type-safe parameters, audited |
MCP environment caveat: MCP clients spawn the server with a CLEAN environment — shell exports may not reach it. Set
K8S_AIOPS_HOME,K8S_AUDIT_APPROVED_BY,K8S_AUDIT_RATIONALE(andKUBECONFIGwhen the kubeconfig is not at~/.kube/config) in the MCP server config'senvblock, not just in your terminal.
MCP Tools (55 — 39 read, 16 write)
| Category | Tools | R/W |
|---|---|---|
| Pods | pod_list, pod_get, pod_logs, pod_describe | Read |
delete_pod | Write | |
| Deployments | deployment_list, deployment_get | Read |
scale_deployment, rollout_restart_deployment, delete_deployment | Write | |
| Rollout | rollout_status, rollout_history | Read |
rollout_undo_deployment, rollout_pause, rollout_resume, set_deployment_image | Write | |
| StatefulSets | statefulset_list, statefulset_get | Read |
scale_statefulset | Write | |
| DaemonSets / ReplicaSets | daemonset_list, daemonset_get, replicaset_list | Read |
| Jobs / CronJobs | job_list, job_get, cronjob_list, cronjob_get | Read |
delete_job | Write | |
| Services / Ingress | service_list, ingress_list, ingress_get, endpoints_list | Read |
| Config / Secrets | configmap_list, configmap_get, secret_list (names/keys only) | Read |
| Storage | pvc_list, pvc_get, pv_list, storageclass_list | Read |
| Nodes | node_list, node_describe | Read |
cordon_node, uncordon_node, drain_node | Write | |
| Namespaces | namespace_list | Read |
create_namespace, delete_namespace | Write | |
| Metrics (top) | node_top, pod_top | Read |
| Cluster | cluster_info, api_resources | Read |
| Events | event_list | Read |
| Diagnostics / RCA | pod_health_rca, workload_readiness_rca | Read |
| Undo | undo_list | Read |
undo_apply | Write |
Security — secrets: secret_list returns secret names, types, and key NAMES only. Secret VALUES are never read, returned, or logged, and there is deliberately no tool that returns secret values.
Dry-run previews: every write tool takes dry_run: bool = False. A dry run returns a {"dryRun": true, "wouldX": ...} preview without touching the cluster, and no undo descriptor is recorded for a preview.
Harness features that light up: write tools with a clean inverse pass an undo= lambda so the harness records an inverse descriptor (with _undo_id) to the undo store — scale_deployment/scale_statefulset record a scale-back to their returned previous_replicas, set_deployment_image records a restore to the captured previous_image, cordon_node ↔ uncordon_node and rollout_pause ↔ rollout_resume are mutual inverses, and create_namespace records a delete_namespace. drain_node records a partial uncordon_node inverse (cordon is reversible; evictions are not). delete_* and rollout_undo_deployment declare no undo. risk_level=high: delete_deployment, delete_job, delete_namespace, drain_node, rollout_undo_deployment. undo_list (read) lists recorded reversible writes whose undo tokens have not been applied yet, and undo_apply (write) executes a recorded inverse — itself governed, single-use, and supports dry_run. All 55 tools are audit-logged under ~/.k8s-aiops/ and pass through the budget/runaway guard, each recorded with a descriptive risk-tier label. pod_top/node_top return a clear "metrics-server not installed" message (not an error) when metrics-server is absent. Avoid tight poll loops (re-listing pods every second) — the runaway breaker backs this up.
CLI Quick Reference
k8s-aiops init # interactive onboarding wizard
k8s-aiops pod list [-n ] [-t ]
k8s-aiops pod get [-n ]
k8s-aiops pod describe [-n ] # status, container states, events
k8s-aiops pod logs [-n ] [--tail 200] [-c ]
k8s-aiops pod delete [-n ] [--dry-run] # double confirm
k8s-aiops deployment list|get|scale|restart|delete ... # scale/restart: single confirm + --dry-run; delete: double confirm
k8s-aiops rollout status|history|pause|resume [-n ]
k8s-aiops rollout set-image [-n ]
k8s-aiops rollout undo [--to-revision N] [--dry-run] # double confirm
k8s-aiops statefulset list|get|scale ...
k8s-aiops daemonset list|get ...
k8s-aiops job list|get|delete ... # delete: double confirm
k8s-aiops cronjob list|get ...
k8s-aiops service list [-n ]
k8s-aiops ingress list|get [-n ]
k8s-aiops configmap list|get [-n ]
k8s-aiops secret list [-n ] # names/keys only — never values
k8s-aiops storage pvc-list|pvc-get|pv-list|class-list
k8s-aiops top pod|node # requires metrics-server
k8s-aiops node list|describe
k8s-aiops node cordon|drain [--dry-run] # double confirm
k8s-aiops node uncordon
k8s-aiops namespace list|create
k8s-aiops namespace delete [--dry-run] # double confirm
k8s-aiops cluster-info
k8s-aiops api-resources
k8s-aiops events [-n ]
k8s-aiops diagnose pod-health [-n ] [-l ] # read-only RCA: crashloop/imagepull/OOM/unschedulable/restarts
k8s-aiops diagnose workload-readiness [-n ] # read-only RCA: ready -n ` and switch to a context/ServiceAccount with adequate roles. For EKS/GKE/AKS, confirm the exec-plugin (aws/gcloud/az CLI) is installed and logged in.
### "Resource not found (404)"
The pod/deployment/node name or namespace is wrong, or the object was deleted. List the parent collection first (`pod list`, `deployment list`, `node list`) to get a current name. Remember most commands default to the `default` namespace unless `-n` is given.
### "Conflict (409)"
The object changed concurrently (or already exists). Re-read it and retry the write.
### Logs are empty or truncated
`pod logs` returns the trailing `--tail` lines (default 100); raise `--tail`. For a multi-container pod, pass `-c ` or the API returns an error naming the available containers.
## Audit & Safety
All operations are automatically audited via the bundled `@governed_tool` decorator (`k8s_aiops.governance`):
- Every tool call logged to `~/.k8s-aiops/audit.db` (local SQLite audit DB; relocate with `K8S_AIOPS_HOME`)
- Budget / runaway guard caps cumulative tool calls and wall-time, and trips on tight poll/retry loops — a safety backstop, not authorization
- Undo store records inverse descriptors for reversible writes (scale → previous replicas; cordon ↔ uncordon)
- Each write carries a descriptive risk-tier label into its audit row — a label, not a gate; `K8S_AUDIT_APPROVED_BY` / `K8S_AUDIT_RATIONALE` are optional annotations recorded when set, never required
**Authorization is not this tool's job.** There is no read-only switch, policy file, or approval gate. Whether a write is permitted is the agent's judgement or the RBAC of the kubeconfig context you connect with — give it a read-only ServiceAccount and writes fail at the apiserver, the place that owns the permission.
The harness is bundled in the package — no external dependency, no manual setup. See `references/setup-guide.md` for security details.
Driving these tools with a smaller / local model? See `references/agent-guardrails.md` — which guardrails the tool now enforces for you, plus a ready-to-paste system prompt.
## Contributing & feature requests
Coverage is intentionally focused. **Missing a device, action, or feature you need?** Open an issue or pull request at [github.com/AIops-tools/K8s-AIops](https://github.com/AIops-tools/K8s-AIops/issues) — feature requests, contributions, and comments are all welcome.
## License
MIT — [github.com/AIops-tools/K8s-AIops](https://github.com/AIops-tools/K8s-AIops)
Related skills
Use this skill whenever the user needs to operate a single container host through the Docker Engine API, Portainer, or Podman — a one-shot host overview; container reads (list/inspect, logs tail, CPU/memory stats, top processes, restart summary); image reads (list, inspect with history, dangling, disk usage); volume reads (list, inspect, dangling); network reads (list, inspect); system reads (info, version, df disk-usage, recent events); Portainer stacks + endpoints; Compose-project rollups (list_compose_stacks, docker+podman); Podman pods (list_pods, podman-only); three flagship analyses — restart-loop RCA (crash-looping containers + cause/action), resource-pressure analysis (CPU/memory vs limits), and image & volume bloat (prune candidates + reclaimable bytes); and eight guarded writes (restart/stop/start/remove a container, prune images/volumes, update resource limits, recreate a Portainer stack). Always use this skill for "Docker host overview", "which containers are crash-looping"
Use this skill whenever the user needs to operate or diagnose a Ceph cluster via its ceph-mgr Dashboard REST API — decode a HEALTH_WARN/ERR state into cause + action (cluster_health), read the cluster status, inspect OSDs (tree/df/perf), placement groups (summary/stuck/scrub), pools (list/usable capacity), RBD images and snapshots, CephFS/MDS and RGW status, monitors/managers, slow ops and capacity forecast — plus governed writes (set cluster flags, reweight/mark-in/mark-out/purge OSDs, trigger scrubs, set pool quota/pg_num/autoscale/size, create/delete pools, create/delete RBD images and snapshots, throttle recovery/backfill). Always use this skill for "ceph health", "what does this HEALTH_WARN mean", "PG_DEGRADED / OSD_NEARFULL / SLOW_OPS / MON_DOWN", "ceph -s", "which OSD is most full", "drain an OSD", "purge an OSD", "stuck PGs", "overdue scrub", "pool usable capacity", "set pool size / quota", "rebalance is too slow / throttle backfill", "RBD image or snapshot", "MDS behind on tri
Use this skill whenever the user needs to operate a GPU inference cluster — vLLM (OpenAI API + Prometheus /metrics) and Ray Serve / Ray Jobs (Ray dashboard), plus the single-process serving engines SGLang and TGI (Text Generation Inference): a one-shot cluster overview (deployments + total replicas + queue backpressure), request metrics (TTFT / TPOT / e2e latency + token totals), queue depth, KV-cache stats (utilisation, prefix-cache hit rate, preemptions), the flagship latency root-cause analysis (diagnose_latency_spike / diagnose_engine_latency) and low-utilisation RCA, engine-agnostic health + running-model inventory across vLLM/SGLang/TGI, Ray Serve autoscaling and scaling (scale up/down, scale-to-zero, drain a replica), LoRA load/unload, base-model hot-swap, deploy/undeploy/redeploy, prefix-aware routing, GPU utilisation, Ray jobs, and cost per million tokens. Always use this skill for "why is inference slow", "TTFT spike", "latency spike", "GPU underutilised", "scale down the dep
Kubernetes operations plugin — 32 tools for cluster management, monitoring, troubleshooting, and security auditing
Use this skill whenever the user needs to operate a self-hosted observability stack on Prometheus (HTTP API + PromQL), Alertmanager, Grafana, or Grafana Loki (logs) — a one-shot overview, PromQL instant/range queries, label + series metadata, scrape-target health (up/down + why) and dropped targets, recording/alerting rule health, firing/pending alerts, Alertmanager alerts + silences, Grafana dashboards/datasources/folders, bounded Loki LogQL log reads (labels, query, error-tail), five flagship analyses (firing-alert RCA, target-scrape-health, alert-noise/flap, log-error-burst RCA, log-volume/cardinality) plus an alert->log cross-signal, and guarded writes (create/expire silence, create annotation, update/delete dashboard, reload Prometheus config). Always use this skill for "Prometheus", "PromQL", "Alertmanager", "Grafana", "Loki", "LogQL", "logs", "which targets are down", "scrape failing", "why is this alert firing", "root cause this alert", "firing alerts", "silence this alert", "n