k8sgpt-ai / k8sgpt-operator

Automatic SRE Superpowers within your Kubernetes cluster
https://k8sgpt.ai
Apache License 2.0
279 stars 76 forks source link

[Question]: Use K8SGPT deployed in one cluster to analyze another cluster #391

Closed kodefoundry closed 3 months ago

kodefoundry commented 3 months ago

Assume we have 2 independent kubernetes clusters. Lets say we create 2 clusters using Kind named Kind-K8sGPT and another Kind-App Now

  1. I deploy k8sgpt using operator on Kind-K8sGPT cluster
  2. I deploy my sample demo application in the Kind-App cluster
  3. I follow Monitor multiple clusters, idea and configure Kind-App cluster's kubeconfig as a secret in Kind-K8sGPT cluster.

Expectation: k8sgpt in Kind-K8sGPT cluster should be able to analyze Kind-App cluster and provide the results when I query "kubectl get results -o json -n k8sgpt | jq ."

Is this supposed to work?

I tried this, but it failed. I see the below errors in the logs

{"level":"info","ts":1711620947.095757,"caller":"server/server.go:68","msg":"binding api to 8080"} {"level":"info","ts":1711620947.0958636,"caller":"server/server.go:83","msg":"binding metrics to 8081"} Error initialising kubernetes client: Get "https://***.**.*.*:443/version": dial tcp ***.**.*.*:443: i/o timeout {"level":"info","ts":1711621006.1122108,"caller":"server/log.go:50","msg":"request failed. Get \"https://***.**.*.*:443/version\": dial tcp ***.**.*.*:443: i/o timeout","duration_ms":30028,"method":"/schema.v1.ServerService/Analyze","request":"backend:\"localai\" anonymize:true language:\"english\" max_concurrency:10 output:\"json\"","remote_addr":"**.**.*.*:51936","status_code":2} Error initialising kubernetes client: Get "https://***.**.*.*:443/version": dial tcp ***.**.*.*:443: i/o timeout {"level":"info","ts":1711621036.158368,"caller":"server/log.go:50","msg":"request failed. Get \"https://***.**.*.*:443/version\": dial tcp ***.**.*.*:443: i/o timeout","duration_ms":30030,"method":"/schema.v1.ServerService/Analyze","request":"backend:\"localai\" anonymize:true language:\"english\" max_concurrency:10 output:\"json\"","remote_addr":"**.**.*.*:50820","status_code":2} Error initialising kubernetes client: Get "https://***.**.*.*:443/version": dial tcp ***.**.*.*:443: i/o timeout {"level":"info","ts":1711621066.2082016,"caller":"server/log.go:50","msg":"request failed. Get \"https://***.**.*.*:443/version\": dial tcp ***.**.*.*:443: i/o timeout","duration_ms":30028,"method":"/schema.v1.ServerService/Analyze","request":"backend:\"localai\" anonymize:true language:\"english\" max_concurrency:10 output:\"json\"","remote_addr":"**.**.*.*:57588","status_code":2} Error initialising kubernetes client: Get "https://***.**.*.*:443/version": dial tcp ***.**.*.*:443: i/o timeout {"level":"info","ts":1711621096.2409728,"caller":"server/log.go:50","msg":"request failed. Get \"https://***.**.*.*:443/version\": dial tcp ***.**.*.*:443: i/o timeout","duration_ms":30001,"method":"/schema.v1.ServerService/Analyze","request":"backend:\"localai\" anonymize:true language:\"english\" max_concurrency:10 output:\"json\"","remote_addr":"**.**.*.*:48490","status_code":2} Error initialising kubernetes client: Get "https://***.**.*.*:443/version": dial tcp ***.**.*.*:443: i/o timeout

kodefoundry commented 3 months ago

Can someone provide some inputs to debug, where to start looking??

JuHyung-Son commented 3 months ago

i think this is network issue. check two clusters can communicate each other

kodefoundry commented 3 months ago

Yes this was an issue with kubeconfig. It worked after had the kubeconfig fixed

kodefoundry commented 3 months ago

I am able to scan other clusters k8sgpt deployed in a separate cluster