<p>I have installed the minikube, deployed the hello-minikube application and opened the port. Basically I have followed the getting started tutorial at <a href="https://kubernetes.io/docs/setup/learning-environment/minikube/#quickstart" rel="nofollow noreferrer">https://kubernetes.io/docs/setup/learning-environment/minikube/#quickstart</a>. </p>

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

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

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

<pre><code>{
  "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": {

    }
  }
}
</code></pre>

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

<p>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.</p>

Karel Frajták
<p>Found the solution in another <a href="https://stackoverflow.com/questions/40767164/expose-port-in-minikube">thread</a> - port forwarding</p>

<pre><code>kubectl port-forward svc/hello-minikube 31191:8080
</code></pre>

<p>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.</p>
