-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terminal : Support for Windows Subsystem for Linux #179
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.
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.
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.
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.
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:
|
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. |
emmm,It can't work by running Lens in my WSL,and got some desc: Help,pls! |
Found a way to run Lens with WSL1. Automatic context switching and access to pod shell also works. To do that, you need to install WSL manually.
|
All my thumbs for this one. I know PS can be great once you get to know it but all my tooling lives inside the WSL. |
Seems that WSL is supported on terminal, so closing this now. Please re-open if you still find this an issue. |
@nevalla So Lens still not directly support WSL? Right? vildek's method can only work on WSL1 with manually configured… |
@nevalla Hi, what do you mean by that? What terminal? |
@nevalla hmmmm until you post the screenshot, I didn't realized that Lens have already release the 5.0.0 version several day ago(I didn't received the 5.0.0 update notification on 4.x latest version), We finally can set the terminal we want. So I upgrade and test it. The KUBECONFIG env automated pass in wsl2 bash looks good. |
Alright, it seems that this is issue on WSL (found multiple open issues). You can try to run |
That didn't work. :( |
Someone hinted that disabling Fast Start-Up might fix the issue but I haven't tested this since I'm able to connect fine. https://stephenreescarter.net/wsl2-network-issues-and-win-10-fast-start-up/ |
That post it talking about the problem that windows can't access WSL2's service directly via localhost. That is the opposite of the situation here.(windows can accesss wsl2 service directly via localhost)(Here is wsl2 kubectl need to access the Lens's proxy service on windows side from WSL2). I'm wondering what version of you wsl versrion? if you are in WSL1 then it makes sense 🤔 |
Ok,I have to point out that it just still not support WSL2 as terminal directly with kubectl due to network structure of WSL2,not WSL1. 😐 This issue should reopen. |
wsl.exe as terminal works for the terminal window. However, as other have said, when using the pod shell command it shows windows folders and it is not possible to get to the container's folder structure |
Please support WSL 2 Getting |
@nevalla I am new to Lens and I'm trying to get the program set up by adding clusters from my WSL2 kubeconfig file. I set the terminal shell path to wsl.exe as you showed, but it doesn't seem to be working. In the "Add clusters from kubeconfig" screen it gives me an error |
I too am seeing this except with gcp's gcloud:
My |
This is very naïve but it seems like the auth proxy here: https://github.com/lensapp/lens/blob/master/src/main/kube-auth-proxy.ts#L89 needs to be spawned within the context of the specified terminal preferences. Likely will cause other issues with the kubectl location since I noticed it's always using a bundled version. Maybe adding a preference to use the installed kubectl rather than bundled. |
I have wrote the script to replace the IP
And it is still not working because my windows host listening port on 127.0.0.1 and I cant connect through wsl network. |
ohhh I didn't make it clear,I mean I can get the right ip of the host. The next line is about I also bump into this problem. :( |
Now that Windows 11 is released, I was able to run Lens from WSL2 and see the GUI. You can follow this guide to get it set up: https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps |
yeah but windows 11 still need some time to go. its still good to have a alternative way to use lens. at least it more easy to use gui app in wsl2 on windows 11 then now. |
hi! |
I think I found a more simple approach based on #2079 (comment).
Finally, you might have to add your kube config from WSL. In my case, I had to add this folder using "Sync folder(s)": |
@pkerschbaum hi! I'll try your solution now, but one question - I see problem that there would be only one kubectl binary for al clusters, so if you have very old (unsupported) and very new clusters you could have issues |
@Bafff that's true, I think this limitation applies also to the approach suggested by @jc-roman (#179 (comment)). |
@pkerschbaum anyway thanks for sharing! How long are you using this? Does it work well, any issues or need-to-know things maybe? |
@Bafff I shared the solution just after I got it working, it seems to work very well (can connect into containers etc). |
And what are your setting on the Kubernetes settings Tab in Lens? @pkerschbaum |
@pkerschbaum Hey, I followed Your instructions and am getting following errors: |
@hpzzz you can try this workaround instead |
For me, there was also more to do regarding authentication for GCP: For my cluster, Running I "fixed" this issue in a similar way as I did for
|
I have created @echo off
echo.
wsl aws %* I got this error message Unable to locate credentials. You can configure credentials by running "aws configure".
E0319 20:27:45.776919 19308 proxy_server.go:147] Error while proxying request: getting credentials: exec: executable aws failed with exit code 253
getting credentials: exec: executable aws failed with exit code 253 |
Try adding |
@jvandervelden Hi, Thanks for the workaround. I have tried to patch @echo off
echo.
wsl --user <wsl-username> aws %* But with option I don't know why 🤔 |
workaround |
I just was able to fix this issue by changing the default WSL default Distribution to Debian.
And by setting up Debian as my default WSL, it has fixed my issue:
Source: https://klaushofrichter.medium.com/using-windows-subsystem-for-linux-for-kubernetes-8bd1f5468531 |
@hpzzz Try to edit the certs paths in your |
@PePoDev I fixed this issue by using the solution provided here. Add the aws.bat file to your LocalAppData and the change will be picked up on restarting Lens. Not sure about the user credentials though 🤔 |
I'm also using This one starts your shell (bash, zsh, ...) in interactive mode:
|
I'm also unable to use Lens with WSL2 since changing my default installation to a non-Debian version. (Kali Linux) Did anyone else manage to get it working? |
I have lost 2 hours of my time but now all it is working fine.
As notes you need to install kubectl in your wsl instance and your additional plugins such as oci or aws, just like lens works on native linux-based OSs |
That worked. Thank you! |
I was able to get this working on Lens 2024.1.170738-latest
Initially this didn't work because Lens was overriding the KUBECONFIG environment variable to point to a custom kubeconfig in /mnt/c/Users//AppData/Local/Temp/-. I was able to workaround this issue using these steps:
Now when you launch a terminal in Lens, the .bashrc file will be sourced and override whatever value is being passed by 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:
The text was updated successfully, but these errors were encountered: