<p>I know this question has been asked before, but the previous one doesn't apply to my case. I have 2 deployments and 2 services and I am using ingress resource and <code>nginx ingress controller</code></p>
<p><code>ingress.yaml</code></p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    name: frontend-ingress
    annotations: 
      kubernetes.io/ingress.class: nginx
spec:
    rules:
    - http:
        paths:
        - path: /api
          backend:
            serviceName: frontend-svc
            servicePort: 3000
        - path: /
          backend:
            serviceName: static-svc
            servicePort: 80

</code></pre>
<p>And the 2 services are defined below,</p>
<p><code>services.yaml</code></p>
<pre><code>  apiVersion: v1
  kind: Service
  metadata:
      labels:
          app: frontend
      name: frontend-svc
  spec:
      ports:
      - port: 3000
        protocol: TCP
        targetPort: 3000
      selector:
          app: frontend
      type: ClusterIP

---

apiVersion: v1
kind: Service
metadata:
    labels:
        app: static
    name: static-svc
spec:
    ports:
    - port: 80
      protocol: TCP
      targetPort: 80
    selector:
        app: static
    type: ClusterIP
</code></pre>
<p>The deployments are shown below,</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
    labels:
        app: frontend
    name: frontend
spec:
    replicas: 2
    selector:
        matchLabels:
            app: frontend
    template:
        metadata:
            labels:
                app: frontend
        spec:
            containers:
            - image: magalixcorp/sample-api:v1
              imagePullPolicy: IfNotPresent
              name: frontend
              env:
              - name: REDIS_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: redis-password
                    key: redis-password
              volumeMounts:
              - name: config-volume
                mountPath: /app/config.json
                subPath: config.json
            volumes:
                - name: config-volume
                  configMap:
                    name: app-config

---

apiVersion: apps/v1
kind: Deployment
metadata:
    labels:
        app: static
    name: static
spec:
    replicas: 2
    selector:
        matchLabels:
            app: static
    template:
        metadata:
            labels:
                app: static
        spec:
            containers:
            - image: magalixcorp/static:v1
              imagePullPolicy: IfNotPresent
              name: static


</code></pre>
<p>I have deployed an nginx controller using helm to AKS. The routes are not working at all.
When I check the nginx-controller logs i get this</p>
<pre><code>W1109 16:30:33.892443       6 controller.go:849] Error obtaining Endpoints for Service &quot;default/frontend-svc&quot;: no object matching key &quot;default/frontend-svc&quot; in local store
W1109 16:30:33.892478       6 controller.go:849] Error obtaining Endpoints for Service &quot;default/static-svc&quot;: no object matching key &quot;default/static-svc&quot; in local store
I1109 16:30:33.929583       6 main.go:112] &quot;successfully validated configuration, accepting&quot; ingress=&quot;frontend-ingress/default&quot;
W1109 16:30:33.935904       6 controller.go:849] Error obtaining Endpoints for Service &quot;default/frontend-svc&quot;: no object matching key &quot;default/frontend-svc&quot; in local store
W1109 16:30:33.935930       6 controller.go:849] Error obtaining Endpoints for Service &quot;default/static-svc&quot;: no object matching key &quot;default/static-svc&quot; in local store
I1109 16:30:33.935973       6 controller.go:144] &quot;Configuration changes detected, backend reload required&quot;
I1109 16:30:33.936084       6 event.go:282] Event(v1.ObjectReference{Kind:&quot;Ingress&quot;, Namespace:&quot;default&quot;, Name:&quot;frontend-ingress&quot;, UID:&quot;efde0161-c03f-49d4-8f2b-38e2ceaaf8a7&quot;, APIVersion:&quot;networking.k8s.io/v1beta1&quot;, ResourceVersion:&quot;7945&quot;, FieldPath:&quot;&quot;}): type: 'Normal' reason: 'Sync' Scheduled for sync
I1109 16:30:34.005219       6 controller.go:161] &quot;Backend successfully reloaded&quot;
I1109 16:30:34.005615       6 event.go:282] Event(v1.ObjectReference{Kind:&quot;Pod&quot;, Namespace:&quot;nginx&quot;, Name:&quot;nginx-ingress-nginx-controller-68f45f49f6-slnv7&quot;, UID:&quot;7880b0be-a1ff-450d-b1c1-4cee11722a6b&quot;, APIVersion:&quot;v1&quot;, ResourceVersion:&quot;3538&quot;, FieldPath:&quot;&quot;}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration
I1109 16:30:37.269565       6 controller.go:144] &quot;Configuration changes detected, backend reload required&quot;
I1109 16:30:37.342929       6 controller.go:161] &quot;Backend successfully reloaded&quot;
I1109 16:30:37.343677       6 event.go:282] Event(v1.ObjectReference{Kind:&quot;Pod&quot;, Namespace:&quot;nginx&quot;, Name:&quot;nginx-ingress-nginx-controller-68f45f49f6-slnv7&quot;, UID:&quot;7880b0be-a1ff-450d-b1c1-4cee11722a6b&quot;, APIVersion:&quot;v1&quot;, ResourceVersion:&quot;3538&quot;, FieldPath:&quot;&quot;}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration
I1109 16:31:01.926983       6 status.go:290] &quot;updating Ingress status&quot; namespace=&quot;default&quot; ingress=&quot;frontend-ingress&quot; currentValue=[] newValue=[{IP: Hostname:a596c83cb03464004bcced0767dd5aa9-1681194742.us-east-1.elb.amazonaws.com}]
I1109 16:31:01.937928       6 event.go:282] Event(v1.ObjectReference{Kind:&quot;Ingress&quot;, Namespace:&quot;default&quot;, Name:&quot;frontend-ingress&quot;, UID:&quot;efde0161-c03f-49d4-8f2b-38e2ceaaf8a7&quot;, APIVersion:&quot;networking.k8s.io/v1beta1&quot;, ResourceVersion:&quot;8081&quot;, FieldPath:&quot;&quot;}): type: 'Normal' reason: 'Sync' Scheduled for sync
10.0.1.165 - - [09/Nov/2020:16:32:18 +0000] &quot;GET / HTTP/1.1&quot; 200 1313 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0&quot; 396 0.002 [default-static-svc-80] [] 10.0.3.144:80 1313 0.000 200 750627c05c4ca98a2bcd60ae8bbb8828
10.0.1.165 - - [09/Nov/2020:16:32:19 +0000] &quot;GET /js/script.js HTTP/1.1&quot; 200 314 &quot;http://a596c83cb03464004bcced0767dd5aa9-1681194742.us-east-1.elb.amazonaws.com/&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0&quot; 397 0.001 [default-static-svc-80] [] 10.0.1.175:80 314 0.000 200 af72c4fdc493a489064307872636b662
10.0.1.165 - - [09/Nov/2020:16:32:20 +0000] &quot;GET /favicon.ico HTTP/1.1&quot; 404 153 &quot;http://a596c83cb03464004bcced0767dd5aa9-1681194742.us-east-1.elb.amazonaws.com/&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0&quot; 407 0.002 [default-static-svc-80] [] 10.0.3.144:80 153 0.000 404 ba36f92120a41720842ba95e24b9975c
10.0.2.31 - - [09/Nov/2020:16:32:47 +0000] &quot;GET /.env HTTP/1.1&quot; 404 555 &quot;-&quot; &quot;Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36&quot; 231 0.001 [default-static-svc-80] [] 10.0.1.175:80 555 0.000 404 d8ec13faad1d46c13401b397e2d80ad0
10.0.2.31 - - [09/Nov/2020:16:32:48 +0000] &quot;POST / HTTP/1.1&quot; 405 559 &quot;-&quot; &quot;Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36&quot; 317 0.001 [default-static-svc-80] [] 10.0.1.175:80 559 0.000 405 567a4b2499fc816d72135445076bafda
10.0.1.165 - - [09/Nov/2020:16:32:53 +0000] &quot;GET /api HTTP/1.1&quot; 200 3 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0&quot; 399 0.003 [default-frontend-svc-3000] [] 10.0.1.26:3000 3 0.000 200 8a92b9829d26dccb60f11a9c8537d831
10.0.3.231 - - [09/Nov/2020:16:34:37 +0000] &quot;POST /api HTTP/1.1&quot; 204 0 &quot;-&quot; &quot;curl/7.64.1&quot; 211 0.002 [default-frontend-svc-3000] [] 10.0.1.26:3000 0 0.000 204 cf837f8bc89c29f2d2b07ac317120220
10.0.2.31 - - [09/Nov/2020:16:34:55 +0000] &quot;GET /api HTTP/1.1&quot; 200 3 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0&quot; 425 0.006 [default-frontend-svc-3000] [] 10.0.2.98:3000 3 0.004 200 a5757323ff32d8c4dbc56ef476798954
</code></pre>
<p>When I try :3000/api either to POST or GET it's not working. What could be wrong. What is it that am doing wrong.</p>

<p>Try cleaning this up a bit. So create a deployment just for your frontend. So this file you would call <code>frontend-depl.yml</code> and then write it like this:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
    name: frontend-depl
spec:
    replicas: 1
    selector:
        matchLabels:
            app: frontend
    template:
        metadata:
            labels:
                app: frontend
        spec:
            containers:
              - name: frontend
                image: magalixcorp/sample-api:v1
---

apiVersion: v1
kind: Service
metadata:
    name: frontend-srv
spec:
    selector:
      app: frontend
    ports:
     - name: frontend
       protocol: TCP
       port: 3000
       targetPort: 3000
</code></pre>
<p>I am suggesting this to keep your <code>yml</code> files neat and tidy as this can all spin out of control real fast as you can tell and troubleshooting can be a pain.</p>
<p>Also I would go into your terminal and run:</p>
<pre><code>$ kubectl get endpoints --namespace &lt;namespace&gt;
...
&lt;namespace&gt; &lt;your-app-service&gt;  &lt;none&gt; 21h
</code></pre>
<p>That is to look and see what endpoints you have.</p>
<p>The issue could also be your label selectors, which is why I offered a cleaner version of your <code>yml</code> file, at least the <code>frontend-depl</code> one, I would use the same pattern for your other <code>yml</code> files.</p>
<p>To learn more about label selectors:
<a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors</a></p>
