Lens: Terminal : Support for Windows Subsystem for Linux

Created on 31 Mar 2020  路  4Comments  路  Source: lensapp/lens


What would you like to be added:

Add an option in the Preference page allowing to select the shell used by the terminal similarly to Visual Studio Code.

Why is this needed:

Windows Subsystem for Linux is commonly used by Kubernetes administrator running on Windows. Today Lens seems to only support Git Bash

Environment you are Lens application on:

  • Kubernetes distribution: Any
  • Desktop OS: Windows
enhancement

Most helpful comment

I got this working by running Lens in my WSL2 Ubuntu distro with the AppImage release (snap install didn't work) and using X11 forwarding (VcXsrv) to show the app in my Windows desktop. There are a bunch of guides lying around for using X11 forwarding to access Linux GUI apps on your Windows host -- here's an example: https://stackoverflow.com/questions/61110603/how-to-set-up-working-x11-forwarding-on-wsl2

Seems to be working fine, and as a bonus, it used the AWS CLI in my Ubuntu distro to authenticate to my EKS cluster out of the box.

All 4 comments

I've found lens to be a breath of fresh air after struggling with the kubernetes dashboard for some time. The UX is excellent and the UI very fast, etc, kudos to all involved. Being able to use the WSL terminal as well would mean I could do all k8s admin in a single app.

Also when connecting to AWS EKS clusters, the aws cli needs to be invoked to verify iam credentials. Running those commands in WSL would also be helpful, as I don't normally install all the aws tools in windows (though can work around that).

Since I need to use some kubectl plugin only available under Linux, so I bump into this issue too. I trying to figure out if I can solve problem manually and have some conclusion.

  1. the env of KUBECONFIG won't pass directly into wsl2 bash

Evening I manually enter bash shell in Lens Terminal. The KUBECONFIG env won't pass directly to bash. I have trying to fix the env problem though WSLENV to share the KUBECONFIG to WSL2 bash.

set WSLENV=KUBECONFIG/pu
  1. wsl2 network problem

Now, another problem is that in WSL2 cannot access to windows localhost network directly. So kubectl will simply get rejected on 127.0.0.1 address since there is no service listening in WSL2.
At least I can set up script in .bashrc to auto fetch host's ip and replace it in kube config. I trying to do some test, fetch the host's ip. Then replace the ip in the kube config manually. It actually work.

  1. Lens security restriction

Then I head into next problem is that looks like lens create a localhost api proxy for it own terminal and restrict to local access only. But as WSL2 environment is a virtual machine have it own ip, so kubectl can only get the default response From lens still failed.

I1020 00:23:57.265435 5900 round_trippers.go:420] GET http://172.23.208.1:53937/02f71990-ec55-4309-9aa0-45d731dcf08e/api?timeout=32s I1020 00:23:57.266435 5900 round_trippers.go:427] Request Headers: I1020 00:23:57.266435 5900 round_trippers.go:431] Accept: application/json, */* I1020 00:23:57.266435 5900 round_trippers.go:431] User-Agent: kubectl/v1.17.11 (windows/amd64) kubernetes/ea5f00d I1020 00:23:57.269436 5900 round_trippers.go:446] Response Status: 200 OK in 3 milliseconds I1020 00:23:57.269436 5900 round_trippers.go:449] Response Headers: I1020 00:23:57.269436 5900 round_trippers.go:452] Content-Type: text/html I1020 00:23:57.269436 5900 round_trippers.go:452] Date: Mon, 19 Oct 2020 16:23:57 GMT I1020 00:23:57.270436 5900 round_trippers.go:452] Connection: keep-alive I1020 00:23:57.270436 5900 request.go:1017] Response Body: <!doctype html><html lang="en"><head><meta charset="UTF-8"><title>Lens - The Kubernetes IDE</title><link href="/build/Lens.css" rel="stylesheet"></head><body><div id="app"></div> <script src="/build/Lens.js"></script></body></html> I1020 00:23:57.271435 5900 cached_discovery.go:121] skipped caching discovery info due to couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omit empty\""; Kind string "json:\"kind,omitempty\"" } F1020 00:23:57.272435 5900 helpers.go:114] error: couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omite mpty\"" }
Lens have no option to remove or add ip white list to its proxy server, so it still head into another dead end. Unless I setup another port forwarding to pass though such problem, but it still inconvenience.

For support WSL2 in Lens I guess we need to implement these function:

  1. Auto fetch real Host ip in WSL2 to setup specified kubeconfig for WSL2
  2. Auto fetch WSL2's virtual IP to setup IP whitelist in Lens's API proxy server
  3. Setup specified KUBECONFIG for WSL2

I got this working by running Lens in my WSL2 Ubuntu distro with the AppImage release (snap install didn't work) and using X11 forwarding (VcXsrv) to show the app in my Windows desktop. There are a bunch of guides lying around for using X11 forwarding to access Linux GUI apps on your Windows host -- here's an example: https://stackoverflow.com/questions/61110603/how-to-set-up-working-x11-forwarding-on-wsl2

Seems to be working fine, and as a bonus, it used the AWS CLI in my Ubuntu distro to authenticate to my EKS cluster out of the box.

I got this working by running Lens in my WSL2 Ubuntu distro with the AppImage release (snap install didn't work) and using X11 forwarding (VcXsrv) to show the app in my Windows desktop. There are a bunch of guides lying around for using X11 forwarding to access Linux GUI apps on your Windows host -- here's an example: https://stackoverflow.com/questions/61110603/how-to-set-up-working-x11-forwarding-on-wsl2

Seems to be working fine, and as a bonus, it used the AWS CLI in my Ubuntu distro to authenticate to my EKS cluster out of the box.

That sounds really crazy to use WSL as ubuntu desktop, too bad most of my work still done on windows side, this is not suitable for my situation, but still kind of interesting.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mhobotpplnet picture mhobotpplnet  路  4Comments

adammw picture adammw  路  4Comments

jtackaberry picture jtackaberry  路  6Comments

geruetzel picture geruetzel  路  6Comments

snowmoonsoftware picture snowmoonsoftware  路  4Comments