At the time of the writing, my
.kube/config has a dozen of clusters configured; some of them are on slow networks. Striking the tab key with
kubectl can lead to veeerrrryyy slow completion and freeze the terminal till the completion functions finish.
kubectl-fzf can be installed locally or on the target cluster. Since I’m dealing with plenty of ephemeral clusters I opted-in for the local approach.
The two twists I’m adding to the standard installation process documented here are:
kubectl-fzf as an oh-my-zsh plugin:
To do so just copy
And replace the first line to put the cache in the home directory:
sed -i '1 s@export KUBECTL_FZF_CACHE@export KUBECTL_FZF_CACHE=$HOME/tmp/kubectl_fzf_cache@' ~/.oh-my-zsh/plugins/kubectl_fzf
2. Add a systemd service for the local user:
To help building the cache as soon as I log in.
To do so you can add the following config to :
As you can see, systemd prefers Specifiers over environment variables like
Now comes the time to enable our cache-builder service
systemctl --user enable cache-builder.service systemctl --user restart cache-builder.service systemctl --user status cache-builder.service
systemctl --user restart cache-builder is useful to force rebuilding the cache when you switch
kubeconfig for example.
fzf itself & systemd are !
There is still plenty to tune in each of these modules like & non-exclusively :