kubemrr
kubemrr mirrors description of Kubernetes resources for blazingly fast auto-completion.
Bash has the programmable completion feature which permits typing a partial command,
then pressing the [TAB] key to auto-complete the command sequence.To use the feature, you need to write a completion script
and place it in /etc/bash_completion.d folder (docs,
tutorial).
Fortunately, kubectl comes with a command to generate completion script (kubectl completion).
The script works extremely well, but slow, because each time you hit [TAB] it sends a request
to Kubernetes API Server. If your server is on a different continent you might wait for up to 2 seconds.
To reduce the delay, kubemrr keeps names of resources locally. We will make a completion script which talks to kubemrr
instead of real Kubernetes API server.
Example
To start watching a server:
kubemrr watch https://kube-us.example.org
To make completion script that talks to kubemrr:
alias kus='kubectl --context us'
kubemrr completion --kubectl-alias=kus > kus
sudo cp kus /etc/bash_completion.d
To test it:
kus get po [TAB][TAB]
To make completion script that talks to kubemrr that is running on different host (use IP to save time on name resolution):
kubemrr completion --address=10.5.1.6 --kubectl-alias=kus > kus
Autocompleted Resources
- pods
- service
- deployments
- configmaps