ckt114 / kubeswitch

Kubernetes context and namspace switcher.
Apache License 2.0
16 stars 1 forks source link

GKE: no Auth Provider found for name "gcp" #2

Closed adamzr closed 3 years ago

adamzr commented 3 years ago

Trying to use Kubeswitch with GKE and I get this error trying to switch namespaces:

no Auth Provider found for name "gcp"

ckt114 commented 3 years ago

@adamzr That error seems like an issue with your kube config file. Can you test using that kube config file without using Kubeswitch and see if you can get namespaces? Do an export KUBECONFIG=/path/to/config then kubectl get ns. Looks like for that gcp context you don’t have an authentication method attached to it.

adamzr commented 3 years ago

@trankchung I didn't have KUBECONFIG set. I set it. Then I ran kubectl get ns which worked fine. Kubeswitch still gives me the same error.

ghost commented 3 years ago

@adamzr Do you mind try the latest version?

adamzr commented 3 years ago

Still doesn't work:

$ kubeswitch --version
v0.2.3
$ kubeswitch ns
no Auth Provider found for name "gcp"
ghost commented 3 years ago

Once in a Kubeswitch session, can you cat $KUBECONFIG and paste the content here? You can mask out sensitive info. I want to see the auth section of the config.

adamzr commented 3 years ago

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: <REDACTED LONG BASE64 LOOKING STRING>
    server: https://<REDACTED IP>
  name: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
- cluster:
    certificate-authority-data: <REDACTED LONG BASE64 LOOKING STRING>
    server: https://<REDACTED IP>
  name: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
- cluster:
    certificate-authority-data: <REDACTED LONG BASE64 LOOKING STRING>
    server: https://<REDACTED IP>
  name: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
contexts:
- context:
    cluster: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
    namespace: <REDACTED CLUSTER NAME>
    user: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
  name: <REDACTED CLUSTER NAME>
- context:
    cluster: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
    user: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
  name: <REDACTED CLUSTER NAME>
- context:
    cluster: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
    user: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
  name: <REDACTED CLUSTER NAME>
current-context: <REDACTED CLUSTER NAME>
kind: Config
preferences: {}
users:
- name: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
  user:
    auth-provider:
      config:
        access-token: <REDACTED ACCESS TOKEN>
        cmd-args: config config-helper --format=json
        cmd-path: /Users/<REDACTED>/google-cloud-sdk/bin/gcloud
        expiry: "2021-02-15T17:58:56Z"
        expiry-key: '{.credential.token_expiry}'
        token-key: '{.credential.access_token}'
      name: gcp
- name: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
  user:
    auth-provider:
      config:
        access-token: <REDACTED ACCESS TOKEN>
        cmd-args: config config-helper --format=json
        cmd-path: /Users/<REDACTED>/google-cloud-sdk/bin/gcloud
        expiry: "2021-02-15T20:37:24Z"
        expiry-key: '{.credential.token_expiry}'
        token-key: '{.credential.access_token}'
      name: gcp
- name: gke_<REDACTED CLUSTER NAME>_us-west1-c_<REDACTED CLUSTER NAME>
  user:
    auth-provider:
      config:
        access-token: <REDACTED ACCESS TOKEN>
        cmd-args: config config-helper --format=json
        cmd-path: /Users/<REDACTED>/google-cloud-sdk/bin/gcloud
        expiry: "2021-01-19T02:46:23Z"
        expiry-key: '{.credential.token_expiry}'
        token-key: '{.credential.access_token}'
      name: gcp
ckt114 commented 3 years ago

The config looks fine. Looks like this is an issue with client-go library, link below, that’s used by Kubeswitch. I’ll try to use a newer client-go version and see if it’ll fix the problem.

https://github.com/sunny0826/kubecm/issues/17

ckt114 commented 3 years ago

@adamzr I just tried it with my GKE account and I'm able to get namespaces and all resources fine. Can you run kubectl version --client --short and see what version you're using? I'm using Client Version: v1.18.0 and it's working fine.

ckt114 commented 3 years ago

@adamzr Sorry I actually was able to reproduce the error. I'll work on getting it working hopefully soon.

ckt114 commented 3 years ago

@adamzr Please try newest version. https://github.com/trankchung/kubeswitch/releases/tag/v0.2.4

adamzr commented 3 years ago

That works! Thanks @trankchung !