I was Trying out kuberenets in my local with a tutorial and ran into some issues.
I used Docker to build images of few snippets in node js and then used it to deploy in microk8s. Everything is working perfectly without the ingress controller. The containers are client - port 3000 (react app) posts - port 4000 comments - port 4001 moderation ...
I applied this configuration after enabling ingress in microk8s
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress-srv
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
rules:
- host: posts.com
http:
paths:
- path: /posts/create
backend:
serviceName: posts-clusterip-srv
servicePort: 4000
- path: /posts
backend:
serviceName: query-clusterip-srv
servicePort: 4002
- path: /posts/?(.*)/comments
backend:
serviceName: comments-clusterip-srv
servicePort: 4001
- path: /?(.*)
backend:
serviceName: client-clusterip-srv
servicePort: 3000
I've ensured to edit the hosts file to set
127.0.0.1 posts.com
When i check the k8s for ingress This is my result
Please guide me on how to troubleshoot this or what's going wrong in my setup. It worked once and when i tried it again with skaffold,(it deploys pods without any issue, i can still access via NodePort service) Its not working when i goto posts.com in browser. please tell me what went wrong.
PS. When i ping posts.com its pointing to 127.0.0.1 as well
Actually I resolved it by Restarting my PC.
I'm not sure how, as I've also reinstalled microk8s and tried minikube as well. It was something associated with the OS I suppose, somehow its working after a restart.