lensapp / lens

Lens - The way the world runs Kubernetes
https://k8slens.dev/
MIT License
22.5k stars 1.46k forks source link

Partial configuration do not load #3684

Open 5nafu opened 3 years ago

5nafu commented 3 years ago

Describe the bug If dividing the kubeconfig into different files, Lens will not be able to load it and does not provide syncing

To Reproduce

  1. create a config.d directory
  2. split your kube config into multiple files, each containing part of the configuration of one cluster (01_preferences, 02_context, ...)
  3. In lens add Configuration Sync of the above created directory
  4. add a KUBECONFIG environment variable with all files above and check that kubectl allows access to the cluster(s) configured
  5. The clusters will not show up in the Catalog/Clusters

Expected behavior I would expect lens to merge the configurations and present the configured clusters.

Environment (please complete the following information):

Logs: When you run the application executable from command line you will see some logging output. Please paste them here:

info: πŸ“Ÿ Setting Lens as protocol client for lens://
info: πŸ“Ÿ Protocol client register failed ❗
info: πŸš€ Starting Lens from "/home/tobias.vollmer/.config/Lens"
info: 🐚 Syncing shell environment
info: πŸ’Ύ Loading stores
info: [STORE]: LOADED from /home/tobias.vollmer/.config/Lens/lens-user-store.json
Running 2.0.0-beta.2 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Running 2.4.1 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Running 2.6.0-beta.2 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Running 2.6.0-beta.3 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Running 2.7.0-beta.0 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Running 2.7.0-beta.1 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Running 3.6.0-beta.1 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Number of clusters to migrate:  0
Running 5.0.0-beta.10 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Running 5.0.0-beta.13 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Running 5.1.3-latest.20210722.1 migration for /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
info: [STORE]: LOADED from /home/tobias.vollmer/.config/Lens/lens-cluster-store.json
Running 5.0.0-alpha.0 migration for /home/tobias.vollmer/.config/Lens/lens-hotbar-store.json
Running 5.0.0-alpha.2 migration for /home/tobias.vollmer/.config/Lens/lens-hotbar-store.json
Running 5.0.0-beta.5 migration for /home/tobias.vollmer/.config/Lens/lens-hotbar-store.json
Running 5.0.0-beta.10 migration for /home/tobias.vollmer/.config/Lens/lens-hotbar-store.json
info: [STORE]: LOADED from /home/tobias.vollmer/.config/Lens/lens-hotbar-store.json
info: [STORE]: LOADED from /home/tobias.vollmer/.config/Lens/lens-extensions.json
info: [STORE]: LOADED from /home/tobias.vollmer/.config/Lens/lens-filesystem-provisioner-store.json
Running 5.0.0-alpha.0 migration for /home/tobias.vollmer/.config/Lens/lens-weblink-store.json
Running 5.0.0-alpha.2 migration for /home/tobias.vollmer/.config/Lens/lens-weblink-store.json
Running 5.0.0-beta.5 migration for /home/tobias.vollmer/.config/Lens/lens-weblink-store.json
Running 5.0.0-beta.10 migration for /home/tobias.vollmer/.config/Lens/lens-weblink-store.json
info: [STORE]: LOADED from /home/tobias.vollmer/.config/Lens/lens-weblink-store.json
info: πŸ”Œ Starting LensProxy
info: [LENS-PROXY]: Proxy server has started at 127.0.0.1:45761
info: πŸ”Ž Testing LensProxy connection ...
info: ⚑ LensProxy connection OK
info: πŸ–₯  Starting WindowManager
APPIMAGE env is not defined, current application is not an AppImage
info: 🧩 Initializing extensions
info: [EXTENSION-DISCOVERY] loading extensions from /home/tobias.vollmer/.config/Lens
info: [EXTENSION-INSTALLER] installing dependencies at /home/tobias.vollmer/.config/Lens
info: [WINDOW-MANAGER]:Β Loading Main window from url: http://localhost:45761 ...
info: [EXTENSION-INSTALLER] dependencies installed at /home/tobias.vollmer/.config/Lens
info: [EXTENSION-DISCOVERY] watching extension add/remove in /home/tobias.vollmer/.k8slens/extensions
Native extraction module not loaded, msgpackr will still run, but with decreased performance. Cannot find module 'msgpackr-extract'
Lens Cloud Extension activated
info: [STORE]: LOADED from /home/tobias.vollmer/.config/Lens/extension-store/lenscloud-lens-extension/auth-token-store.json
info: [STORE]: LOADED from /home/tobias.vollmer/.config/Lens/extension-store/lens-survey/preferences-store.json
telemetry main extension activated
info: [STORE]: LOADED from /home/tobias.vollmer/.config/Lens/extension-store/lens-telemetry/preferences-store.json
info: [EXTENSION]: enabled lens-license@5.1.3-latest.20210722.1
info: [EXTENSION]: enabled lens-survey@5.1.3-latest.20210722.1
info: [EXTENSION]: enabled lens-telemetry@5.1.3-latest.20210722.1
[CLUSTER-CONNECT] cluster proxy started on port 39947
[CLUSTER-CONNECT] cluster proxy is using aes-256-gcm for end-to-end encryption
info: [STORE]: SAVING /home/tobias.vollmer/.config/Lens/lens-filesystem-provisioner-store.json
info: [EXTENSION]: enabled lenscloud-lens-extension@5.1.3-latest.20210722.1
info: [KUBECONFIG-SYNC]: starting requested syncs
info: πŸ“‘ Checking for app updates
info: Checking for update
info: [KUBECONFIG-SYNC]: starting sync of file/folder {"filePath":"/home/tobias.vollmer/.config/Lens/kubeconfigs"}
info: [KUBECONFIG-SYNC]: starting sync of file/folder {"filePath":"/home/tobias.vollmer/.kube"}
info: [KUBECONFIG-SYNC]: starting sync of file/folder {"filePath":"/home/tobias.vollmer/.kube/config.d"}
error: Error: Error: ENOENT: no such file or directory, open '/opt/Lens/resources/app-update.yml'
error: [UPDATE-CHECKER]: failed with an error {"error":"Error: ENOENT: no such file or directory, open '/opt/Lens/resources/app-update.yml'"}
warn: [KUBECONFIG-SYNC]: encountered errors while loading config: "value" must be of type object {"filePath":"/home/tobias.vollmer/.kube/kubectx","details":[{"message":"\"value\" must be of type object","path":[],"type":"object.base","context":{"type":"object","label":"value","value":"prc-devplayground"}}]}
info: [WINDOW-MANAGER]: Main window loaded
info: [WINDOW-MANAGER]: Main window has reported that it has loaded

Kubeconfig: Quite often the problems are caused by malformed kubeconfig which the application tries to load. Please share your kubeconfig, remember to remove any secret and sensitive information.

Additional context We have (multiple) Rancher cluster with different downstream kubernetes clusters. The Rancher system is working as an authentication proxy, resulting in the same user/token being used in multiple contexts. Additionally we do have testing accounts for different access levels to the clusters, resulting in multiple cluster configurations being used in multiple contexts as well.

To be able to more easily rotate tokens (more often) or URLs (less often), we divide the configuration into multiple files, each containing only a single component. kubectl (and other tools) are able to read those file and merge the config even over file boundaries.

Nokel81 commented 3 years ago

Would having the merge only occur within a single folder sync be an acceptable solution? We don't look at the KUBECONFIG env var at all. Though I guess we could.


Note to future implementer:

After playing around with kubectl config view it seems like the merge rules prefer the order that the files are specified and ignore duplicates from subsequent files.

5nafu commented 3 years ago

Hi @Nokel81, thanks for your answer, for our usecase this would be absolutely fine, though I can not say if others may sort the configuration differently.

brad-jones commented 3 years ago

Yes please honor KUBECONFIG, I also just installed https://k9scli.io/ & it worked out of the box with zero config. If I want to use Lens I now need to maintain two sets of config, not ideal.

tgruenert commented 2 years ago

IΒ΄ve run in this case today. My scenario is sharing configuration files without any user specific credentials. These are not necessary if using OIDC auth. So i have one config file for user to authenticate via oidc (kubelogin) and one file per cluster which refers to user. So it would be really nice to see a solution for splittet config files.