Skip to main content

kube-query

kube-query — read-only Kubernetes queries for humans and AI agents.

kubectl is a loaded gun in an agent's hands. kube-query is the safe scope: it captures cluster state and diagnoses problems, and cannot create, update or delete anything — the HTTP layer implements GET and nothing else. Compact YAML by default, with rich tables, markdown, JSON and ownership trees on request. Built-ins, shortnames, CRDs, Helm releases and External Secrets Operator — one small, fast binary-ish CLI.

kube-query p l -A                    # all pods, all namespaces
kube-query p desc web-5d9c6 -n prod  # status + reasons + restarts + events, one doc
kube-query logs web-5d9c6 -n prod -c app --previous
kube-query tree deploy/web -n prod   # Deployment -> ReplicaSet -> Pods, health per node
kube-query overview                  # whole-cluster snapshot, problems first

kube-query is the diagnosis half of the loop. The fix half belongs to other tools (kubectl apply, gitops, helm) — by design.

Why

Problem with kubectl for agents kube-query
can delete/scale/apply — one hallucinated flag away from an incident GET-only; no mutating code path exists
-o yaml dumps managedFields/uid/annotations noise into context compact by default, -v/-vv for more
output shaped for terminals, not reasoning yaml/json data, md reports, tree views
100+ verbs to misuse ~15 read verbs with short aliases (p l, d l, c l)
helm/ESO/CRD troubleshooting needs extra tools helm releases, ESO status and CRDs built in

Install

Requires Python 3.13+. The PyPI package is kube-query and it installs a single command: kube-query. (There is deliberately no short kq executable — that name on PyPI belongs to an unrelated Kafka library, and PyPI's similarity rules block close variants like kubeq. Alias it if you want it short: alias kq=kube-query.)

uvx kube-query overview             # one-off, no install
uv tool install kube-query          # permanent
pipx install kube-query             # alternatives
pip install kube-query

kube-query ctx ls                   # verify — reads your existing kubeconfig
alias kq=kube-query                 # optional short form

From source:

git clone https://github.com/stivio00/kube-query && cd kube-query
make setup                          # .venv (py3.13) + dev deps
.venv/bin/kube-query overview

No cluster to try it on? make demo boots a fake API server with broken pods, a stuck deployment, helm releases and ESO resources to poke at.

Commands

Command (aliases) Purpose
kube-query overview (ov, o, health) cluster snapshot: problem pods, nodes, deployments, PVCs, warnings
kube-query pod (pods, p, po) l [REGEX] [-A|-n|-l|--field-selector] · NAME · desc NAME · logs NAME
kube-query deploy (deployments, dep, d) same shape for deployments
kube-query ns (n) · kube-query node (no) · kube-query svc · kube-query cm namespaces, nodes, services, configmaps
kube-query crd (crds) CRDs installed in the cluster (group, kind, Established)
kube-query secret (sec) values hidden; kube-query sec NAME --reveal decodes (explicit opt-in)
kube-query ev (events, e) events, newest first: --type Warning --since 2h --for pod/NAME
kube-query get RESOURCE[/NAME] (g) any resource incl. CRDs; kube-query api lists all types
kube-query describe (desc) diagnosis bundle: summary + object + children + events
kube-query tree RESOURCE/NAME (t) ownership tree (deploy/web, cronjob/x, node/y)
kube-query helm (h) releases read-only from Helm's release Secrets; show NAME adds values
kube-query eso ExternalSecret sync status (--stores for SecretStores)
kube-query argo (argocd) Argo CD Applications: health + sync
kube-query ctx (c) kubeconfig contexts (kube-query c l), no API calls
kube-query ver client + server version (which cluster am I on?)

Shared flags: -n NS · -A · -l SELECTOR · --field-selector · -f/--filter REGEX · -o yaml|json|rich|md|tree (default yaml, KQ_OUTPUT env) · -v/-vv.

Output

kube-query overview -o rich      # aligned, colored tables (humans)
kube-query p l -A -o md          # markdown tables (tickets, chat, agent reports)
kube-query p web-5d9c6 -o json   # machine-readable
kube-query d l -o tree           # ownership view

Stdout is always the payload (parseable); commentary goes to stderr as #-prefixed notes. Exit codes: 0 ok, 1 error (one actionable sentence), 2 usage.

For AI agents

Give your agent (Claude Code, opencode, codex, …) the one-file skill: SKILL.md — command map, the 5-move triage loop, output contract, failure-signature table, and rules of engagement. Suggested system-prompt line:

Use kube-query (read-only) to inspect the Kubernetes cluster: start with kube-query overview, then kube-query p desc <pod>, kube-query logs, kube-query tree, kube-query ev. Never attempt cluster changes with kube-query; propose them for kubectl instead.

Documentation

Doc Contents
docs/usage.md full manual: every command, flag, format, exit code
docs/tutorial.md hands-on: debugging a broken deployment end-to-end
docs/architecture.md module map + data flow diagrams
docs/extending.md add commands, columns, formats (with examples)
docs/roadmap.md what's next + explicit non-goals
CHANGELOG.md releases

Development

make setup          # venv + deps
make check          # the full gate: ruff lint + format check + pytest + build
make demo           # fake-cluster playground
make tag            # run the gate, then create v<version> tag
git push origin vX.Y.Z   # CI publishes to PyPI (trusted publishing)

Pipeline: make check mirrors CI exactly; pushing a v* tag runs the same gate, builds sdist+wheel, verifies tag/version match, and publishes via GitHub Actions to PyPI — no stored secrets (OIDC trusted publishing).

Tests are network-free: unit suites plus smoke tests that drive the real CLI against an in-process fake Kubernetes API server.

Safety model

  1. kube_query/http.py exposes raw_get only — there is no verb parameter anywhere.
  2. kube_query/access.py builds list/get/log paths only.
  3. Secret values are redacted unless --reveal is passed explicitly.
  4. Your RBAC still applies — kube-query reads exactly what your credentials allow.

License

MIT — see LICENSE.

Metadata

Release files for kube-query 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kube-query 0.2.0
File Size Uploaded Provenance Actions
kube_query-0.2.0.tar.gz 53.9 kB With provenance Details for kube_query-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kube-query 0.2.0
File Interpreter ABI Platform Actions
kube_query-0.2.0-py3-none-any.whl Python 3 none any Details for kube_query-0.2.0-py3-none-any.whl

Total release size: 110.7 kB

Release files / kube_query-0.2.0.tar.gz

Download URL kube_query-0.2.0.tar.gz
Size 53.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8ce6b5038610142c1fd60fb28dfcf5bf56d4061debe83bc52146780cd8a07418
BLAKE2b-256 checksum
How to use checksums
9c1478c2cd73d6f81c259ada482390ff8ffa5976fa45c699c0287716910fe052
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / kube_query-0.2.0-py3-none-any.whl

Download URL kube_query-0.2.0-py3-none-any.whl
Size 56.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bee61151584a66689b15f0280e39cc5d3866edd649a29fb87b604903799a8ec
BLAKE2b-256 checksum
How to use checksums
5b2889b7361bd31b4b018d906c85e1317b9381208dc3bd82ea06c4b9af925b78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for kube-query 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kube_query-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page