前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >kubernetes(k8s)安装命令行自动补全功能

kubernetes(k8s)安装命令行自动补全功能

原创
作者头像
小陈运维
发布2021-11-05 09:34:44
2.1K0
发布2021-11-05 09:34:44
举报
文章被收录于专栏:小陈运维

kubernetes(k8s)安装命令行自动补全功能

Ubuntu下安装命令

代码语言:javascript
复制
root@master1:~# apt install -y bash-completion
Reading package lists... Done
Building dependency tree      
Reading state information... Done
bash-completion is already the newest version (1:2.10-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.
复制代码

centos下安装命令

代码语言:javascript
复制
[root@dss ~]# yum install bash-completion -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * epel: mirrors.tuna.tsinghua.edu.cn
Package 1:bash-completion-2.1-8.el7.noarch already installed and latest version
Nothing to do
[root@dss ~]#
复制代码
代码语言:javascript
复制
root@master1:~# locate bash_completion
/etc/bash_completion
/etc/bash_completion.d
/etc/bash_completion.d/apport_completion
/etc/bash_completion.d/git-prompt
/etc/profile.d/bash_completion.sh
/snap/core18/2128/etc/bash_completion
/snap/core18/2128/usr/share/bash-completion/bash_completion
/snap/core18/2128/usr/share/doc/bash/README.md.bash_completion.gz
/snap/core18/2128/usr/share/perl5/Debian/Debhelper/Sequence/bash_completion.pm
/snap/lxd/21029/etc/bash_completion.d
/snap/lxd/21029/etc/bash_completion.d/snap.lxd.lxc
/usr/share/bash-completion/bash_completion
/usr/share/doc/bash/README.md.bash_completion.gz
/usr/share/perl5/Debian/Debhelper/Sequence/bash_completion.pm
/var/lib/docker/overlay2/0f27e9d2ca7fbe8a3b764a525f1c58990345512fa6dfe4162aba3e05ccff5b56/diff/etc/bash_completion.d
/var/lib/docker/overlay2/5eb1b0cb946881e1081bfa7a608b6fa85dbf2cb7e67f84b038f3b8a85bd13196/diff/usr/local/lib/node_modules/npm/node_modules/dashdash/etc/dashdash.bash_completion.in
/var/lib/docker/overlay2/76c41c1d1eb6eaa7b9259bd822a4bffebf180717a24319d2ffec3b4dcae0e66a/merged/etc/bash_completion.d
/var/lib/docker/overlay2/78b8ab76c0e0ad7ee873daab9ab3987a366ec32fda68a4bb56a218c7f8806a58/merged/etc/profile.d/bash_completion.sh
/var/lib/docker/overlay2/78b8ab76c0e0ad7ee873daab9ab3987a366ec32fda68a4bb56a218c7f8806a58/merged/usr/share/bash-completion/bash_completion
/var/lib/docker/overlay2/802133f75f62596a2c173f1b57231efbe210eddd7a43770a62ca94c86ce2ca56/merged/usr/local/lib/node_modules/npm/node_modules/dashdash/etc/dashdash.bash_completion.in
/var/lib/docker/overlay2/ee672bdd0bf0fdf590f9234a8a784ca12c262c47a0ac8ab91acc0942dfafc339/diff/etc/profile.d/bash_completion.sh
/var/lib/docker/overlay2/ee672bdd0bf0fdf590f9234a8a784ca12c262c47a0ac8ab91acc0942dfafc339/diff/usr/share/bash-completion/bash_completion
复制代码

临时环境变量

代码语言:javascript
复制
root@master1:~# source /usr/share/bash-completion/bash_completion
root@master1:~# source <(kubectl completion bash)
root@master1:~#
root@master1:~#
root@master1:~# kubectl
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          
attach         completion     debug          edit           help           patch          rollout        top            
root@master1:~# kubectl
复制代码

永久写入环境变量配置文件

代码语言:javascript
复制
root@master1:~#
root@master1:~#
root@master1:~# echo "source <(kubectl completion bash)" >> ~/.bashrc
root@master1:~#
root@master1:~# cat ~/.bashrc


----略----


# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'


# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.


if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi


# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
#    . /etc/bash_completion
#fi


source <(kubectl completion bash)
root@master1:~#
复制代码

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • kubernetes(k8s)安装命令行自动补全功能
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档