<p>I am sure I am missing something clear as day, but here goes. I have a frontend and backend being deployed behind an Nginx ingress. The requests to the backend were timing out, so I tested with a <code>curl</code> pod. I found that I was able to hit the pods directly, but not the service. This led me to run:</p>
<pre class="lang-sh prettyprint-override"><code>&gt; kubectl get endpoints

NAME                                               ENDPOINTS                        AGE
backend-api                                        &lt;none&gt;                           10m
kubernetes                                         167.99.101.163:443               121d
nginx-ingress-ingress-nginx-controller             10.244.0.17:80,10.244.0.17:443   96m
nginx-ingress-ingress-nginx-controller-admission   10.244.0.17:8443                 96m
vue-frontend                                       10.244.0.24:80                   84m
</code></pre>
<p>No endpoints... I recall (from when I initially set this deployment up) that this usually has to do with selectors. I have checked and checked and checked, but I swear I have it set up correctly. Clearly not though.</p>
<pre class="lang-yaml prettyprint-override"><code>## api-deployment.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend-api
  labels:
    app: backend-api
spec:
  replicas: 2
  selector:
    matchLabels:
      app: backend-api
  template:
    metadata:
      labels:
        app: backend-api
    spec:
      containers:
      - name: backend-api
        image: us.gcr.io/container-registry-276104/backend-api:0.88
        ports:
        - containerPort: 8080
        env:
        ...
</code></pre>
<pre class="lang-sh prettyprint-override"><code>&gt; kubectl get pods --show-labels
NAME                                                      READY   STATUS    RESTARTS   AGE   LABELS
backend-api-76d6d4f4c9-drbmn                              1/1     Running   0          85m   app=backend-api,pod-template-hash=76d6d4f4c9
backend-api-76d6d4f4c9-qpbhk                              1/1     Running   0          85m   app=backend-api,pod-template-hash=76d6d4f4c9
curl-curlpod-7b46d7776f-jkt6f                             1/1     Running   0          47m   pod-template-hash=7b46d7776f,run=curl-curlpod
nginx-ingress-ingress-nginx-controller-5475c95bbf-psmzr   1/1     Running   0          97m   app.kubernetes.io/component=controller,app.kubernetes.io/instance=nginx-ingress,app.kubernetes.io/name=ingress-nginx,pod-template-hash=5475c95bbf
vue-frontend-6dbf68446f-pzv5h                             1/1     Running   0          85m   app=vue-frontend,pod-template-hash=6dbf68446f
</code></pre>
<p>and the service:</p>
<pre class="lang-yaml prettyprint-override"><code>## api-service.yaml
---
apiVersion: v1
kind: Service
metadata:
  name: backend-api
spec:
  selector:
    app: backend-api
  ports:
  - port: 8080
    protocol: TCP
    targetPort: http
  publishNotReadyAddresses: true
</code></pre>
<p>Help is, of course, appreciated :) I normally beat my head against the wall for hours, but I'm learning to work smarter, not harder!</p>
<p>Happy to answer any questions - thanks in advance!</p>

createchange
<p>It looks like you got the service ports mixed up. <code>targetPort</code> is set to <code>http</code>, which is port 80. This is the port that the service forwards to on the pod. The <code>port</code> value of the service is the port service exposes. So if you want your service to forward traffic to port 8080 of your pod, set <code>targetPort</code> to 8080.</p>
