开启 k8s 命令补全功能

1. 查看 kubectl 帮助信息

bash 复制代码
[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. 再次查看帮助信息

bash 复制代码
[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
相关推荐
Dontla1 小时前
Docker run --add-host参数解析(在容器启动时向/etc/hosts文件中添加自定义的主机名与IP映射)(适用于临时调试或测试)
tcp/ip·docker·容器
西西小飞龙1 小时前
Docker和K8S中pod、services、container的介绍和关系
docker·容器·kubernetes
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
放情12 小时前
Ubutu部署WordPress
ubuntu·云原生
飞火流星0202713 小时前
docker安装etcd:docker离线安装etcd、docker在线安装etcd、etcd镜像下载、etcd配置详解、etcd常用命令、安装常见问题总结
docker·容器·etcd
you来有去14 小时前
记录一下在k3s快速创建gitlab
java·kubernetes·gitlab
magrich14 小时前
Docker usage on ubuntu
ubuntu·docker·容器
一只专注api接口开发的技术猿14 小时前
电商API接口设计:商品、订单与支付模块的微服务拆分实践
大数据·前端·数据库·微服务·云原生·架构