Skip to main content

kubectl wrapper with index-based resource selection

Project description

kx

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

pip install kx-cli

Usage

List resources

kx get <resource> [-n <namespace>]

Fetches resources and assigns index numbers. Omitting -n uses the current context namespace.

$ kx get pods
X  NAME                          READY  STATUS   RESTARTS  AGE
1  api-7d9f4b8c6-xkp2q           1/1    Running  0         2d
2  worker-6c8b5f7d9-mnt4r        1/1    Running  3         5h
3  postgres-0                    1/1    Running  0         12d

All subsequent commands reference resources by their X index from the last kx get.

Commands

Command Description
kx get <resource> [-n ns] List resources with index numbers
kx describe <index> Show kubectl describe output for an indexed resource
kx events <index> Show Kubernetes events for the resource
kx logs <index> Stream logs for a pod
kx yaml <index> Print the raw YAML manifest
kx exec <index> [cmd] Open an interactive shell in a pod (bash → sh fallback); pass a custom command with cmd
kx edit <index> Open the resource in your editor via kubectl edit
kx delete <index> [-y] Delete the resource (prompts for confirmation; -y skips it)
kx tree <index> Show the ownership graph for a resource
kx port-forward <index> <port> Forward a local port to a resource (supports Pod, Deployment, ReplicaSet, StatefulSet, DaemonSet, Service)
kx state Show the current state (last kx get result) as JSON

Example workflow

# list deployments, pick index 2
kx get deployments
kx describe 2

# check events on that deployment
kx events 2

# drill into a pod
kx get pods
kx logs 1
kx exec 1            # opens bash/sh
kx exec 1 -- env     # run a specific command

# forward local port 8080 to port 80 on a service
kx get services
kx port-forward 2 8080:80

# clean up
kx delete 3

State

kx saves the last get result to ~/.kx_state.json. Index-based commands read from this file, so switching namespaces or resource types requires a new kx get.

Development

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Run the CLI directly:

python -m kx.main --help

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kx_cli-0.0.2.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kx_cli-0.0.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file kx_cli-0.0.2.tar.gz.

File metadata

  • Download URL: kx_cli-0.0.2.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for kx_cli-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c44cb6fb300208eeaeca34b8bf34560131a86f0320f9b14191fa45512f113367
MD5 1743edfc467c42a36a3d4a5f84c93bba
BLAKE2b-256 77e2454684f6f29a2bb71fde9670fcac10db245e6828e640be9b60866eb15f69

See more details on using hashes here.

File details

Details for the file kx_cli-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: kx_cli-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for kx_cli-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b6021f8e09f3509c3f36661399b94b41dc9725a5b33bc494256eb02774ad4029
MD5 04baa46b793e904bcf9b28cd6d8c4fa2
BLAKE2b-256 e8396ff6a944cab09f9e62e2d1573e3a2d8d8b792f7da748609f6e532df742c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page