I was trying to use Kubernetes to set up a service locally. I am using ingress-nginx for routing. I am using Ubuntu 18.04. This is my ingress.yaml file:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-service
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
rules:
- host: ecommerce.dev
http:
paths:
- path: /api/users/?(.*)
backend:
serviceName: auth-srv
servicePort: 3000
Also, I mapped this in my /etc/hosts/
file:
127.0.0.1 localhost
127.0.1.1 TALHA
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1 ecommerce.dev
When I try to reach 'ecommerce.dev' from my browser, I am unable to access it as it says 'Site can not be reached'. Can someone please help me about it?
I saw you mentioned you are using minikube with nginx ingress addon.
This information helps a lot. Try not to skip this kind of information in future. I was assuming that by saying "I was trying to use Kubernetes to set up a service locally" you mean that you run baremetal k8s.
Minikube is most probably running in a VM and this is why you cannot access it.
Running minikube ip
gives you the IP address of a VM:
$ minikube ip
192.168.39.67
Your ip may be different so don't use my IP, check what IP you got assigned.
Now that you have the IP of a minikube VM, use it in /etc/hosts
. In my case it looks like following:
192.168.39.67 ecommerce.dev