kubectl的插件安装工具krew

最近得知一个kubectl插件安装工具,叫做krew。

官网地址是:Krew – kubectl plugin manager

 安装krew

按照官网的做法,一直安装失败,于是拆解步骤,一步一步下载离线安装。

1、下载krew.yaml

地址:https://github.com/kubernetes-sigs/krew-index/blob/master/plugins/krew.yaml

这里我把原文贴出来,大家可以直接copy使用

apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
  name: krew
spec:
  version: "v0.4.4"
  homepage: https://krew.sigs.k8s.io/
  shortDescription: Package manager for kubectl plugins.
  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/.

  # The supported platforms for plugins are the ones that Krew itself is distributed in.
  # See all supported platforms on the [releases page](https://github.com/kubernetes-sigs/krew/releases).
  platforms:
  - uri: https://github.com/kubernetes-sigs/krew/releases/download/v0.4.4/krew-darwin_amd64.tar.gz
    sha256: 5f4d2f34868a87cf1188212cf7cb598e76a32f389054089aad1fa46e6daf1e1b
    bin: krew
    files:
    - from: ./krew-darwin_amd64
      to: krew
    - from: ./LICENSE
      to: .
    selector:
      matchLabels:
        os: darwin
        arch: amd64
  - uri: https://github.com/kubernetes-sigs/krew/releases/download/v0.4.4/krew-darwin_arm64.tar.gz
    sha256: e6ac776140b228d6bdfda11247baf4e9b11068f42005d0975fc260c629954464
    bin: krew
    files:
    - from: ./krew-darwin_arm64
      to: krew
    - from: ./LICENSE
      to: .
    selector:
      matchLabels:
        os: darwin
        arch: arm64
  - uri: https://github.com/kubernetes-sigs/krew/releases/download/v0.4.4/krew-linux_amd64.tar.gz
    sha256: e471396b0ed4f2be092b4854cc030dfcbb12b86197972e7bef0cb89ad9c72477
    bin: krew
    files:
    - from: ./krew-linux_amd64
      to: krew
    - from: ./LICENSE
      to: .
    selector:
      matchLabels:
        os: linux
        arch: amd64
  - uri: https://github.com/kubernetes-sigs/krew/releases/download/v0.4.4/krew-linux_arm.tar.gz
    sha256: 4f3d550227e014f3ba7c72031108ffda0654cb755f70eb96be413a5102d23333
    bin: krew
    files:
    - from: ./krew-linux_arm
      to: krew
    - from: ./LICENSE
      to: .
    selector:
      matchLabels:
        os: linux
        arch: arm
  - uri: https://github.com/kubernetes-sigs/krew/releases/download/v0.4.4/krew-linux_arm64.tar.gz
    sha256: f8f0cdbf698ed3e8cb46e7bd213754701341a10e11ccb69c90d4863e0cf5a16a
    bin: krew
    files:
    - from: ./krew-linux_arm64
      to: krew
    - from: ./LICENSE
      to: .
    selector:
      matchLabels:
        os: linux
        arch: arm64
  - uri: https://github.com/kubernetes-sigs/krew/releases/download/v0.4.4/krew-linux_ppc64le.tar.gz
    sha256: 966ee6d2b113c9ed7d8c6072ae3b24d5041da9a658b6197249634c5c76ba37a9
    bin: krew
    files:
    - from: ./krew-linux_ppc64le
      to: krew
    - from: ./LICENSE
      to: .
    selector:
      matchLabels:
        os: linux
        arch: ppc64le
  - uri: https://github.com/kubernetes-sigs/krew/releases/download/v0.4.4/krew-windows_amd64.tar.gz
    sha256: da0dfeb2a598f11fb9ce871ee7f3b1a69beb371a45f531ee65a71b2201511d28
    bin: krew.exe
    files:
    - from: ./krew-windows_amd64.exe
      to: krew.exe
    - from: ./LICENSE
      to: .
    selector:
      matchLabels:
        os: windows
        arch: amd64

2、下载安装包

根据官网给的命令中的这一部分,大家执行的时候,可能会出错,但是至少可以看到一个url地址

set -x; cd "$(mktemp -d)" &&
  OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
  ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
  KREW="krew-${OS}_${ARCH}" &&
  curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" 

如下图

kubectl的插件安装工具krew_第1张图片

复制地址,直接在浏览器中粘贴,去下载,下载好了之后放入自己的服务器上。

然后执行下述命令解压,多一个可执行程序

tar zxvf  krew-linux_amd64.tar.gz

 如下图所示:

kubectl的插件安装工具krew_第2张图片

3、安装

./krew-linux_amd64 install --manifest=krew.yaml --archive=krew-linux_amd64.tar.gz

kubectl的插件安装工具krew_第3张图片

4、配置环境变量

vi   ~/.bashrc   加入如下内容

export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"

记得再加载一下环境变量,使其生效

source ~/.bashrc 

5、验证

kubectl krew  -h

kubectl的插件安装工具krew_第4张图片

你可能感兴趣的:(linux,运维,服务器,云原生,kubectl)