How do I install gke-gcloud-auth-plugin on a Mac M1 with zsh
Asked Answered
K

3

41

I try to install gke-gcloud-auth-plugin on a Mac M1 with zsh, following the gcloud docs.

The installation ran without issue and trying to re-run gcloud components install gke-gcloud-auth-plugin I get the All components are up to date. message.

However, gke-gcloud-auth-plugin --version returns zsh: command not found: gke-gcloud-auth-plugin. kubectl, installed the same way, works properly.

I tried to install kubectl using brew, with no more success.

Kowalewski answered 28/10, 2022 at 9:34 Comment(2)
I'm in the same boat, but on an Intel Mac using bash...Dutyfree
On the positive side, the probability to find someone to save us is higher if the issue occurs on different setupsKowalewski
A
10

Not sure if it is the same on macOS. Can you try the following:

export USE_GKE_GCLOUD_AUTH_PLUGIN=True

Then reload the Cluster with

gcloud container clusters get-credentials clustername

Guess it is installed but just not used.

Maybe you just need to add the directory where to find your gke-gcloud-auth-plugin file to your PATH.

Is it working when you call it wirh absolute path?

path/to/gke-gcloud-auth-plugin --version

to find the file use the following command:

sudo find / -name gke-gcloud-auth-plugin
Armchair answered 29/10, 2022 at 18:28 Comment(4)
Thank you, I tried but it did not work. I also assume that this could be solved using the absolute path - but this is the point: I have no idea where it is installed. I noticed that it is not the same one for all the gcloud components. kubectl was installed in /usr/local/bin/kubectl for instance.Kowalewski
Try: sudo find / -name gke-gcloud-auth-pluginArmchair
Thank you ! I found it this way and I created a symbolic link to a folder my PATH. Everything works now. I accepted your answer, but how can I make your suggestion n the comments more visible?Kowalewski
Happy to hear it helped. I will add it in my answer. ThanksArmchair
H
42

I had the same error and here's how I fixed it.

brew info google-cloud-sdk

which produces:

To add gcloud components to your PATH, add this to your profile:

  for bash users
    source "$(brew --prefix)/share/google-cloud-sdk/path.bash.inc"

  for zsh users
    source "$(brew --prefix)/share/google-cloud-sdk/path.zsh.inc"
    source "$(brew --prefix)/share/google-cloud-sdk/completion.zsh.inc"

  for fish users
    source "$(brew --prefix)/share/google-cloud-sdk/path.fish.inc"

Grab the code for your terminal and then run it (e.g., for zsh)

source "$(brew --prefix)/share/google-cloud-sdk/path.zsh.inc"

Add the above line to your .zshrc profile to make sure that it is loaded every time you open a new terminal.

I had originally installed gcloud sdk with homebrew brew install google-cloud-sdk. At that time, I read the Caveats, which tell you how to add gcloud components to your PATH.

I installed both kubectl and gke-gcloud-auth-plugin, and neither of them could be found from the command line. I got the same error as the OP "command not found"

Helmand answered 8/12, 2022 at 16:9 Comment(4)
worked for me with a slightly different path: /opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.incKlatt
did you just copy and paste that path in .zshrc?Tricky
@Tricky - yes, copy and paste the 2 lines for zsh into your .zshrc without changing them.Helmand
For me also worked custom path - "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc". I found it in output of "brew info google-cloud-sdk" command.Order
B
36
gcloud components install gke-gcloud-auth-plugin

here we go: enter image description here

Burthen answered 17/3, 2023 at 19:15 Comment(2)
This works perfectly. CheersInaudible
With Mac m1 I received error: ModuleNotFoundError: No module named 'imp'Visconti
A
10

Not sure if it is the same on macOS. Can you try the following:

export USE_GKE_GCLOUD_AUTH_PLUGIN=True

Then reload the Cluster with

gcloud container clusters get-credentials clustername

Guess it is installed but just not used.

Maybe you just need to add the directory where to find your gke-gcloud-auth-plugin file to your PATH.

Is it working when you call it wirh absolute path?

path/to/gke-gcloud-auth-plugin --version

to find the file use the following command:

sudo find / -name gke-gcloud-auth-plugin
Armchair answered 29/10, 2022 at 18:28 Comment(4)
Thank you, I tried but it did not work. I also assume that this could be solved using the absolute path - but this is the point: I have no idea where it is installed. I noticed that it is not the same one for all the gcloud components. kubectl was installed in /usr/local/bin/kubectl for instance.Kowalewski
Try: sudo find / -name gke-gcloud-auth-pluginArmchair
Thank you ! I found it this way and I created a symbolic link to a folder my PATH. Everything works now. I accepted your answer, but how can I make your suggestion n the comments more visible?Kowalewski
Happy to hear it helped. I will add it in my answer. ThanksArmchair

© 2022 - 2024 — McMap. All rights reserved.