[root@k8s-master01 k8s]# yum install -y bash-completion [root@k8s-master01 k8s]# source /usr/share/bash-completion/bash_completion # source <(kubectl completion bash)
就可以完成补全了。
可以将 source <(kubectl completion bash) 命令 写入 $HOME/.bashrc中.
[root@k8s-master01 k8s]# cat $HOME/.bashrc # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi source <(kubectl completion bash) [root@k8s-master01 k8s]# source $HOME/.bashrc