Skip to main content

The kuba-mazing kubectl companion

Project description

Kuba

The kuba-mazing kubectl companion with fzf, fx, aliases, and more!

Kuba logo

Features

Kuba demo

  • ☁️ Fuzzy commands like get, describe, logs, exec
  • 🧠 Guess pod containers automagically, no more typing -c <container-name>
  • ✈️ Cross namespaces and clusters in one command, no more for loops
  • Cut down on keystrokes with an extensible alias language, e.g. kpf to kuba get pods -o json | fx
  • 🧪 Simulate scheduling without the scheduler, try it with kuba sched
  • 🔁 And lots more!

Install

Quick-install:

pip install kuba

Kuba makes use of the following tools you'll likely want to install as well: fzf, fx, kubecolor, and krew for stern and lineage. On macOS, you can install these tools with Homebrew:

brew install fzf fx kubecolor krew && kubectl krew install stern lineage

To use the aliases, add this to one of your dotfiles:

source <(kuba shellenv --kubectl kubecolor)  # omit --kubectl kubecolor if you haven't installed kubecolor

Usage

Start by using kuba get and kuba describe as a ~drop-in replacements for kubectl get and kubectl describe. Then try a few examples from the overview video, or check out the commands below.

Help pages

$ kuba --help
Usage: kuba [OPTIONS] COMMAND [ARGS]...

  The kuba-mazing kubectl companion.

Options:
  -h, --help  Show this message and exit.

Commands:
  api       Shadow of `kubectl api-resources` but with optional fzf for resource selection.
  cluster   Shadow of `kubectx` and `kubens` for all-in-one switching between logical clusters.
  ctx       Shadow of `kubectx` for context switching.
  describe  Shadow of `kubectl describe` but with optional fzf for resource selection.
  exec      Shadow of `kubectl exec` but with optional fzf for pod and container selection.
  get       Shadow of `kubectl get` but with optional fzf for resource selection.
  logs      Shadow of `kubectl logs` but with optional fzf for pod and container selection.
  ns        Shadow of `kubens` for namespace switching.
  sched     Predict which nodes a pod can be scheduled on.
  shellenv  Generate k-aliases and completions for easy kubectl resource access.
  ssh       Shadow of `ssh` for connecting to a node, with optional fzf for node selection.

Alias language

$ kuba shellenv --help
Usage: kuba shellenv [OPTIONS]

  Generate k-aliases and completions for easy kubectl resource access.

  E.g. kp for kubectl get pod.

  Generated aliases all forward to kuba, which eventually forwards to kubectl, including any kubectl-specific
  parameters. Passing kubectl arguments and shell completion both have some rough edges.

  GENERAL

  - kns => kuba ns
  - kctx => kuba ctx (suffixes: l=list, n=ns)
  - kclus => kuba cluster
  - kssh => kuba ssh (suffixes: a=any, p=pods)
  - kapi => kuba api (suffixes: n=name, z=select)
  - ksys => kuba ns kube-system

  RESOURCE-LEVEL

  Default native resource mappings:
  - c=configmap
  - d=deployment
  - j=job
  - m=daemonset
  - n=node
  - o=cronjob
  - p=pod
  - r=secret
  - s=service
  - x=lease

  Alias modifiers, optional and in this order:
  - Search in (a)ll namespaces or (k)ube-system namespace
  - Search across (m)ultiple sibling clusters
  - Restrict to objects e(x)clusively holding a lease
  - Force selection using f(z)f or force (p)icking all
  - Choose an alternative output type:
      - (d)escribe
      - (n)ame
      - (w)ide
      - (y)aml
      - (j)son
      - (f)x
      - lo(g)s
      - follow (l)ogs
      - lineage downward i.e. (c)hildren
      - lineage (u)pward
      - p(o)ds (only for nodes, shows pods on the node)

  Example alias usage:
  - kp -> kuba get pod
  - kpw -> kuba get pod -o wide
  - kpz  -> kuba get pod (fzf multi-select over all pods)
  - kpzf myapp -> kuba get pod --select -o json | fx (fzf multi-select over all pods fuzzy matching 'myapp')
  - kxd -> kuba describe lease
  - kny -> kuba get node -o yaml
  - kdj -> kuba get deployment -o json
  - ksz -> kuba get service (fzf multi-select over all services)
  - kjf -> kuba get job -o json | fx
  - kcaj -l app=myapp -> kuba get configmap --all-namespaces -o json -l app=myapp

  CONTAINER-LEVEL

  Default kuba aliases:
  - l=logs
  - e=exec

  Alias modifiers, optional and in this order:
  - Search in (a)ll namespaces or (k)ube-system namespace
  - Search across (m)ultiple sibling clusters
  - Restrict to objects e(x)clusively holding a lease (via convenience heuristic)
  - Choose (c)ontainers, or automatically pick a(l)l containers
  - Command-specific
      - logs: (f)ollow logs

  Example alias usage:
  - kl -> kuba logs --guess
  - ke -> kuba exec --guess
  - klx -> kuba logs --leader --guess
  - kexc -> kuba exec --leader
  - klamlf -> kuba logs --all-namespaces --multi-cluster --all --follow

  Usage: source <(kuba shellenv [OPTIONS])

Options:
  --resources TEXT    Add or override resource mappings, formatted as e.g. p=pod,n=node. Can also set via
                      KUBA_SHELLENV_RESOURCES env var.
  --clusters TEXT     List of clusters to consider, formatted as e.g. k1=v1,k2=v2 (use '*' to match multiple
                      clusters). Can also set via KUBA_CLUSTERS env var.
  --shell [|zsh]      Override shell detection.
  --kubectl TEXT      Name or path of the kubectl binary to use. Can also set via KUBA_KUBECTL env var.
  --no-native         Don't include the default native resource mappings.
  --no-resources      Don't include aliases and completions for resource-level commands.
  --no-containers     Don't include aliases and completions for container-level commands.
  --ssh-bastion TEXT  SSH bastion option to use with kuba ssh.
  --ssh-use-name      Use name option to use with kuba ssh.
  --list              Just list all resource aliases.
  --debug             Print debug info to stderr.
  -h, --help          Show this message and exit.

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

kuba-0.5.0.tar.gz (34.3 kB view details)

Uploaded Source

Built Distribution

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

kuba-0.5.0-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file kuba-0.5.0.tar.gz.

File metadata

  • Download URL: kuba-0.5.0.tar.gz
  • Upload date:
  • Size: 34.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.10 Darwin/24.5.0

File hashes

Hashes for kuba-0.5.0.tar.gz
Algorithm Hash digest
SHA256 9dfeb3378d646a0b9b4328f827c74a9d65e0227af7cea5b3df56b7579bc63a29
MD5 ea71b9110abe23cbadd19d57644cc7dd
BLAKE2b-256 29fb181db6ff5e1349ca03391d0c80c443f40ca49b8d5d47ffd08d1a6bb87bd4

See more details on using hashes here.

File details

Details for the file kuba-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: kuba-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.10 Darwin/24.5.0

File hashes

Hashes for kuba-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d90a26eb343e4a04176496556bf46e4c899f2a3dea843b80bc967ff2a187860d
MD5 0a14942691a70093423752f49928ec43
BLAKE2b-256 02d53b407d3a6ce492b2b8cb67d5e49d162c153c8ffa475959a4854b7108a054

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