1. 查看 kubectl 帮助信息

[root@k8s231 /etc/kubernetes]# kubectl --help

Settings Commands:
  label         Update the labels on a resource
  annotate      Update the annotations on a resource
  completion    Output shell completion code for the specified shell (bash, zsh or fish)

#completion 这个是管理命令补全功能的

2. 再次查看帮助信息

[root@k8s231 /etc/kubernetes]# kubectl completion --help
 
 #linux 查看这里
 #基于当前生效,临时性的
  kubectl completion bash > ~/.kube/completion.bash.inc

  # Kubectl shell completion
  echo "source '$HOME/.kube/completion.bash.inc'" >> $HOME/.bash_profile
  source $HOME/.bash_profile

# 根据提示执行相关命令 ,永久生效
yum –y install bash-completion
kubectl completion bash > ~/.kube/completion.bash.inc
echo "source '$HOME/.kube/completion.bash.inc'" >> $HOME/.bash_profile
source $HOME/.bash_profile

Logo

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

更多推荐