There are older versions of Google Cloud Platform tools: Docker

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. 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. 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.

The Kubernetes client command, kubectl, is included and configured to connect to the local Kubernetes server.

....

If you installed kubectl with Homebrew, or by some other method, and experience conflicts, remove /usr/local/bin/kubectl.


Here is my case you can refer to. After running gcloud components update, I got this warning:

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:

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

I check this tool using 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.

☁  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.


This happens because docker-for-mac installs a bin for kubectl, and gcloud-sdk also installs another bin with gcloud components install kubectl.

My recommendation is to uninstall kubectl as component from gcloud, overwrite the symlink from docker-for-mac, and only use the homebrew installed bin.

Try this commands:

gcloud components remove kubectl

brew install kubernetes-cli

brew link --overwrite kubernetes-cli