Search code examples
kubernetesminikubessh-tunneleclipse-che

access k8s service hosted by minikube from another machine


I am following the instructions (https://www.eclipse.org/che/docs/che-7/installation-guide/installing-che-on-minikube/) to install Eclipse:Che from Minikube hosted on a remote ubuntu VM box;

I got the installation done successfully,

[![enter image description here][1]][1]

I could access the portal from ubuntu VM console:

[![enter image description here][2]][2]

overhere, the 172.17.0.3 is actually the minikube IP;

How do I enable external access to https://che-che.172.17.0.3.nip.io/dashboard/?

from my reading and googling, it seems like SSH forwarding is the right way, but I am struggling to get it correct.

thanks!

====== update 2020.11.27 =====

$ minikube start --addons=ingress  --memory=8192
$ chectl server:deploy --platform minikube --installer helm
$ kubectl expose deployment che --type=NodePort -n che --port 8080

$ kubectl get svc -n che
NAME               TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
che                NodePort    10.109.226.80    <none>        8080:32540/TCP      16h
che-dashboard      ClusterIP   10.105.102.187   <none>        8080/TCP            17h
che-host           ClusterIP   10.106.2.155     <none>        8080/TCP,8087/TCP   17h
devfile-registry   ClusterIP   10.103.124.53    <none>        8080/TCP            17h
plugin-registry    ClusterIP   10.97.131.33     <none>        8080/TCP            17h

$ minikube service  -n che che
|-----------|------|-------------|-------------------------|
| NAMESPACE | NAME | TARGET PORT |           URL           |
|-----------|------|-------------|-------------------------|
| che       | che  |        8080 | http://172.17.0.4:32540 |
|-----------|------|-------------|-------------------------|
🎉  Opening service che/che in default browser...
👉  http://172.17.0.4:32540

chaoshi@prd-sal-demo01:~$ kubectl port-forward -n che svc/che 9911:8080
Forwarding from 127.0.0.1:9911 -> 8080
Forwarding from [::1]:9911 -> 8080
Handling connection for 9911
Handling connection for 9911
Handling connection for 9911
Handling connection for 9911
Handling connection for 9911

$ curl http://localhost:9911
[![CircleCI](https://circleci.com/gh/eclipse/che-plugin-registry.svg?style=svg)](https://circleci.com/gh/eclipse/che-plugin-registry)
[![Master Build Status](https://ci.centos.org/buildStatus/icon?subject=master&job=devtools-che-plugin-registry-build-master/)](https://ci.centos.org/job/devtools-che-plugin-registry-build-master/)
[![Nightly Build Status](https://ci.centos.org/buildStatus/icon?subject=nightly&job=devtools-che-plugin-registry-nightly/)](https://ci.centos.org/job/devtools-che-plugin-registry-nightly/)
[![Release Build Status](https://ci.centos.org/buildStatus/icon?subject=release&job=devtools-che-plugin-registry-release/)](https://ci.centos.org/job/devtools-che-plugin-registry-release/)
[![Release Preview Build Status](https://ci.centos.org/buildStatus/icon?subject=release-preview&job=devtools-che-plugin-registry-release-preview/)](https://ci.centos.org/job/devtools-che-plugin-registry-release-preview/)


  [1]: https://i.sstatic.net/sVZVz.png
  [2]: https://i.sstatic.net/JsOOW.png
  [3]: https://i.sstatic.net/maoWv.png

Solution

  • First, you should create a NodePort type service and then the app will be available on your Ubuntu VM's IP and on the port provided in the NodePort service config

    The port should be 8080 when creating service. The nodePort gets randomly assigned (or you can choose it --nodePort ). For your config, you can see it in the output 172.17.0.4:31243. So the port is 31243. Reference: https://minikube.sigs.k8s.io/docs/handbook/accessing/

    For deployment portforward will not work instead use service. Try other port of your service: Here, first port is Host Port and seccond port is container port.

    kubectl port-forward svc/che 8080:8080

    Once it's accessible on localhost:8080 you can access it outside the VM using externalIPofVM:8080