Skip to content

Instantly share code, notes, and snippets.

@debovema
Last active April 19, 2023 04:02
Show Gist options
  • Save debovema/783f29040059f8b2b784a246dbd96365 to your computer and use it in GitHub Desktop.
Save debovema/783f29040059f8b2b784a246dbd96365 to your computer and use it in GitHub Desktop.
Eclipse Che on WSL2
# start a Minikube instance
minikube start --addons=ingress --driver=docker --memory=12288 --cpus=6
# deploy Eclipse Che
chectl server:deploy --platform=minikube
# configure network
## 1. edit /etc/hosts in WSL2 (warning: this will not persist across WSL restarts)
echo "127.0.0.1\t$(minikube ip).nip.io" | sudo tee -a /etc/hosts
echo "127.0.0.1\tdex.$(minikube ip).nip.io" | sudo tee -a /etc/hosts
## 2. edit /etc/hosts in Windows hosts
## next line must be run with administrative rights (for instance launch Windows Terminal as administrator)
echo "127.0.0.1\t$(minikube ip).nip.io" | sudo tee -a /c/Windows/System32/drivers/etc/hosts # path could also starts with /mnt/c instead of /c
echo "127.0.0.1\tdex.$(minikube ip).nip.io" | sudo tee -a /c/Windows/System32/drivers/etc/hosts # path could also starts with /mnt/c instead of /c
## 3. add reverse entries in Core DNS
kubectl get configmap coredns -n kube-system -o json | sed "s[hosts {[hosts {\\\\n $(echo `kubectl run -it --rm coredns-fix --image=alpine --restart=Never -- sh -c 'getent hosts host.docker.internal'` | awk '{ print $1 }') $(minikube ip).nip.io[" | kubectl replace -f -
kubectl get configmap coredns -n kube-system -o json | sed "s[hosts {[hosts {\\\\n $(echo `kubectl run -it --rm coredns-fix --image=alpine --restart=Never -- sh -c 'getent hosts host.docker.internal'` | awk '{ print $1 }') dex.$(minikube ip).nip.io[" | kubectl replace -f -
# export Eclipse Che Certificate Authority (to be imported in end-user browser)
chectl cacert:export
# pull the (huge) Docker image used by DevWorkspaces in the Minikube Docker daemon
eval $(minikube docker-env)
docker pull quay.io/devfile/universal-developer-image:ubi8-latest
# start the Minikube tunnel
minikube tunnel
# open the Eclipse Che Dashboard
chectl dashboard:open
@debovema
Copy link
Author

debovema commented Jun 27, 2022

I used to have this issue too.

Check the new version of the Gist, especially:

kubectl get configmap coredns -n kube-system -o json | sed "s[hosts {[hosts {\\\\n       $(echo `kubectl run -it --rm coredns-fix --image=alpine --restart=Never -- sh -c 'getent hosts host.docker.internal'` | awk '{ print $1 }') $(minikube ip).nip.io[" | kubectl replace -f -
kubectl get configmap coredns -n kube-system -o json | sed "s[hosts {[hosts {\\\\n       $(echo `kubectl run -it --rm coredns-fix --image=alpine --restart=Never -- sh -c 'getent hosts host.docker.internal'` | awk '{ print $1 }') dex.$(minikube ip).nip.io[" | kubectl replace -f -

basically it updates the hosts section in the CoreDNS configuration (you might need to delete the CoreDNS pod to recreate a pod with the new configuration).

Instead of resolving dex.192.168.49.2.nip.io to 127.0.0.1, it will resolve as the Docker host IP as seen from inside a Kubernetes pod.

@mikefarmer01
Copy link

mikefarmer01 commented Dec 21, 2022

Hi @debovema,

awesome script.
I'm using containerd as the container runtime.
Can you point me in the right direction on what I need to do?

Merci

Update:

I followed your commands except for the last two.
Accessing Eclipse Che from localhost works though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment