依次执行以下四条命令即可完成k8s的命令补全

yum -y install bash-completion
source /usr/share/bash-completion/bash_completion
source <(kubectl completion bash)
echo "source <(kubectl completion bash)" >> ~/.bashrc

补全效果

[root@k8s-master ~]# kubectl 
annotate       autoscale      cordon         drain          kustomize      port-forward   set            
api-resources  certificate    cp             edit           label          proxy          taint          
api-versions   cluster-info   create         exec           logs           replace        top            
apply          completion     delete         explain        options        rollout        uncordon       
attach         config         describe       expose         patch          run            version        
auth           convert        diff           get            plugin         scale          wait    
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐