Skip to content
shiporbreak

No streak yet

Sign in

November 19, 2026 路 #64

KubernetesEasyOpen write-up

The Service pointing at the wrong port

Pods are Running and Ready on port 8080. Requests through the Service get connection refused. Which line is wrong?

apiVersion: v1
kind: Service
metadata:
  name: api
spec:
  selector:
    app: api
  ports:
    - name: http
      port: 80
      targetPort: 80

Next puzzle in UTC

One try. The first answer sticks.

How to fix it

port is what clients call on the Service. targetPort is where traffic goes in the pod. The app listens on 8080, so targetPort must be 8080 or the named port.

A Service forwards from port to targetPort on each selected pod. Here clients hit port 80 correctly, but kube-proxy forwards to port 80 in the pod, where nothing listens, so the kernel answers with a refused connection. The readiness probe probes 8080 directly, which is why the pods still look healthy.

kubectl get endpoints api shows the pod IPs with port 80, a quick tell.

Fix

  ports:
    - name: http
      port: 80
      targetPort: http

Name the container port http in the Deployment (containerPort: 8080, name: http) and refer to it by name, so the two cannot drift apart. protocol defaults to TCP.

Sponsor this spot

Put your tool on the puzzle
One labeled card, in front of engineers who show up every day from YouTube, TikTok, and Instagram.