redhat-developer / intellij-kubernetes

IntelliJ Kubernetes plugin
https://plugins.jetbrains.com/plugin/15921-kubernetes-by-red-hat
Eclipse Public License 2.0
20 stars 19 forks source link

Cannot get my clusters to appear #779

Open creckord opened 1 month ago

creckord commented 1 month ago

I have been using the Jetbrains Kubernetes plugin on and off for a while now, and have several clusters added in IntelliJ.

I wanted to give the Redhat Kubernetes plugin a shot, because really, the Jetbrains one is too clunky as my main k8s console (coming from OpenLens).

Unfortunately, all I got from the Redhat plugin was a long time of cluster resource refreshing, but at the end, the Kubernetes tool window just stayed empty. No errors in the logs either.

IntelliJ IDEA 2024.1.4 (Ultimate Edition) Build #IU-241.18034.62 Redhat Kubernetes Plugin 1.3.0 OpenJDK 64-Bit Server VM by JetBrains s.r.o. Runtime version: 17.0.11+1-b1207.24 amd64

creckord commented 1 month ago

Hm, actually, looking at a fresh log from a recently restarted IDEA, I get a whole bunch of these from the IntelliJ Kubernetes provider:

2024-08-02 20:43:38,680 [   5436]   INFO - #c.i.k.a.KubernetesApiProvider - Configuration refresh started
2024-08-02 20:43:38,951 [   5707]   WARN - #c.i.k.a.KubernetesApiProvider - Configuration not loaded: Context 'prod-gcp-star' not found in contexts list [], kubeconfig file: file://C:/Users/creckord/.kube/config
2024-08-02 20:43:38,953 [   5709]   INFO - #c.i.k.a.KubernetesApiProvider - Configuration loaded: ContextsConfiguration(contexts={kind-kind=Context(name=kind-kind, kubeConfigUrl=file://C:/Users/creckord/.kube/kind-k8s.yaml, originalNamespace=apicurio, clusterPath=null), microk8s=Context(name=microk8s, kubeConfigUrl=file://C:/Users/creckord/.kube/microk8s.yaml, originalNamespace=kubebox, clusterPath=null), prod-dc=Context(name=prod-dc, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-dc.yaml, originalNamespace=ars, clusterPath=null), prod-dc-back01=Context(name=prod-dc-back01, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-dc.yaml, originalNamespace=ars, clusterPath=null), dpa-analytics=Context(name=dpa-analytics, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-onprem-analytics.yaml, originalNamespace=star-spark-analytics, clusterPath=null), prod-onprem=Context(name=prod-onprem, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-onprem.yaml, originalNamespace=ermittlungsbericht-archiv, clusterPath=null), prod-gcp-common=Context(name=prod-gcp-common, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-gcp-common.yaml, originalNamespace=sentry, clusterPath=null), prod-gcp-star=Context(name=prod-gcp-star, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-gcp-star.yaml, originalNamespace=kafka, clusterPath=null), test-onprem-oracle=Context(name=test-onprem-oracle, kubeConfigUrl=file://C:/Users/creckord/.kube/test-onprem-oracle.yaml, originalNamespace=oracle-database-enterprise-edition, clusterPath=null), test-onprem=Context(name=test-onprem, kubeConfigUrl=file://C:/Users/creckord/.kube/test-onprem.yaml, originalNamespace=ars-selenium1, clusterPath=null)}, kubeConfig=KubeConfigEx(contexts=[{context={cluster=kind-kind, namespace=apicurio, user=kind-kind}, name=kind-kind}, {context={cluster=microk8s-cluster, namespace=kubebox, user=admin}, name=microk8s}, {context={cluster=prod-dc-back01, namespace=ars, user=arvato-back01}, name=prod-dc}, {context={cluster=prod-dc-back01, namespace=ars, user=arvato-back ...
2024-08-02 20:43:39,313 [   6069]   INFO - #c.i.k.a.KubernetesApiProvider - Configuration applied to executor
2024-08-02 20:43:39,353 [   6109]   INFO - #c.i.k.a.KubernetesApiProvider - Model added: KubernetesApiModel(currentContextObject=Context(name=dpa-analytics, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-onprem-analytics.yaml, originalNamespace=star-spark-analytics, clusterPath=null))
2024-08-02 20:43:39,354 [   6110]   INFO - #c.i.k.a.KubernetesApiProvider - Model added: KubernetesApiModel(currentContextObject=Context(name=microk8s, kubeConfigUrl=file://C:/Users/creckord/.kube/microk8s.yaml, originalNamespace=kubebox, clusterPath=null))
2024-08-02 20:43:39,354 [   6110]   INFO - #c.i.k.a.KubernetesApiProvider - Model added: KubernetesApiModel(currentContextObject=Context(name=prod-onprem, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-onprem.yaml, originalNamespace=ermittlungsbericht-archiv, clusterPath=null))
2024-08-02 20:43:39,354 [   6110]   INFO - #c.i.k.a.KubernetesApiProvider - Model added: KubernetesApiModel(currentContextObject=Context(name=prod-gcp-common, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-gcp-common.yaml, originalNamespace=sentry, clusterPath=null))
2024-08-02 20:43:39,356 [   6112]   INFO - #c.i.k.a.KubernetesApiProvider - Model added: KubernetesApiModel(currentContextObject=Context(name=test-onprem, kubeConfigUrl=file://C:/Users/creckord/.kube/test-onprem.yaml, originalNamespace=ars-selenium1, clusterPath=null))
2024-08-02 20:43:39,356 [   6112]   INFO - #c.i.k.a.KubernetesApiProvider - Model added: KubernetesApiModel(currentContextObject=Context(name=test-onprem-oracle, kubeConfigUrl=file://C:/Users/creckord/.kube/test-onprem-oracle.yaml, originalNamespace=oracle-database-enterprise-edition, clusterPath=null))
2024-08-02 20:43:39,356 [   6112]   INFO - #c.i.k.a.KubernetesApiProvider - Model added: KubernetesApiModel(currentContextObject=Context(name=prod-gcp-star, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-gcp-star.yaml, originalNamespace=kafka, clusterPath=null))
2024-08-02 20:43:39,358 [   6114]   INFO - #c.i.k.a.KubernetesApiProvider - Model added: KubernetesApiModel(currentContextObject=Context(name=prod-dc, kubeConfigUrl=file://C:/Users/creckord/.kube/prod-dc.yaml, originalNamespace=ars, clusterPath=null))
2024-08-02 20:43:39,358 [   6114]   INFO - #c.i.k.a.KubernetesApiProvider - Configuration refresh finished
2024-08-02 20:43:39,359 [   6115]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/microk8s.yaml
2024-08-02 20:43:39,360 [   6116]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-dc.yaml
2024-08-02 20:43:39,360 [   6116]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-onprem-analytics.yaml
2024-08-02 20:43:39,360 [   6116]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-onprem.yaml
2024-08-02 20:43:39,360 [   6116]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-gcp-common.yaml
2024-08-02 20:43:39,360 [   6116]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-gcp-star.yaml
2024-08-02 20:43:39,360 [   6116]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/test-onprem-oracle.yaml
2024-08-02 20:43:39,361 [   6117]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/test-onprem.yaml
2024-08-02 20:43:39,361 [   6117]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-gcp-star.yaml
2024-08-02 20:43:39,361 [   6117]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-gcp-common.yaml
2024-08-02 20:43:39,361 [   6117]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-onprem.yaml
2024-08-02 20:43:39,361 [   6117]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-onprem-analytics.yaml
2024-08-02 20:43:39,361 [   6117]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/prod-dc.yaml
2024-08-02 20:43:39,362 [   6118]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/microk8s.yaml
2024-08-02 20:43:39,362 [   6118]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/test-onprem.yaml
2024-08-02 20:43:39,362 [   6118]   INFO - #c.i.k.m.KubeConfigWatcher - Raw path stored instead of a URL: C:/Users/creckord/.kube/test-onprem-oracle.yaml
2024-08-02 20:43:39,363 [   6119]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:39,363 [   6119]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:39,364 [   6120]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:39,364 [   6120]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:39,364 [   6120]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:39,364 [   6120]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:39,365 [   6121]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:39,365 [   6121]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:39,366 [   6122]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:39,366 [   6122]   INFO - #c.i.k.m.KubeConfigWatcher - Watcher started for: C:\Users\creckord\.kube
2024-08-02 20:43:42,460 [   9216]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-onprem-analytics.yaml
2024-08-02 20:43:42,460 [   9216]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\microk8s.yaml
2024-08-02 20:43:42,460 [   9216]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-onprem.yaml
2024-08-02 20:43:42,460 [   9216]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-gcp-common.yaml
2024-08-02 20:43:42,460 [   9216]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\test-onprem.yaml
2024-08-02 20:43:42,460 [   9216]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\test-onprem-oracle.yaml
2024-08-02 20:43:42,460 [   9216]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-gcp-star.yaml
2024-08-02 20:43:42,460 [   9216]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-dc.yaml
2024-08-02 20:44:17,805 [  44561]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-onprem-analytics.yaml
2024-08-02 20:44:17,805 [  44561]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\microk8s.yaml
2024-08-02 20:44:17,805 [  44561]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-onprem.yaml
2024-08-02 20:44:17,805 [  44561]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-gcp-common.yaml
2024-08-02 20:44:17,805 [  44561]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\test-onprem.yaml
2024-08-02 20:44:17,805 [  44561]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\test-onprem-oracle.yaml
2024-08-02 20:44:17,805 [  44561]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-gcp-star.yaml
2024-08-02 20:44:17,805 [  44561]   INFO - #c.i.k.m.KubeConfigWatcher - Not a regular file: \\C\Users\creckord\.kube\prod-dc.yaml

The IntelliJ Kubernetes integration works just fine, though.

I guess this could be related to how my clusters are set up:

I have a nearly empty .kube/config which basically just holds the current-context:

apiVersion: v1
clusters: null
contexts: null
current-context: prod-gcp-star
kind: Config
preferences: {}
users: null

and then one separate config file for each cluster, each without the current-context key present:

apiVersion: v1
clusters:
- cluster:
  name: gke_team-star_europe-west3-a
  ...
contexts:
- context:
    cluster: gke_team-star_europe-west3-a
    namespace: kafka
    user: gke_team-star_europe-west3-a
  name: prod-gcp-star
kind: Config
preferences: {}
users:
- name: gke_star_europe-west3-a
  user:
    ...

At the command line, with kubectl, this is all tied together through the KUBECONFIG env variable that holds .kube/config and all cluster configs. In IntelliJ, lacking KUBECONFIG support, I just added all the separate configs (sans the .kube/config, which does not include a cluster).

adietish commented 1 month ago

Hi @creckord

Thanks for reporting this! This seems particularly valuable given your non-standard setup of kubeconfig. At first glance such setup seems to make perfect sense if one has lots of clusters. I'm looking into it, trying to fix it for the next release 😄

adietish commented 1 month ago

@creckord I need to replicate it but at first glance I'd guess that our plugin would not detect those cluster files. There's a possibility to set things up via system vars though. I'll look into it and report back.

adietish commented 1 month ago

for my own documentation purposes:

To set the KUBECONFIG env var one has to list all files and the main conf separated by ":" (see https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#append-home-kube-config-to-your-kubeconfig-environment-variable)

export KUBECONFIG="${HOME}/.kube/config:${HOME}/.kube/minikube.yaml:${HOME}/.kube/sandbox.yaml
adietish commented 1 month ago

This is related to https://github.com/fabric8io/kubernetes-client/issues/2174 I filed https://github.com/fabric8io/kubernetes-client/issues/6240

adietish commented 1 month ago

@creckord: A fix for https://github.com/fabric8io/kubernetes-client/issues/6240 shouldn't be too complicated, I'm working on it. It could take quite some time for the new client to be released though and our 2 plugins bumped to it (a limitation in the intellij platform requires us to use the same client across all our plugins). Crossing fingers 😄

creckord commented 1 month ago

@adietish thanks for looking into this. If you want me to try out a build, let me know.

adietish commented 1 month ago

@creckord awesomeness, if you can check the fixed build, once we have it, that would be stellar. I'll keep you posted. We'll first release a new version and then fix your issue. I have a POC but special care is needed to not break backward compatibility (as pointed out in https://github.com/fabric8io/kubernetes-client/issues/6240#issuecomment-2287854615).

adietish commented 1 week ago

@creckord Looks like I have a fix. Will test throughout tomorrow and if things look good I'll have a zip for you that you can download and install if you want :)