【问题标题】:There are older versions of Google Cloud Platform tools: Docker有旧版本的 Google Cloud Platform 工具:Docker
【发布时间】:2019-05-04 23:02:29
【问题描述】:

更新 gcloud 后,我收到此警告,但我该怎么做(我应该删除 Docker)?

WARNING:   There are older versions of Google Cloud Platform tools on your system PATH.
  Please remove the following to avoid accidentally invoking these old tools:

  /Applications/Docker.app/Contents/Resources/bin/kubectl

我的 .zshrc 中有这个:

# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/<NAME>/google-cloud-sdk/path.zsh.inc' ]; then source '/Users/<NAME>/google-cloud-sdk/path.zsh.inc'; fi

# The next line enables shell command completion for gcloud.
if [ -f '/Users/<NAME>/google-cloud-sdk/completion.zsh.inc' ]; then source '/Users/<NAME>/google-cloud-sdk/completion.zsh.inc'; fi

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

【问题讨论】:

    标签: docker google-cloud-platform gcloud kubectl google-cloud-sdk


    【解决方案1】:

    这是因为 docker-for-mac 为 kubectl 安装了一个 bin,而 gcloud-sdk 还安装了另一个带有 gcloud components install kubectl 的 bin。

    我的建议是从 gcloud 卸载 kubectl 作为组件,从 docker-for-mac 覆盖符号链接,并且只使用 homebrew 安装的 bin。

    试试这个命令:

    gcloud components remove kubectl

    brew install kubernetes-cli

    brew link --overwrite kubernetes-cli

    【讨论】:

    • 在我的 MacOS Mojave 上,当我执行 which kubectl 时,它指向来自 google-cloud-sdk 的 kubectl。对我来说,警告是无关紧要的,因此可以忽略。
    【解决方案2】:

    TLDR

    /usr/local/bin/kubectl 是 Docker 安装的链接:ls -l /usr/local/bin/kubectl => /usr/local/bin/kubectl -&gt; /Applications/Docker.app/Contents/Resources/bin/kubectl。去掉链接没有副作用,解决了冲突:

    rm /usr/local/bin/kubectl

    理由

    冲突在于 Docker 提供的 kubectl 版本,因此检查 Docker 文档对此有何评论是有意义的。 https://docs.docker.com/docker-for-mac/#kubernetes

    摘录:

    在 Docker Desktop for Mac 17.12 Edge (mac45) 及更高版本以及 18.06 稳定版 (mac70) 及更高版本,包含独立的 Kubernetes 服务器 在您的 Mac 上运行,以便您可以测试部署 Docker Kubernetes 上的工作负载。

    Kubernetes 客户端命令 kubectl 已包含并配置为 连接到本地 Kubernetes 服务器。

    ....

    如果您使用 Homebrew 安装了 kubectl,或者通过某些 其他方法,遇到冲突,去掉/usr/local/bin/kubectl

    【讨论】:

      【解决方案3】:

      这是我的案例,您可以参考。运行gcloud components update 后,我收到了这个警告:

      警告:您的系统 PATH 上有旧版本的 Google Cloud Platform 工具。 请删除以下内容以避免意外调用这些旧工具:

      /usr/local/Cellar/kubernetes-cli/1.10.2/bin/kubectl

      我使用brew list检查这个工具

      ☁  issue [master] brew list
      coreutils       gdbm            git-lfs         icu4c           kops            kubectx         libpng          mtr             openssl         python@2        sqlite          tree            wxmac
      erlang          geoip           git-redate      jpeg            kube-ps1        kubernetes-cli  libtiff         node            pcre            readline        telnet          watchman
      

      看完doc。我决定卸载 kubernetes-cli 及其依赖项 kopskube-ps1kubectx 以避免冲突。

      ☁  issue [master] brew uninstall kops kube-ps1 kubectx
      Uninstalling /usr/local/Cellar/kops/1.9.0... (5 files, 129.8MB)
      Uninstalling /usr/local/Cellar/kube-ps1/0.6.0... (6 files, 29.0KB)
      Uninstalling /usr/local/Cellar/kubectx/0.5.0... (12 files, 27.8KB)
      ☁  issue [master] brew uninstall kubernetes-cli
      Uninstalling /usr/local/Cellar/kubernetes-cli/1.10.2... (178 files, 52.8MB)
      ☁  issue [master] gcloud components update
      
      All components are up to date.
      

      这个警告消失了。

      【讨论】:

        【解决方案4】:

        我刚刚进入 Docker 文件的 bin 文件夹并将 kubectl 移到了垃圾箱。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-03-29
          • 2018-01-04
          • 1970-01-01
          • 2015-12-12
          • 2018-08-07
          • 1970-01-01
          • 1970-01-01
          • 2016-04-08
          相关资源
          最近更新 更多