Search code examples
windowskubernetesdnskubernetes-ingress

Kubernetes: how an ingress domain is resolved to localhost on windows


Following https://kubernetes.github.io/ingress-nginx/deploy/#installation-guide

kubectl create deployment demo --image=httpd --port=80
kubectl expose deployment demo
kubectl create ingress demo-localhost --class=nginx \
  --rule="demo.localdev.me/*=demo:80"
kubectl port-forward --namespace=ingress-nginx service/ingress-nginx-controller 8080:80

how the domain "demo.localdev.me" is resolved to localhost?

 > curl http://demo.localdev.me:8080
 <html><body><h1>It works!</h1></body></html>

The domain "demo.localdev.me" is not in the c:\Windows\System32\drivers\etc\hosts file on windows 11. Is it added to a DNS server?


Solution

  • Domain names or IP addresses on a local computer can be resolved by adding entries in the local hosts file on a computer (C:\Windows\System32\drivers\etc → for windows) . Go to this path and set up the hostname.

    Before adding it check if the dns is already configured by using nslookup host_name.If you don’t find it in dns you need to add it.

    As per official doc:

    The ingress, and ingress-dns addons are currently only supported on Linux.

    If you have already used minikube addons enable ingress, Try minikube tunnel and your ingress resources would be available at 127.0.0.1. So the requests from http://demo.localdev.me:8080 will be sent to 127.0.0.1.

    Refer to the official doc and blog authored by Snehalhingane for more information.