It is useful to configure hostnames for kubernetes ingresses when testing kubernetes application locally on a developer’s machine.
We may add LoadBalancer IP address to /etc/hosts
file to be able to open ingress hostname in browsers.
Minikube
- Show IP of the LoadBalancer
|
|
- update localhost
/etc/hosts
file example
|
|
Rancher Desktop
Assuming ingress-nginx is installed following nginx-ingress-rancher-destop in ingress-nginx namespace.
Show IP of the LoadBalancer
- Get
ingress-nginx
service to find theexternal-ip
1 2 3
kubectl get service -n ingress-nginx NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ingress-nginx-controller LoadBalancer 10.43.49.110 192.168.178.50 80:32170/TCP,443:30682/TCP 8d
- Another approach to find the address could be to view the ingresses
1 2 3
kubectl get ingress -A NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE demo demo-development <none> demo.nginx.local 192.168.178.50 80 8d
- Get
Update /etc/hosts file with the external IP example
|
|
We could do the same if we are using traefik ingress that comes pre-enabled in rancher-desktop
|
|