kubectl-klock


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.
Installation
Krew

kubectl krew install klock
Snap

sudo snap install klock
Scoop

scoop bucket add applejag https://github.com/applejag/applejag-bucket
scoop install applejag/kubectl-klock
Nix

nix-shell -p kubectl-klock
Pre-built binaries
You can download pre-built binaries from the latest GitHub release: https://github.com/applejag/kubectl-klock/releases/latest
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
From source
Requires Go 1.21 (or later).
go install github.com/applejag/kubectl-klock@latest
Usage
Supports a wide range of flags
kubectl klock <resource> [name(s)] [flags]
Examples
# Watch all pods
kubectl klock pods
# Watch all pods with more information (such as node name)
kubectl klock pods -o wide
# Watch a specific pod
kubectl klock pods my-pod-7d68885db5-6dfst
# Watch a subset of pods, filtering on labels
kubectl klock pods --selector app=my-app
kubectl klock pods -l app=my-app
# Watch all pods in all namespaces
kubectl klock pods --all-namespaces
kubectl klock pods -A
# Watch other resource types
kubectl klock cronjobs
kubectl klock deployments
kubectl klock statefulsets
kubectl klock nodes
# Watch all pods, but restart the watch when your ~/.kube/config file changes,
# such as when using "kubectl config use-context NAME"
kubectl klock pods --watch-kubeconfig
kubectl klock pods -W
There's also some hotkeys available:
→/l/pgdn next page d show/hide deleted ctrl+c quit
←/h/pgup prev page f toggle fullscreen ?/esc close help
g/home go to start / filter by text
G/end go to end enter close the filter input field
esc clear the applied filter
Features
-
Pagination, for when the terminal window gets too small (height-wise)
-
Same output format as kubectl get
-
Watch arbitrary resources, just like kubectl get <resource> [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.
Completion
To get completion when writing kubectl klock
, you need to add
./bin/kubectl_complete-klock
to your PATH
.
For example:
sudo curl https://github.com/applejag/kubectl-klock/raw/main/bin/kubectl_complete-klock -o /usr/local/bin/kubectl_complete-klock
sudo chmod +x /usr/local/bin/kubectl_complete-klock