505. 【kubernetes】安装-krew-管理kubectl-插件

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 安装包、解压、并安装

  1. 下载:
wget https://github.com/kubernetes-sigs/krew/releases/latest/download/krew-linux_amd64.tar.gz
  1. 解压
tar -zxvf krew-linux_amd64.tar.gz
  1. 配置环境变量
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,可以用了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值