原文地址: https://blog.csdn.net/wenwenxiong/article/details/53105287
我下面测试用的 k8s版本: 1.9.3
在linux上
# yum install -y bash-completion
# locate bash_completion
/usr/share/bash-completion/bash_completion
# source /usr/share/bash-completion/bash_completion
# source <(kubectl completion bash)
测试下,没问题后,我们对 /root/.bashrc 加2行代码 ,方便以后每次登录自动生效:
source /usr/share/bash-completion/bash_completion
source <(kubectl completion bash)
在mac上
$ brew install bash-completion
$ source $(brew --prefix)/etc/bash_completion
$ source <(kubectl completion bash)