Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot analyze GKE environment #133

Closed
hapham1701 opened this issue Mar 29, 2023 · 13 comments
Closed

Cannot analyze GKE environment #133

hapham1701 opened this issue Mar 29, 2023 · 13 comments
Labels
question Further information is requested

Comments

@hapham1701
Copy link

hapham1701 commented Mar 29, 2023

I'm facing this issue while running command: k8sgpt analyze on Macos arm64 and connecting to GKE.

Error initialising kubernetes client: no Auth Provider found for name "gcp"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x101e6c600]

@thschue thschue changed the title Error initialising kubernetes client: no Auth Provider found for name "gcp" panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x101e6c600]question: Cannot analyze GKE environment Mar 29, 2023
@thschue thschue added the question Further information is requested label Mar 29, 2023
@thschue
Copy link
Contributor

thschue commented Mar 29, 2023

Hello @hapham1701!

Unfortunately, I could not reproduce your issue. Authenticated on a cluster using

gcloud container clusters get-credentials ******** --zone ********** --project ******** 

and could analyze without problems. Please provide a bit more information on your configuration, e.g., some obfuscated information about your kube context. Thank you!

@hapham1701
Copy link
Author

this is full error:
Error initialising kubernetes client: no Auth Provider found for name "gcp"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x103d0c600]

goroutine 1 [running]:
github.com/k8sgpt-ai/k8sgpt/pkg/analyzer.AnalyzePod({0x104311018, 0x14000134010}, 0x14000257bb8, 0x0, {0x10?, 0x103d31816?}, 0x14000257ba0)
/home/runner/work/k8sgpt/k8sgpt/pkg/analyzer/podAnalyzer.go:17 +0x40
github.com/k8sgpt-ai/k8sgpt/pkg/analyzer.RunAnalysis({0x104311018, 0x14000134010}, 0x33?, 0x103d1d9f0?, {0x1043001a8, 0x1400042cb28}, 0x1040e0020?)
/home/runner/work/k8sgpt/k8sgpt/pkg/analyzer/analyzer.go:18 +0x38
github.com/k8sgpt-ai/k8sgpt/cmd/analyze.glob..func1(0x104ead1a0?, {0x103d1bc51?, 0x0?, 0x0?})
/home/runner/work/k8sgpt/k8sgpt/cmd/analyze/analyze.go:80 +0x30c
github.com/spf13/cobra.(*Command).execute(0x104ead1a0, {0x104ef9f68, 0x0, 0x0})
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920 +0x5ac
github.com/spf13/cobra.(*Command).ExecuteC(0x104eacbe0)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x340
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/k8sgpt-ai/k8sgpt/cmd.Execute({0x103f40730?, 0x140000021a0?})
/home/runner/work/k8sgpt/k8sgpt/cmd/root.go:36 +0x58
main.main()
/home/runner/work/k8sgpt/k8sgpt/main.go:11 +0x2c

@thschue
Copy link
Contributor

thschue commented Mar 29, 2023

As written before, please add some more information about your configuration.

e.g. kubectl config view (for your current context).

@AlexsJones
Copy link
Member

If you could print your ~/.k8sgpt.yaml ( omitting your key for openAI) we could see what's going on.. the auth backend shouldn't be giving that error at all.

@hapham1701
Copy link
Author

hapham1701 commented Mar 29, 2023

result : cat ~/.k8sgpt.yaml

backend_type: openai
kubernetesclient: null
openai_key:xxxxxxxxxx

@matthisholleville
Copy link
Contributor

@hapham1701 Do you have gcloud properly installed/configured on your environment ?

@hapham1701
Copy link
Author

This is information about gcloud and kubectl, which i have already installed on my laptop. Please feel free to ask me if you need any further information:

gcloud version

Google Cloud SDK 423.0.0
alpha 2023.03.17
beta 2023.03.17
bq 2.0.88
config-connector 1.93.0
core 2023.03.17
gsutil 5.21
Updates are available for some Google Cloud CLI components. To install them,
please run:
$ gcloud components update

To take a quick anonymous survey, run:
$ gcloud survey


~ kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.0", GoVersion:"go1.17.3", Compiler:"gc", Platform:"darwin/arm64"}

Server Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.9-gke.3200", GoVersion:"go1.18.9b7", Compiler:"gc", Platform:"linux/amd64"}

@hapham1701
Copy link
Author

hapham1701 commented Mar 30, 2023

Hi @thschue This is the result of the command: kubectl config view

  • name: xxxxxxx
    user:
    auth-provider:
    config:
    access-token: xxxxx
    cmd-args: config config-helper --format=json
    cmd-path: /opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin/gcloud
    expiry: "xxxxxx"
    expiry-key: '{.credential.token_expiry}'
    token-key: '{.credential.access_token}'
    name: gcp

@matthisholleville
Copy link
Contributor

@hapham1701 can you try to run : gcloud components install gke-gcloud-auth-plugin please ?

@matthisholleville
Copy link
Contributor

I have set up a clean environment on Debian, and I had no issues.

gcloud container clusters get-credentials xxx --region xxx --project xxx

Here's my configuration:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://xxxxx
  name: gcp
contexts:
- context:
    cluster: gcp
    user: gcp
  name: gcp
current-context: gcp
kind: Config
preferences: {}
users:
- name: gcp
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args: null
      command: gke-gcloud-auth-plugin
      env: null
      installHint: Install gke-gcloud-auth-plugin for use with kubectl by following
        https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
      interactiveMode: IfAvailable
      provideClusterInfo: true

Here's my version of gcloud:

root@xxxx:~/.kube# gcloud version
Google Cloud SDK 424.0.0
alpha 2023.03.24
beta 2023.03.24
bq 2.0.89
bundled-python3-unix 3.9.16
core 2023.03.24
gcloud-crc32c 1.0.0
gke-gcloud-auth-plugin 0.5.2
gsutil 5.21

I think you need to use gke-gcloud-auth-plugin as authentication method.

@hapham1701
Copy link
Author

hapham1701 commented Mar 31, 2023

Here's my version of gcloud:

~ gcloud version
Google Cloud SDK 423.0.0
alpha 2023.03.17
beta 2023.03.17
bq 2.0.88
config-connector 1.93.0
core 2023.03.17
gke-gcloud-auth-plugin 0.5.2
gsutil 5.21


After install gke-gcloud-auth-plugin, The error still exists.

@hapham1701
Copy link
Author

It worked after I upgraded ver chatgpt to 0.1.6 and ran the command 'gcloud container clusters get-credentials xxx --region xxx --project xxx'. I don't know why I needed to get credentials even though they already existed.
Thank you for your support.

@thschue thschue closed this as completed Apr 1, 2023
@umiyosh
Copy link

umiyosh commented Apr 21, 2023

I experienced the same problem, but I can confirm that it is recovered by installing and activating the gke-gcloud-auth-plugin described in the discussion here. It is important to note that the problem will not be solved without installing, activating and getting credentials for the gke-gcloud-auth-plugin, as I found out when I checked the operation. Therefore, to solve the problem, you need to execute all of the following commands.

% gcloud components install gke-gcloud-auth-plugin
-> gke-gcloud-auth-plugin will be installed
% export USE_GKE_GCLOUD_AUTH_PLUGIN=True
-> gke-gcloud-auth-plugin will be activated
% gcloud container clusters get-credentials xxx --region xxx --project xxx
-> Credentials will be obtained by authentication with gke-gcloud-auth-plugin
% k8sgpt analyse
-> You will be able to see that the problem has been resolved.

A change in the kubectl authentication method causes this problem. You can read the details in the following document.
https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke?hl=en

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants