命令`gcloud container clusters get-credentials`不会创建kubeconfig

The command `gcloud container clusters get-credentials ` will not create a kubeconfig

当我键入 gcloud container clusters get-credentials 时,我得到响应 entry generated for ***.。看起来它已经生成了,但是当我点击 kubectl config view 时,什么也没有。

Reference of gcloud container clusters get-credentials 说,

gcloud container clusters get-credentials updates a kubeconfig file with appropriate credentials and endpoint information to point kubectl at a specific cluster in Google Kubernetes Engine.

所以我认为问题是 ~/.kube/config 不存在,但是创建一个空文件并没有改变它。

原因是WSL的PATH默认包含了Windows端的PATH,所以调用了[=17=上的gcloud ](由勺子安装)。 我通过排除Windows的PATH解决了问题,参考this gists.