lens icon indicating copy to clipboard operation
lens copied to clipboard

When a config context has no namespace, it doesn't appear in the menu.

Open BladeMF opened this issue 5 months ago • 3 comments

Describe the bug When a config context has no namespace (namespace: ~), it doesn't appear in the menu. If the namespace is deleted it appears, but it refuses to connect with "Invalid credentials".

To Reproduce Import a kubeconfig without a namespace.

Expected behavior To see my cluster and be able to connect.

Screenshots

Environment (please complete the following information):

  • Lens Version: 2025.6.261308-latest
  • OS: [e.g. OSX] Ubuntu
  • Installation method (e.g. snap or AppImage in Linux):

Logs: When you run the application executable from command line you will see some logging output. Please paste them here: (These are the logs when I edit the file. It clearly monitors it).

2025-07-15T11:42:23.068Z debug: 	[KUBE-CONFIG-SYNC-MANAGER]: file changed { filePath: '/home/<redacted>/Dev/.tools/kubeconfigs/20250709/service.yaml' }
2025-07-15T11:42:23.070Z debug: 	[KUBE-CONFIG-SYNC-MANAGER]: File now has 0 entries { filePath: '/home/<redacted>/Dev/.tools/kubeconfigs/20250709/service.yaml' }
2025-07-15T11:42:23.070Z debug: 	[KUBE-CONFIG-SYNC-MANAGER]: Finished computing diff { filePath: '/home/<redacted>/Dev/.tools/kubeconfigs/20250709/service.yaml' }

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.

apiVersion: v1
clusters:
- name: kubernetes-service
  cluster:
    certificate-authority-data: <redacted>
    server: https://<redacted>:<redacted>
contexts:
- name: kubernetes-service
  context:
    cluster: kubernetes-service
    namespace: ~
    user: kubernetes-service
current-context: kubernetes-service
kind: Config
users:
- name: kubernetes-service
  user:
    token: <redacted>

Additional context

BladeMF avatar Jul 15 '25 11:07 BladeMF

Hello @BladeMF,

Thank you for reaching out to Lens support!

Thank you for reporting a bug.

We are working on your issue. Stand by for further updates.

Best Regards, Tikhon Kudinov Lens Support Engineer Mirantis, Inc

Tixon123 avatar Jul 16 '25 07:07 Tixon123

Hi @BladeMF,

thank you for raising this issue.

You've rightfully pointed out a compatibility issue here: While Kubernetes CLI tools like kubectl handle null and ~ or omitted namespaces by defaulting to the default namespace, Lens currently does not behave the same way. This can lead to unexpected behavior where valid kubeconfigs are not properly recognized or displayed.

We're now tracking this internally and will work towards aligning Lens's kubeconfig parser behavior with the Kubernetes standard. In the meantime, the recommended workaround is to completely omit the namespace field in kubeconfig contexts if no specific namespace is intended.

Thanks again for reporting this!

clrothmann avatar Jul 16 '25 08:07 clrothmann

If I omit the namespace field it won't connect (I've tested it manually using kubectl --kubeconfig ...).

BladeMF avatar Jul 16 '25 09:07 BladeMF