先下载配置文件和相应的tar包,并对tar包解压,释放出可执行文件:
wget https://storage.googleapis.com/krew/v0.2.1/krew.tar.gz wget https://storage.googleapis.com/krew/v0.2.1/krew.yaml tar -zxvf krew.tar.gz
# wget https://storage.googleapis.com/krew/v0.2.1/krew.tar.gz --2020-01-13 08:34:35-- https://storage.googleapis.com/krew/v0.2.1/krew.tar.gz Resolving storage.googleapis.com (storage.googleapis.com)… 172.217.164.112, 2607:f8b0:4005:807::2010 Connecting to storage.googleapis.com (storage.googleapis.com)|172.217.164.112|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 14375157 (14M) [application/x-tar] Saving to: ‘krew.tar.gz’ 100%[=====================================================>] 14,375,157 42.9MB/s in 0.3s 2020-01-13 08:34:36 (42.9 MB/s) - ‘krew.tar.gz’ saved [14375157/14375157]
# wget https://storage.googleapis.com/krew/v0.2.1/krew.yaml --2020-01-13 08:34:36-- https://storage.googleapis.com/krew/v0.2.1/krew.yaml Resolving storage.googleapis.com (storage.googleapis.com)… 172.217.164.112, 2607:f8b0:4005:807::2010 Connecting to storage.googleapis.com (storage.googleapis.com)|172.217.164.112|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 2442 (2.4K) [application/octet-stream] Saving to: ‘krew.yaml’ 100%[=====================================================>] 2,442 --.-K/s in 0s 2020-01-13 08:34:36 (37.2 MB/s) - ‘krew.yaml’ saved [2442/2442]
# tar -zxvf krew.tar.gz ./krew-darwin_amd64 ./krew-linux_amd64 ./krew-linux_arm ./krew-windows_amd64.exe
# ls krew-darwin_amd64 krew-linux_arm krew-windows_amd64.exe krew-linux_amd64 krew.tar.gz krew.yaml
./krew-linux_amd64 install --manifest=krew.yaml --archive=krew.tar.gz Installing plugin: krew CAVEATS: \ | krew is now installed! To start using kubectl plugins, you need to add | krew's installation directory to your PATH: | | * macOS/Linux: | - Add the following to your ~/.bashrc or ~/.zshrc: | export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" | - Restart your shell. | | * Windows: Add %USERPROFILE%.krew\bin to your PATH environment variable | | Run "kubectl krew" to list krew commands and get help. | You can find documentation at https://github.com/GoogleContainerTools/krew. / Installed plugin: krew
修改 ~/.bash_profile
vim .bash_profile 增加一行: PATH=$PATH:$HOME/bin:$HOME/.krew/bin 保存后执行: source .bash_profile
示例,安装一个tree插件:
# kubectl krew install tree Updated the local copy of plugin index. Installing plugin: tree CAVEATS: \ | * For resources that are not in default namespace, currently you must | specify -n/--namespace explicitly (the current namespace setting is not | yet used). / Installed plugin: tree [root@xxxx ~]# kubectl tree deployment zzzz -n yyyy NAMESPACE NAME READY REASON AGE yyyy Deployment/zzzz - 4d14h yyyy └─ReplicaSet/zzzz-58dc7468d7 - 4d14h yyyy └─Pod/zzzz-58dc7468d7-nzkbh True 3h45m