'Run Ingress in minikube and its address shows localhost

I'm new to k8s. I deployed an ingress on minikube, and I found out its address to be localhost which it shouldn't be, I guess. For this, I don't know how to continue, for I should edit /etc/hosts/ to add dns item, but no I could not.
enter image description here

And this is my configuration file

kiloson@ubuntu:~$ cat kubia-ingress.yaml 
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kubia
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - host: kubia.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service: 
            name: kubia-nodeport
            port: 
              number: 80

minikube version

kiloson@ubuntu:~$ minikube version
minikube version: v1.24.0
commit: 76b94fb3c4e8ac5062daf70d60cf03ddcc0a741b

Ubuntu Info

kiloson@ubuntu:~$ neofetch
            .-/+oossssoo+/-.               kiloson@ubuntu 
        `:+ssssssssssssssssss+:`           -------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 20.04.3 LTS x86_64 
    .ossssssssssssssssssdMMMNysssso.       Host: Virtual Machine 7.0 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 5.11.0-1022-azure 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 2 hours, 33 mins 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 648 (dpkg), 4 (snap) 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: bash 5.0.17 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Terminal: /dev/pts/0 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   CPU: Intel Xeon E5-2673 v4 (2) @ 2.294GHz 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   GPU: 00:08.0 Microsoft Corporation Hyper-V virtual VGA 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Memory: 1493MiB / 7959MiB 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/                            
  +sssssssssdmydMMMMMMMMddddyssssssss+                             
   /ssssssssssshdmNNNNmyNMMMMhssssss/
    .ossssssssssssssssssdMMMNysssso.
      -+sssssssssssssssssyyyssss+-
        `:+ssssssssssssssssss+:`
            .-/+oossssoo+/-.


Solution 1:[1]

localhost adress is correct. That's how minikube works.

You can get your minikube cluster ip with

minikube ip

or

minikube service <service-name> --url

Solution 2:[2]

I was butting heads with this for a while and just got it working, so I'll add color to the other answers.

First of all, as pointed out in this related question, when you intially run minikube addons enable ingress it prints After the addon is enabled, please run "minikube tunnel" and your ingress resources would be available at "127.0.0.1".

After completing the steps in the tutorial and running into the issue in this question, I was able to hit the hello-world app by starting minikube tunnel and adding 127.0.0.1 hello-world.info to my /etc/hosts.

I am not sure why the tutorial execution of kubectl get ingress returns a non-localhost IP, but returns localhost when running locally, but it seems like the primary issue here is that while you are creating an ingress on the docker containers running minikube, you need to forward traffic to the containers through minikube tunnel to hit the now open ingress in minikube.

Solution 3:[3]

I have encountered the same issue.

The --publish-status-address=localhost is set in the args of nginx-ingress-controller. https://github.com/kubernetes/minikube/blob/1b25cac7f5735be22f88a159b35b1996abba3c73/deploy/addons/ingress/ingress-deploy.yaml.tmpl#L373

I removed this arg and it worked.

$ kubectl edit deployments.apps -n ingress-nginx ingress-nginx-controller 
  - args:
    - /nginx-ingress-controller
    - --election-id=ingress-controller-leader
    - --controller-class=k8s.io/ingress-nginx
    - --watch-ingress-without-class=true
-   - --publish-status-address=localhost
    - --configmap=$(POD_NAMESPACE)/ingress-nginx-controller
    - --report-node-internal-ip-address
    - --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
    - --udp-services-configmap=$(POD_NAMESPACE)/udp-services
    - --validating-webhook=:8443
    - --validating-webhook-certificate=/usr/local/certificates/cert
    - --validating-webhook-key=/usr/local/certificates/key

Solution 4:[4]

To enable ingress on minikube local just run this:-

first, verify whether addons are enabled or not for ingress

minikube addons list

if it's not enabled run the below command:-

minikube addons enable ingress

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 p10l
Solution 2 Paulo Black
Solution 3 szktkfm
Solution 4