krew
是一个可以轻松使用kubectl插件的工具。支持插件的发现、安装和管理。它类似于apt、dnf或brew等工具。
安装过程中比较坑的地方在于:github 访问不了。这里不得不推荐 github520
这个项目,我们先从 github520 项目中,复制 github 的各种域名解析列表,将其复制到 /etc/hosts
中。
1. 复制github 域名解析列表
2. 修改 /etc/hosts 文件
cat >> /etc/hosts <<EOF
# GitHub520 Host Start
140.82.114.25 alive.github.com
140.82.112.6 api.github.com
185.199.110.153 assets-cdn.github.com
185.199.111.133 avatars.githubusercontent.com
185.199.108.133 avatars0.githubusercontent.com
185.199.108.133 avatars1.githubusercontent.com
185.199.108.133 avatars2.githubusercontent.com
185.199.108.133 avatars3.githubusercontent.com
185.199.108.133 avatars4.githubusercontent.com
185.199.108.133 avatars5.githubusercontent.com
185.199.108.133 camo.githubusercontent.com
140.82.113.21 central.github.com
185.199.108.133 cloud.githubusercontent.com
140.82.113.10 codeload.github.com
140.82.113.22 collector.github.com
185.199.108.133 desktop.githubusercontent.com
185.199.108.133 favicons.githubusercontent.com
140.82.114.4 gist.github.com
52.217.65.188 github-cloud.s3.amazonaws.com
52.217.230.97 github-com.s3.amazonaws.com
52.217.67.92 github-production-release-asset-2e65be.s3.amazonaws.com
54.231.162.177 github-production-repository-file-5c1aeb.s3.amazonaws.com
54.231.170.177 github-production-user-asset-6210df.s3.amazonaws.com
192.0.66.2 github.blog
140.82.112.18 github.community
185.199.108.154 github.githubassets.com
151.101.129.194 github.global.ssl.fastly.net
185.199.110.153 github.io
185.199.108.133 github.map.fastly.net
185.199.110.153 githubstatus.com
140.82.114.26 live.github.com
185.199.108.133 media.githubusercontent.com
185.199.108.133 objects.githubusercontent.com
13.107.43.16 pipelines.actions.githubusercontent.com
185.199.108.133 raw.githubusercontent.com
185.199.108.133 user-images.githubusercontent.com
13.107.246.51 vscode.dev
# Update time: 2022-11-24T22:05:05+08:00
# Update url: https://raw.hellogithub.com/hosts
# Star me: https://github.com/521xueweihan/GitHub520
# GitHub520 Host End
EOF
3. 下载 krew 安装包、解压、并安装
- 下载:
wget https://github.com/kubernetes-sigs/krew/releases/latest/download/krew-linux_amd64.tar.gz
- 解压
tar -zxvf krew-linux_amd64.tar.gz
- 配置环境变量
vim /etc/profile
添加这样一行: PATH=${PATH}:${HOME}/.krew/bin
4. 安装
[root@k8s0 workspace_krew]# ./krew-linux_amd64 install krew
Updated the local copy of plugin index.
Installing plugin: krew
Installed plugin: krew
\
| Use this plugin:
| kubectl krew
| Documentation:
| https://krew.sigs.k8s.io/
| 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
| |
| | To list krew commands and to get help, run:
| | $ kubectl krew
| | For a full list of available plugins, run:
| | $ kubectl krew search
| |
| | You can find documentation at
| | https://krew.sigs.k8s.io/docs/user-guide/quickstart/.
| /
/
OK,可以用了。