K8S kubectl 自动补全

77 阅读1分钟
[root@test01v ~]# yum install -y bash-completion
Loaded plugins: fastestmirror
ADDOPS-base                                                                     | 2.9 kB  00:00:00     
base                                                                            | 2.9 kB  00:00:00     
centosplus                                                                      | 2.9 kB  00:00:00     
docker-ce-stable                                                                | 3.5 kB  00:00:00     
epel                                                                            | 2.9 kB  00:00:00     
extras                                                                          | 2.9 kB  00:00:00     
kubernetes                                                                      | 1.4 kB  00:00:00     
puppetlabs-deps                                                                 | 2.9 kB  00:00:00     
puppetlabs-products                                                             | 2.9 kB  00:00:00     
updates                                                                         | 2.9 kB  00:00:00     
(1/4): kubernetes/primary                                                       | 125 kB  00:00:00     
(2/4): centosplus/7/x86_64/primary_db                                           | 8.3 MB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                              |  20 MB  00:00:01     
(4/4): epel/x86_64/primary_db                                                   | 7.7 MB  00:00:01     
Determining fastest mirrors
kubernetes                                                                                     932/932
Resolving Dependencies
--> Running transaction check
---> Package bash-completion.noarch 1:2.1-8.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
 Package                       Arch                 Version                   Repository          Size
=======================================================================================================
Installing:
 bash-completion               noarch               1:2.1-8.el7               base                87 k

Transaction Summary
=======================================================================================================
Install  1 Package

Total download size: 87 k
Installed size: 263 k
Downloading packages:
bash-completion-2.1-8.el7.noarch.rpm                                            |  87 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:bash-completion-2.1-8.el7.noarch                                                  1/1 
  Verifying  : 1:bash-completion-2.1-8.el7.noarch                                                  1/1 

Installed:
  bash-completion.noarch 1:2.1-8.el7                                                                   

Complete!
[root@test01v ~]# 
[root@test01v ~]# source /usr/share/bash-completion/bash_completion
[root@test01v ~]# source <(kubectl completion bash)
[root@test01v ~]# echo "source <(kubectl completion bash)" >> ~/.bashrc
[root@test01v ~]# kubectl de
delete    describe