Install bash-completion if it is not installed
CentOS / Fedora / RHEL:
yum -y install bash-completion
Debian / Ubuntu:
apt-get -y install bash-completion
Add bash completion for „kubectl“ to .bash_aliases
echo "source <(kubectl completion bash)" >> ~/.bash_aliases
Add alias and bash completion to .bash_aliases to make the changes persistent across sessions
echo "alias k=kubectl" >> ~/.bash_aliases
echo "complete -F __start_kubectl k" >> ~/.bash_aliases
If you only added the commands to .bashrc make them available in the current session
source ~/.bashrc
You can now use „k“ instead of „kubectl“ for kubernetes commands and TAB for auto-completion.