简体   繁体   English

有旧版本的谷歌云平台工具:Docker

[英]There are older versions of Google Cloud Platform tools: Docker

After updating gcloud I get this warning, but how do I do it(Should I remove Docker)?更新 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

I have this in my.zshrc:我在 my.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

TLDR TLDR

/usr/local/bin/kubectl is a link installed by Docker: ls -l /usr/local/bin/kubectl => /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl . /usr/local/bin/kubectl是 Docker 安装的链接: ls -l /usr/local/bin/kubectl => /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl Removing the link has no side effects and solves the conflict:删除链接没有副作用,解决了冲突:

rm /usr/local/bin/kubectl

Justification理由

The conflict is with the Docker-provided version of kubectl so it makes sense to check what Docker docs have to say about it.冲突与 Docker 提供的kubectl版本有关,因此检查 Docker 文档kubectl是有意义的。 https://docs.docker.com/docker-for-mac/#kubernetes https://docs.docker.com/docker-for-mac/#kubernetes

Extract:提炼:

In Docker Desktop for Mac 17.12 Edge (mac45) and higher, and 18.06 Stable (mac70) and higher, a standalone Kubernetes server is included that runs on your Mac, so that you can test deploying your Docker workloads on Kubernetes.在 Docker Desktop for Mac 17.12 Edge (mac45) 及更高版本和 18.06 Stable (mac70) 及更高版本中,包含一个独立的 Kubernetes 服务器,可在您的 Mac 上运行,以便您可以测试在 Kubernetes 上部署 Docker 工作负载。

The Kubernetes client command, kubectl , is included and configured to connect to the local Kubernetes server. Kubernetes 客户端命令kubectl包含并配置为连接到本地 Kubernetes 服务器。

.... ....

If you installed kubectl with Homebrew, or by some other method, and experience conflicts, remove /usr/local/bin/kubectl .如果您使用 Homebrew 或通过其他方法安装kubectl并遇到冲突,请删除/usr/local/bin/kubectl

This happens because docker-for-mac installs a bin for kubectl, and gcloud-sdk also installs another bin with gcloud components install kubectl .发生这种情况是因为 docker-for-mac 为 kubectl 安装了一个 bin,而 gcloud-sdk 还安装了另一个带有gcloud components install kubectl bin。

My recommendation is to uninstall kubectl as component from gcloud, overwrite the symlink from docker-for-mac, and only use the homebrew installed bin.我的建议是从 gcloud 卸载 kubectl 作为组件,覆盖来自 docker-for-mac 的符号链接,并且只使用自制软件安装的 bin。

Try this commands:试试这个命令:

gcloud components remove kubectl

brew install kubernetes-cli

brew link --overwrite kubernetes-cli

Here is my case you can refer to.这是我的案例,你可以参考。 After running gcloud components update , I got this warning:运行gcloud components update ,我收到此警告:

WARNING: There are older versions of Google Cloud Platform tools on your system PATH.警告:您的系统路径上有旧版本的 Google Cloud Platform 工具。 Please remove the following to avoid accidentally invoking these old tools:请删除以下内容以避免意外调用这些旧工具:

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

I check this tool using brew list我使用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

After reading the doc .阅读文档后 I decided to uninstall kubernetes-cli and its dependencies kops , kube-ps1 , and kubectx to avoid the conflicts.我决定卸载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.

This warning is gone.这个警告消失了。

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

Do echo $PATH and check which folder takes precedence.执行echo $PATH并检查哪个文件夹优先。 In my case it is like .../Users/myname/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:... .就我而言,它就像.../Users/myname/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:... Here the kubectl in gcloud is actually before the kubectl from Docker Desktop (which is in /usr/local/bin/kubectl ) so there is no problem.这里 gcloud 中的 kubectl 实际上在 Docker 桌面(在/usr/local/bin/kubectl )的 kubectl 之前,所以没有问题。 If this is also your case you don't need to do anything.如果这也是你的情况,你不需要做任何事情。

Of course, if you want to completely remove confusion you can just delete the link /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl , or rename it.当然,如果你想完全消除混淆,你可以删除链接/usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl ,或者重命名它。

Update:更新:

In the recent docker desktop releases they actually provided another link /usr/local/bin/kubectl.docker -> /Applications/Docker.app/Contents/Resources/bin/kubectl to differentiate it from other kubectl so it is not a bad idea to just simply delete the link /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl在最近的 docker 桌面版本中,他们实际上提供了另一个链接/usr/local/bin/kubectl.docker -> /Applications/Docker.app/Contents/Resources/bin/kubectl以将其与其他 kubectl 区分开来,所以这不是一个坏主意只需删除链接/usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM