A kubectl plugin to render watch output in a more readable fashion
A kubectl plugin to render watch output in a more readable fashion
A kubectl plugin to render the kubectl get pods --watch output in a
much more readable fashion.
Think of it as running watch kubectl get pods, but instead of polling,
it uses the regular watch feature to stream updates as soon as they occur.
kubectl krew install klock
sudo snap install klock
scoop bucket add applejag https://github.com/applejag/applejag-bucket
scoop install applejag/kubectl-klock
nix-shell -p kubectl-klock
You can download pre-built binaries from the latest GitHub release:
Download the one that fits your OS and architecture, extract the
tarball/zip file, and move the kubectl-klock binary to somewhere in your PATH.
For example:
tar -xzf kubectl-klock_linux_amd64.tar.gz
sudo mv ./kubectl-klock /usr/local/bin
Requires Go 1.21 (or later).
go install github.com/applejag/kubectl-klock@latest
Supports a wide range of flags
kubectl klock [name(s)] [flags]
…
There's also some hotkeys available:
→/l/pgdn next page / filter by text ctrl+c quit
←/h/pgup prev page enter close the filter input field ?/esc close help
g/home go to start esc clear the applied filter d show all deleted
G/end go to end ↓/ctrl+n show next suggestion f toggle fullscreen
↑/ctrl+p show previous suggestion
tab accept a suggestion
Pagination, for when the terminal window gets too small (height-wise)
Same output format as kubectl get
Watch arbitrary resources, just like kubectl get [name]
Filter results
Auto updating age column.
Colors on statuses (e.g Running) and fractions (e.g 1/1) to make
them stand out more.
Restart watch when kubeconfig file changes (flag: --watch-kubeconfig, -W),
such as when changed by kubectx.
Color themes powered by kubecolor
Shows deleted table rows for a short duration,
controllable via the --hide-deleted=10s flag
and KLOCK_HIDE_DELETED=10s environment variable.
Can be disabled to always show deleted rows by setting --hide-deleted=false
Command-line flags can be controlled via environment variables:
export KLOCK_ALL_NAMESPACES="true" # --all-namespaces
export KLOCK_FIELD_SELECTOR="status.phase!=Succeeded" # --field-separator
export KLOCK_HIDE_DELETED="false" # --hide-deleted
export KLOCK_LABEL_COLUMNS="app.kubernetes.io/name" # --label-columns
export KLOCK_OUTPUT="wide" # --output
export KLOCK_SELECTOR="team!=frontend" # --selector
export KLOCK_WATCH_KUBECONFIG="true" # --watch-kubeconfig
The command-line flags have precedence over the environment variables.
So if you set KLOCK_ALL_NAMESPACES=true then you can revert the value
by passing the flag --all-namespaces=false
Klock uses kubecolor's coloring logic and behavior when coloring its output. See:
[!NOTE] If you have a light background, then switch
kubectl-klockto use the light theme by setting theKUBECOLOR_PRESET=lightenvironment variable:export KUBECOLOR_PRESET="light" kubectl klock --help
Color settings that klock uses:
KUBECOLOR_THEME_BASE_DANGER for rows with errorsKUBECOLOR_THEME_BASE_MUTED for "No resources found"KUBECOLOR_THEME_BASE_MUTED for deleted rowsKUBECOLOR_THEME_BASE_MUTED for status lineKUBECOLOR_THEME_BASE_SECONDARY for "FILTER:" promptKUBECOLOR_THEME_BASE_WARNING for "No resources visible" when filteringKUBECOLOR_THEME_DATA_DURATIONFRESH for AGE: 12h when below thresholdKUBECOLOR_THEME_DATA_RATIO_EQUAL for READY: 1/1KUBECOLOR_THEME_DATA_RATIO_UNEQUAL for READY: 0/1KUBECOLOR_THEME_STATUS_ERROR for STATUS: CrashLoopBackOffKUBECOLOR_THEME_STATUS_SUCCESS for STATUS: RunningKUBECOLOR_THEME_STATUS_WARNING for STATUS: TerminatingKUBECOLOR_THEME_TABLE_COLUMNS for table columnsKUBECOLOR_THEME_TABLE_HEADER for table headerYou can configure these colors either via
environment variables
or via the ~/.kube/color.yaml config file
To get completion when writing kubectl klock, you need to add
./bin/kubectl_complete-klock
to your PATH.
For example:
curl -sSfL https://github.com/applejag/kubectl-klock/raw/main/bin/kubectl_complete-klock -o ~/.local/bin/kubectl_complete-klock
chmod -v +x ~/.local/bin/kubectl_complete-klock
No open issues yet, or sync has not completed.