1

I have installed the minikube, deployed the hello-minikube application and opened the port. Basically I have followed the getting started tutorial at https://kubernetes.io/docs/setup/learning-environment/minikube/#quickstart.

The problem starts when I want to open the URL where the deployed application is running obtained by running minikube service hello-minikube --url.

I get http://172.17.0.7:31198 and that URI cannot be opened, since that IP does not exist locally. Changing it to http://localhost:31198 does not work either (so adding an entry to hosts file won't work I guess).

The application is running, I can query the cluster and obtain the info through http://127.0.0.1:50501/api/v1/namespaces/default/services/hello-minikube:

{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "hello-minikube",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/services/hello-minikube",
    "uid": "56845ce6-bbba-45e5-a1b6-d094949438cf",
    "resourceVersion": "1578",
    "creationTimestamp": "2020-03-10T10:33:41Z",
    "labels": {
      "app": "hello-minikube"
    }
  },
  "spec": {
    "ports": [
      {
        "protocol": "TCP",
        "port": 8080,
        "targetPort": 8080,
        "nodePort": 31198
      }
    ],
    "selector": {
      "app": "hello-minikube"
    },
    "clusterIP": "10.108.152.177",
    "type": "NodePort",
    "sessionAffinity": "None",
    "externalTrafficPolicy": "Cluster"
  },
  "status": {
    "loadBalancer": {

    }
  }
}
λ kubectl get services
NAME             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
hello-minikube   NodePort    10.108.152.177   <none>        8080:31198/TCP   4h34m
kubernetes       ClusterIP   10.96.0.1        <none>        443/TCP          4h42m

How to access the application deployed in minikube k8s cluster on localhost? Also minikube is running as a docker container on the machine with following ports 32770:2376 32769:8443 32771:22 exposed.

Karel Frajták
  • 4,389
  • 1
  • 23
  • 34
  • 1
    Please see: [Why is “Can someone help me?” not an actual question?](http://meta.stackoverflow.com/q/284236) – Adriaan Mar 10 '20 at 14:52
  • Did you run kubectl expose for port 8080? If so, what do you see for `kubectl get services` ? – Eamonn McEvoy Mar 10 '20 at 14:58
  • @EamonnMcEvoy I did (I guess), see the edit. – Karel Frajták Mar 10 '20 at 15:08
  • Did you try port mapping for minikube docker container as 31198:31198 to access 31198 port of minikube container from your hosts port? – kadir Mar 10 '20 at 19:35
  • @kadir I haven't installed minikube myself, chocolatey did. So I have now minikube container running and don't know how to modify it. – Karel Frajták Mar 10 '20 at 20:21
  • When I ssh into minikube the IP adress works - `curl 172.17.0.7:31246` returns the expected data. @kadir might be onto something, but how to modify the running container and expose wide range of ports ... – Karel Frajták Mar 10 '20 at 20:26

1 Answers1

1

Found the solution in another thread - port forwarding

kubectl port-forward svc/hello-minikube 31191:8080

The first port is port that you will use on your machine (in the browser) and 8080 is the port defined when running the service.

Karel Frajták
  • 4,389
  • 1
  • 23
  • 34