Kubernetes command auto completion


The kubectl command has a fair number of commands as well as a number of options available for each command. I recently learned that kubectl has a completion command which can be used along side the [bash|zsh]-completion packages to autocomplete commands for you! To get this working you will first need to install bash-completion:

$ yum -y install bash-completion

Once this package is installed you can run kubectl with the completion command to generate shell completion code:

$ kubectl completion bash >> $HOME/.bashrc

Once you source your .bashrc you can type in kubectl and then use tab to autocomplete the rest of your command line! Nifty!

This article was posted by Matty on 2018-02-04 12:46:40 -0500 -0500