Microk8s bash completion
D
Dan Willoughby・ Jan 6, 2020・1 min read
Having bash completion for kubectl has been the best. I find it most useful when I need to get the full name of a pod. I type the first few letters of the name of the pod and then hit tab and it'll populate the rest for me.
I followed the instructions on microk8s getting started. After it was installed I setup an alias
sudo snap alias microk8s.kubectl mk
Once you have the alias set, you can run the command to generate the completion functions. The sed replaces all occurances of kubectl
with mk
. This allows completion to exist with your microk8s alis
source <(mk completion bash | sed "s/kubectl/mk/g")
If you're curious you can pipe the output of mk completion bash
and grep for __kubectl
to see a list of the functions you'll be renaming.
mk completion bash | grep __kubectl
WRITTEN BY
Dan Willoughby