1.查看
kubectl --help | grep bash
[root@master ~]# kubectl --help | grep bash
completion Output shell completion code for the specified shell (bash or zsh)
2.执行
kubectl completion bash
3.添加
在etc/profile文件第二行添加如下内容source <(kubectl completion bash)
# /etc/profile
source <(kubectl completion bash)
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
4.执行
source /etc/profile
5.验证
报错:
[root@k8s-master ~]# kubectl ap-bash: _get_comp_words_by_ref: 未找到命令
解决办法:
# yum install -y bash-completion
# source /usr/share/bash-completion/bash_completion
# source <(kubectl completion bash)
就可以完成补全了
网友评论