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

分享
开发者 2024-9-24 18:06:56 71 0 来自 中国
krew 是一个可以轻松利用kubectl插件的工具。支持插件的发现、安装和管理。它类似于apt、dnf或brew等工具。
安装过程中比力坑的地方在于:github 访问不了。这里不得不保举 github520 这个项目,我们先从 github520 项目中,复制 github 的各种域名剖析列表,将其复制到 /etc/hosts 中。
1. 复制github 域名剖析列表

1.png 2. 修改 /etc/hosts 文件

cat >> /etc/hosts <<EOF# GitHub520 Host Start140.82.114.25                 alive.github.com140.82.112.6                  api.github.com185.199.110.153               assets-cdn.github.com185.199.111.133               avatars.githubusercontent.com185.199.108.133               avatars0.githubusercontent.com185.199.108.133               avatars1.githubusercontent.com185.199.108.133               avatars2.githubusercontent.com185.199.108.133               avatars3.githubusercontent.com185.199.108.133               avatars4.githubusercontent.com185.199.108.133               avatars5.githubusercontent.com185.199.108.133               camo.githubusercontent.com140.82.113.21                 central.github.com185.199.108.133               cloud.githubusercontent.com140.82.113.10                 codeload.github.com140.82.113.22                 collector.github.com185.199.108.133               desktop.githubusercontent.com185.199.108.133               favicons.githubusercontent.com140.82.114.4                  gist.github.com52.217.65.188                 github-cloud.s3.amazonaws.com52.217.230.97                 github-com.s3.amazonaws.com52.217.67.92                  github-production-release-asset-2e65be.s3.amazonaws.com54.231.162.177                github-production-repository-file-5c1aeb.s3.amazonaws.com54.231.170.177                github-production-user-asset-6210df.s3.amazonaws.com192.0.66.2                    github.blog140.82.112.18                 github.community185.199.108.154               github.githubassets.com151.101.129.194               github.global.ssl.fastly.net185.199.110.153               github.io185.199.108.133               github.map.fastly.net185.199.110.153               githubstatus.com140.82.114.26                 live.github.com185.199.108.133               media.githubusercontent.com185.199.108.133               objects.githubusercontent.com13.107.43.16                  pipelines.actions.githubusercontent.com185.199.108.133               raw.githubusercontent.com185.199.108.133               user-images.githubusercontent.com13.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 EndEOF3.  下载 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

  • 安装
[root@k8s0 workspace_krew]# ./krew-linux_amd64 install krewUpdated the local copy of plugin index.Installing plugin: krewInstalled 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}/binPATH" |  |     - 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,可以用了。

您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2024-10-18 22:31, Processed in 0.180559 second(s), 35 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表