kubectl 安装

    可以使用 Homebrew 或者 下载 kubectl:

    或者

    1. curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl

    Linux

    1. curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
    1. curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/windows/amd64/kubectl.exe

    或者使用 Chocolatey 来安装:

    你可以使用 krew 来管理 kubectl 插件。

    是一个用来管理 kubectl 插件的工具,类似于 apt 或 yum,支持搜索、安装和管理 kubectl 插件。

    安装

    1. set -x; cd "$(mktemp -d)" &&
    2. curl -fsSLO "https://storage.googleapis.com/krew/v0.2.1/krew.{tar.gz,yaml}" &&
    3. tar zxvf krew.tar.gz &&
    4. ./krew-"$(uname | tr '[:upper:]' '[:lower:]')_amd64" install \
    5. --manifest=krew.yaml --archive=krew.tar.gz
    6. )

    安装完成后,把 krew 的二进制文件加入环境变量 PATH 中:

    1. $ kubectl plugin list
    2. The following kubectl-compatible plugins are available:
    3. /home/<user>/.krew/bin/kubectl-krew

    首次使用前,请执行下面的命令更新插件索引:

    使用示例:

    1. kubectl krew search # show all plugins
    2. kubectl krew install ssh-jump # install a plugin named "ssh-jump"
    3. kubectl krew upgrade # upgrade installed plugins
    4. kubectl krew remove ssh-jump # uninstall a plugin

    在安装插件后,会输出插件所依赖的外部工具,这些工具需要你自己手动安装。

    1. Installing plugin: ssh-jump
    2. \
    3. | This plugin needs the following programs:
    4. | * ssh(1)
    5. | * ssh-agent(1)
    6. |
    7. | Please follow the documentation: https://github.com/yokawasa/kubectl-plugin-ssh-jump
    8. /
    9. Installed plugin: ssh-jump
    1. kubectl ssh-jump <node-name> -u <username> -i ~/.ssh/id_rsa -p ~/.ssh/id_rsa.pub

    升级方法