kx is a kubectl wrapper that adds index-based resource selection. Run
kx get <resource> once, then reference any result by number instead of typing
full resource names.
Install
Requires kubectl on your PATH. Every install path delivers the same prebuilt
binary — no Python runtime, no dependencies.
With uv (recommended), pipx, or pip:
uv tool install kx-cli
pipx install kx-cli
pip install kx-cli
As a kubectl plugin via krew, where kx is published as idx:
kubectl krew install idx
alias kx="kubectl idx"
Or run it without installing — the package is kx-cli, the command is kx:
uvx --from kx-cli kx get pods
pipx run --spec kx-cli kx get pods
Standalone binaries for linux, macOS and Windows are attached to every GitHub Release.
Usage
A kx session at a glance — one listing, then everything after it by number.
kx get pods # lists pods, numbering each row
kx logs 3 # the third pod
kx diag 3 # why it's unhealthy
Indexes come several at a time, as ranges, or narrowed.
kx delete 3 5 # several at once
kx delete 3..7 # an inclusive range, walking either direction
kx delete ..5 # open at the start
kx delete 5.. # open to the end of the listing
kx get pods -m api # --match/-m filters rows by name substring
kx get pods -n prod -l app=api # anything else passes through to kubectl
-A listings are indexed too: each row records its own namespace, so
kx describe 7 reaches a resource in a namespace you aren't in, and two pods
sharing a name keep separate numbers.
Known kinds can drop the get — kx pods, kx deploy -n kube-system,
kx svc -m api — kubectl's shorthands and your CRDs included. A CRD resolves
from kubectl's on-disk discovery cache, with no API call.
--watch/-w redraws the table in place, rather than appending lines the way
kubectl -w does.
kx completion <bash|zsh|fish|powershell> completes indexes with the resource
behind them, so kx describe <TAB> offers 1 api-7d8f (Pod) rather than a
bare number.
Triage a namespace
Bare kx diag sweeps the current namespace — every workload kind, plus
Services, PVCs, Ingresses and pods nothing owns — and ranks what's unhealthy.
It reads live usage too, so a pod running hot against its memory limit is
flagged as an OOMKill risk before it dies.
kx diag <index> diagnoses a single resource: a top level verdict, a findings
summary, a per-pod status table, log tails from broken containers and warning
events — one screen instead of four kubectl commands.
Read a Secret in plaintext
kx secret <index> --decode prints an indexed Secret's keys and values decoded.
--key/-k prints a single value raw — no banner, no wrapping — so it drops
straight into a shell.
export PGPASSWORD=$(kx secret 1 --decode -k password)
Bare kx secret --decode decodes every Secret in the namespace in one call,
confirming first — that prints every credential you have.
Scan images for CVEs
kx scan <index> scans the unique container images of an indexed workload.
Bare kx scan sweeps every workload in the namespace. Results come back as a
severity summary, or the full per-image CVE report with --full.
Requires the CLI for the selected engine — Docker Scout
by default, or Trivy and
Grype via kx engine.
See what owns what
kx tree <index> walks the ownership graph — Deployment to ReplicaSet to Pods —
and indexes every node it draws, so anything in the tree is one number away.
Bare kx tree graphs the whole namespace.
Reports in the browser
--html on kx diag, kx scan, kx tree, and kx top renders the same
analysis as a page and opens it in your browser. It binds 127.0.0.1 only and
writes nothing to disk.
The page is drawn in your active theme. Sweep rows expand into that resource's full report, image rows into the CVEs behind their counts — detail the terminal has no room for.
--out <path> writes the page to a file instead of serving it, which is what
you want in CI — kx diag --out report.html is the whole command.
Use kx in CI
--fail-on <severity> turns a sweep into a build gate, and --json prints the
same analysis as a document for anything downstream.
kx diag -A --fail-on critical # 0 if the cluster is healthy, 2 if not
kx scan -A --fail-on high # the same, for image vulnerabilities
kx scan -n prod --fail-on high --json | jq '.images[] | select(.counts.critical > 0)'
kx diag -A --fail-on critical --out report.html # publishes the report *and* fails the build
kx diag -A --fail-on warning --since 24h # ignore what failed before today
--since bounds how far back the report looks — a warning event, an OOMKill a
container recovered from, a pod or run that failed. Without it a failure from
last month holds the gate red forever. Whatever is still going wrong — a
CrashLoopBackOff, a Pending pod — is reported either way. Set the window once
with diag_max_age in config.toml, or KX_DIAG_MAX_AGE in the job's
environment.
kx events and kx logs take --since too. kx events has a key of its own,
events_max_age / KX_EVENTS_MAX_AGE, and it does not affect kx diag —
narrowing the evidence behind a verdict is not a request for a shorter event
listing. Neither key falls back to the other.
Exit 2 means findings breached the threshold, 1 means kx itself failed — so a pipeline can tell "the cluster is sick" from "the check never ran".
State and history
kx keeps up to 10 kx get results in ~/.kx/state.json, with a cursor
marking the entry indexes resolve against.
kx state # the listing indexes currently resolve against
kx state --all # the whole history, with positions
kx state 2 # jump to position 2
kx state back # step back one (forward steps the other way)
kx state drop 2 # remove position 2 (--all clears everything, slots included)
Each entry remembers the context it was listed in, so a staging index is never
resolved against production — kx refuses and relists instead. KX_STATE
points kx at a different state file, so a second terminal keeps its own history.
Configuration
kx reads ~/.kx/config.toml, and every setting takes a KX_* environment
override. The two worth changing have commands of their own — kx theme and
kx engine both persist your choice.
Styling is dropped when stdout isn't a terminal, so kx get pods | grep worker
stays clean. NO_COLOR is honored too.
Themes
kx theme lists the available themes with a preview of each. kx theme <name>
persists your choice, by name or index.
Eleven prefabs ship with it: github-dark (default), dracula, nord,
gruvbox, solarized-dark, catppuccin-mocha, tokyo-night, rose-pine,
mono, light and plain.
Commands
| Command | Description |
|---|---|
kx annotate <index> [<key=value>...] |
Set or remove annotations on an indexed resource. |
kx annotations <index>... |
Show annotations for one or more indexed resources. |
kx context [<index>] |
List kubeconfig contexts, or switch to an indexed one; alias: kx contexts. |
kx cordon <index>... |
Mark one or more indexed Nodes unschedulable. |
kx cp <src> <dest> |
Copy files to or from an indexed pod via kubectl cp. |
kx debug <index> [<command>...] |
Open a debug shell on an indexed Pod (an ephemeral container, for images with no shell) or Node (a privileged pod on the host). |
kx delete <index>... |
Delete one or more indexed resources (prompts for confirmation unless --yes). |
kx describe <index>... |
Show full kubectl describe output for one or more indexed resources. |
kx diagnostic [<index>] |
Diagnose an indexed Deployment, StatefulSet, DaemonSet, Job, CronJob, Service, PersistentVolumeClaim, Ingress, Pod, or Node, or triage a whole namespace when no index is given (-n to pick one, -A for every namespace); alias: kx diag. |
kx drain <index> |
Evict the pods from an indexed Node (prompts for confirmation unless --yes). |
kx edit <index> |
Open an indexed resource in your editor via kubectl edit. |
kx events <index>... |
Show Kubernetes events for one or more indexed resources. |
kx exec <index> [<command>...] |
Open an interactive shell in an indexed Pod, Deployment, ReplicaSet, StatefulSet or DaemonSet (bash, falling back to sh). |
kx get <resource> [<index>...] |
List resources and assign index numbers for use with other commands; shorthand: kx (e.g. kx pods, kx po 3). |
kx label <index> [<key=value>...] |
Set or remove labels on an indexed resource. |
kx labels <index>... |
Show labels for one or more indexed resources; --selector formats output as a label selector. |
kx logs <index>... |
Stream logs for an indexed resource; aggregates across pods for Deployments, StatefulSets, DaemonSets, and Services. |
kx namespace [<index>] |
List namespaces, or switch to an indexed one; alias: kx ns. |
kx port-forward <index> <port> |
Forward a local port to an indexed resource (Pod, Deployment, ReplicaSet, StatefulSet, DaemonSet, Service). |
kx rollout <action> <index> |
Run a rollout action (status, restart, pause, resume, history, undo) on a Deployment, StatefulSet, or DaemonSet. |
kx scale <index> <replicas> |
Scale an indexed Deployment, StatefulSet, or ReplicaSet to a given replica count. |
kx scan [<index>] |
Scan the unique container images of an indexed workload for vulnerabilities, or a whole namespace when no index is given (-n to pick one, -A for every namespace); prints a severity summary table by default, or the raw scanner output with --full. Requires the CLI for the selected scan engine (Docker Scout by default; Trivy or Grype via --engine — see kx engine). |
kx secret [<index>...] |
List Secrets like kx get, or show an indexed Secret's data with --decode; alias: kx secrets. |
kx top [<resource>] |
List CPU/memory usage for pods (default) or nodes and assign index numbers, like kx get; shows usage as a percent of limits (pods) or capacity (nodes) unless --no-limits. |
kx tree [<index>] |
Show the ownership graph for an indexed resource, or the whole current namespace when no index is given (-n to pick one, -A for every namespace); assigns indexes to tree nodes by default. A Namespace index graphs that namespace. |
kx uncordon <index>... |
Mark one or more indexed Nodes schedulable again. |
kx yaml <index>... |
Print the raw YAML manifest for one or more indexed resources; --show filters to specific top-level fields. |
kx state [<position>] |
Show current state, jump to a history position, list all entries with --all, or expand the switch targets with --targets. |
kx engine [<name>] |
List available scan engines or persist a default choice by name or index. |
kx theme [<name>] |
List available color themes or persist a choice by name or index. |
kx completion |
Generate a shell completion script for kx (bash, zsh, fish, powershell). |
Development
Go, at the version pinned by the go directive in go.mod. Nothing else is
required to build or run.
go build ./...
go run ./cmd/kx --help # run the CLI directly
gofmt -l ./cmd ./internal ./tools # must print nothing
go vet ./...
go test -race ./...
pre-commit run --all-files runs gofmt and go vet, and regenerates the command
table above from the command tree — it fails if the table has drifted from the
commands it documents. Tests are not in the hook — run them yourself.
The demo GIFs are rendered from VHS
tapes — see demo/README.md for seeding the demo namespace
and re-recording.
Metadata
Release files for kx-cli 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| kx_cli-0.5.2-py3-none-win_arm64.whl | Python 3 | none | Windows ARM64 | Details |
| kx_cli-0.5.2-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| kx_cli-0.5.2-py3-none-musllinux_1_2_x86_64.whl | Python 3 | none | Linux musl 1.2+ x86-64 | Details |
| kx_cli-0.5.2-py3-none-musllinux_1_2_aarch64.whl | Python 3 | none | Linux musl 1.2+ ARM64 | Details |
| kx_cli-0.5.2-py3-none-manylinux_2_17_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| kx_cli-0.5.2-py3-none-manylinux_2_17_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| kx_cli-0.5.2-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| kx_cli-0.5.2-py3-none-macosx_10_9_x86_64.whl | Python 3 | none | macOS 10.9+ x86-64 | Details |
Total release size: 410.6 MB
Release files / kx_cli-0.5.2-py3-none-win_arm64.whl
| Download URL | kx_cli-0.5.2-py3-none-win_arm64.whl |
|---|---|
| Size | 49.6 MB |
| Tags | Python 3 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
b868d972ce4d9b4b57812621226237f579bffb3c80cfd0f5f569ce424119775e
|
|
BLAKE2b-256 checksum How to use checksums |
bad290938670d8fd679cc7521cc7fa62891ad340e3840b53ab0b912957c1b7b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / kx_cli-0.5.2-py3-none-win_amd64.whl
| Download URL | kx_cli-0.5.2-py3-none-win_amd64.whl |
|---|---|
| Size | 53.8 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
dce54f294769da3430aa4799dd42d6c31f38054d4e6d47da739339762b6129f3
|
|
BLAKE2b-256 checksum How to use checksums |
8a93d909c5fece2302621bd4a242f271bdb24e4f040580cf94a14ba91dadf787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / kx_cli-0.5.2-py3-none-musllinux_1_2_x86_64.whl
| Download URL | kx_cli-0.5.2-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 52.5 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
676f3cc9c1bc69c02119cad47a3a7c9278d27a9b1834cf3546090aab4d0b6655
|
|
BLAKE2b-256 checksum How to use checksums |
7fb9db4db96629e5d7209057739408bdc5a3c29a7e2f16b86257cec073929c1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / kx_cli-0.5.2-py3-none-musllinux_1_2_aarch64.whl
| Download URL | kx_cli-0.5.2-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 49.1 MB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
f937a2366265fa3f5d2e87189ffd06d2c0853ffce79df3a4038c582df7949474
|
|
BLAKE2b-256 checksum How to use checksums |
19d8c71d8f59a4646dcbbe50881a95eae8f682e17b7b7a6f84823f04f6f81d78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / kx_cli-0.5.2-py3-none-manylinux_2_17_x86_64.whl
| Download URL | kx_cli-0.5.2-py3-none-manylinux_2_17_x86_64.whl |
|---|---|
| Size | 52.5 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
2d3e5addafa8eb5af0e3734c58423a3ccf5f7c3ac2e0cdebcdddbcd2c16e67be
|
|
BLAKE2b-256 checksum How to use checksums |
ff2bbf4d4279ee75bf0ce2b8be33b8718836fa3eb27da83ba682e3e7e81bff5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / kx_cli-0.5.2-py3-none-manylinux_2_17_aarch64.whl
| Download URL | kx_cli-0.5.2-py3-none-manylinux_2_17_aarch64.whl |
|---|---|
| Size | 49.1 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
e0642297503ed35ada114b59bacc0e4c77e399906c75b9e752b72bf5489656da
|
|
BLAKE2b-256 checksum How to use checksums |
ad1c74f69e30e500774352c0ba6aa9514b0cc17db67e8b21912408f739aa766c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / kx_cli-0.5.2-py3-none-macosx_11_0_arm64.whl
| Download URL | kx_cli-0.5.2-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 50.5 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
24b025d03175b392107c89da6c8aa50155802750456e44e14fcf63a41825b61a
|
|
BLAKE2b-256 checksum How to use checksums |
aaaf31aebf283395d2a114c59e2edd36c7690b360f9a11201809758865cf36aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / kx_cli-0.5.2-py3-none-macosx_10_9_x86_64.whl
| Download URL | kx_cli-0.5.2-py3-none-macosx_10_9_x86_64.whl |
|---|---|
| Size | 53.6 MB |
| Tags | Python 3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
31d7157f309c9e9720ac5e60a8c0d81eaf32a0acd468d35ee145e3043606b1f4
|
|
BLAKE2b-256 checksum How to use checksums |
60fb6bd556a65debf4e15719cd8e394bee33a082b3a3de174dd7312228a53959
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for kx-cli 0.5.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.