0

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

Screenshot for Ingress Controller

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

Adharsh M
  • 2,961
  • 3
  • 16
  • 23
  • Your ingress is correct (tested on my lab), make sure you enabled the ingress on Microk8s correctly. Take a look on [this](https://kndrck.co/posts/microk8s_ingress_example/) guide. – Mark Watney May 28 '20 at 06:54
  • I was following that guide as well – Adharsh M May 28 '20 at 07:10
  • 1
    After hours of getting stuck, I restarted my pc. It worked.. classic turn it off and turn it back on worked. Now I'm thinking why it didnt work before. – Adharsh M May 28 '20 at 07:12

1 Answers1

2

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.

Adharsh M
  • 2,961
  • 3
  • 16
  • 23