Search code examples
gcloudkubectl

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


When I type gcloud container clusters get-credentials, I get response entry generated for ***.. and it looks like it is generated, but when I hit kubectl config view, there is nothing.

Reference of gcloud container clusters get-credentials says,

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.

So I thought the problem was that ~/.kube/config did not exist, but creating an empty file did not change it.

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


Solution

  • Thanks to @DazWilkin in the comments for suggesting running the command with the --verbosity=debug flag, which then outputted where it was writing the file.

    The reason was that the PATH of WSL included the PATH of the Windows side by default, so it was calling the gcloud on Windows (installed by scoop). I solved the problem by excluding the PATH of Windows, referring to this gists.