配置 kubectl 命令自动补全功能
# 安装 bash-completion
yum install -y bash-completion
source /usr/share/bash-completion/bash_completion
# 系统所有用户都拥有命令自动补全功能
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
# 仅当前用户拥有命令自动补全功能
#echo 'source <(kubectl completion bash)' >> ~/.bashrc
#source ~/.bashrc
kubectl 命令自动补全效果
[root@k8s-master-01 ~]# kubectl
alpha attach completion debug edit help patch rollout top
annotate auth config delete exec kustomize plugin run uncordon
api-resources autoscale cordon describe explain label port-forward scale version
api-versions certificate cp diff expose logs proxy set wait
apply cluster-info create drain get options replace taint
[root@k8s-master-01 ~]# kubectl config
current-context delete-context get-clusters get-users set set-context unset view
delete-cluster delete-user get-contexts rename-context set-cluster set-credentials use-context
[root@k8s-master-01 ~]# kubectl config view
anaconda-ks.cfg .bash_logout .bashrc .kube/ .ssh/ .viminfo
.bash_history .bash_profile .cshrc .pki/ .tcshrc
[root@k8s-master-01 ~]# kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://192.168.3.201:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: admin
name: kubernetes
current-context: kubernetes
kind: Config
preferences: {}
users:
- name: admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
[root@k8s-master-01 ~]#
参考链接:
网友评论