<p>I am following <a href="https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/" rel="nofollow noreferrer">this tutorial</a> for setting up Ingress with Ingress-Nginx on Minikube. But I can't seem to get it to work. I get a connection refused when I try to connect to port 80 on the VM IP address returned by <code>minikube ip</code></p>
<p>My setup is this:</p>
<ul>
<li><strong>Minikube version</strong>: v1.25.1</li>
<li><strong>VirtualBox version</strong>: 6.1</li>
<li><strong>Kubernetes version</strong>: v1.22.5</li>
</ul>
<p>The ingress-nginx namespace has the below resources:</p>
<pre><code>NAME                                            READY   STATUS    RESTARTS   AGE
pod/ingress-nginx-controller-85f4c5b458-2dhqh   1/1     Running   0          49m

NAME                                         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
service/ingress-nginx-controller             NodePort    10.102.88.109   &lt;none&gt;        80:30551/TCP,443:31918/TCP   20h
service/ingress-nginx-controller-admission   ClusterIP   10.103.134.39   &lt;none&gt;        443/TCP                      20h

NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/ingress-nginx-controller   1/1     1            1           20h

NAME                                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/ingress-nginx-controller-85f4c5b458   1         1         1       20h

NAME                                       COMPLETIONS   DURATION   AGE
job.batch/ingress-nginx-admission-create   1/1           6s         20h
job.batch/ingress-nginx-admission-patch    1/1           6s         20h
</code></pre>
<p>The default namespace has the below resources</p>
<pre><code>NAME                       READY   STATUS    RESTARTS   AGE   IP           NODE           NOMINATED NODE   READINESS GATES
pod/web-79d88c97d6-rvp2r   1/1     Running   0          47m   10.244.1.4   minikube-m02   &lt;none&gt;           &lt;none&gt;

NAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE   SELECTOR
service/kubernetes   ClusterIP   10.96.0.1      &lt;none&gt;        443/TCP          20h   &lt;none&gt;
service/web          NodePort    10.104.20.14   &lt;none&gt;        8080:31613/TCP   20h   app=web

NAME                                        CLASS   HOSTS              ADDRESS     PORTS   AGE
ingress.networking.k8s.io/example-ingress   nginx   hello-world.info   localhost   80      20h
</code></pre>
<p>Minikube is exposing these services:</p>
<pre><code>|---------------|------------------------------------|--------------|-----------------------------|
|   NAMESPACE   |                NAME                | TARGET PORT  |             URL             |
|---------------|------------------------------------|--------------|-----------------------------|
| default       | kubernetes                         | No node port |
| default       | web                                |         8080 | http://192.168.59.106:31613 |
| ingress-nginx | ingress-nginx-controller           | http/80      | http://192.168.59.106:30551 |
|               |                                    | https/443    | http://192.168.59.106:31918 |
| ingress-nginx | ingress-nginx-controller-admission | No node port |
| kube-system   | kube-dns                           | No node port |
| kube-system   | registry                           | No node port |
|---------------|------------------------------------|--------------|-----------------------------|
</code></pre>
<p>In step 4 of the <a href="https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/#create-an-ingress" rel="nofollow noreferrer">Create an Ingress</a> section The tutorial mentions this:</p>
<pre><code>Add the following line to the bottom of the /etc/hosts file on your computer (you will need administrator access):

172.17.0.15 hello-world.info

Note: If you are running Minikube locally, use minikube ip to get the external IP. The IP address displayed within the ingress list will be the internal IP. 
</code></pre>
<p>It's a three node cluster using VirtualBox. I've tried adding the Minikube ingress-nginx-controller service's IP (192.168.59.106, which is also the result of minikube ip) to my hosts file, but it doesn't work. And as far as I know, I can't include the service's node port 30551 in the hosts file to test that.</p>
<p>Some guidance on how to get this working would be much appreciated</p>

cjt
<p>You are correct. You cannot include the port in the <code>/etc/hosts</code> file. To get there, you would need to specify the full path in your browser or some other application as following (assuming no connectivity issues):</p>
<ul>
<li><code>hello-world.info:30551</code></li>
</ul>
<hr />
<p>I'd recommend you to tell specifically what type of issue you have. There can be multiple issues and each one will have different solution.</p>
<p>For example there will be a difference between the inability to access the <em>Service</em> and getting the <code>404</code> message.</p>
<hr />
<p>I'm not sure if it's related but I had connectivity issues when I created a cluster in a following way:</p>
<ul>
<li><code>minikube start --driver=&quot;virtualbox&quot;</code></li>
<li><code>minikube node add</code></li>
<li><code>minikube node add</code></li>
</ul>
<p>However, when I ran below command, I encountered noone:</p>
<ul>
<li><code>minikube start --driver=&quot;virtualbox&quot; --nodes=3</code></li>
</ul>
<hr />
<p>Assuming that you would like to expose your <em>Nginx Ingress controller</em> to be available on the ports <code>80</code> and <code>443</code> instead of <code>NodePort's</code> you can do:</p>
<ul>
<li>Spawn your cluster</li>
<li>Deploy:
<ul>
<li><em><a href="https://metallb.universe.tf/" rel="nofollow noreferrer">Metallb.universe.tf</a></em></li>
</ul>
</li>
<li>Configure your address pool similar to:</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1                                                                                                                                     
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.59.200-192.168.59.210&quot;
</code></pre>
<ul>
<li>Change the <em>Service</em> of your: <code>ingress-nginx-controller</code> to <em>LoadBalancer</em> instead of <code>NodePort</code> (<code>kubectl edit svc -n ingress-nginx ingress-nginx-controller</code>)</li>
<li>Check on the <em>Service</em>:
<ul>
<li><code>kubectl get svc -n ingress-nginx ingress-nginx-controller</code></li>
</ul>
</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>NAME                       TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)                      AGE
ingress-nginx-controller   LoadBalancer   10.106.63.253   192.168.59.201   80:30092/TCP,443:30915/TCP   23m
</code></pre>
<ul>
<li>Put the <em>EXTERNAL-IP</em> of your <em>Ingress controller</em> to your <code>/etc/hosts</code> file.</li>
<li>Create an <em>Ingress</em> resource that is matching what you've inputted as a name to <code>/etc/hosts</code> and has some backend.</li>
</ul>
<hr />
<p>Additional resources:</p>
<ul>
<li><em><a href="https://kubernetes.github.io/ingress-nginx/" rel="nofollow noreferrer">Kubernetes.github.io: Ingress nginx</a></em></li>
<li><em><a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Kubernetes.io: Docs: Concepts: Services networking: Service</a></em></li>
</ul>
