Question 530
At Northstar finance, in an isolated training cluster during a scheduled maintenance rehearsal: Service invoice-svc in ledger uses the wrong targetPort; the application container is listening on 8080 and Service port must remain 80. Work only within the stated target and verify before declaring success. Which Kubernetes behavior best explains the required change or diagnosis?
Explanation
Correct Answer
The Service port is what clients connect to, while targetPort must reach the actual backend listener. This explains the stated condition. The corresponding action is: Run kubectl -n ledger patch service invoice-svc --type=merge -p '{"spec":{"ports":[{"port":80,"targetPort":8080}]}}' for the lab's single-port Service. The direct acceptance evidence is: Run kubectl -n ledger describe service invoice-svc and perform a connection test to port 80.
Incorrect Answers
This principle describes a separate cause: An Ingress resource declares HTTP host/path routing but requires an actual installed Ingress controller. The reported condition is governed by: The Service port is what clients connect to, while targetPort must reach the actual backend listener. The two mechanisms should not be conflated.
The offered statement is true for this other mechanism: Gateway API HTTPRoutes express matching and backend behavior while Gateway resources own compatible listeners. It does not explain the facts described here, which follow from: The Service port is what clients connect to, while targetPort must reach the actual backend listener.
This principle describes a separate cause: CoreDNS behavior is configured separately from Service definitions, and incorrect DNS plugins or cluster domain can break discovery cluster-wide. The reported condition is governed by: The Service port is what clients connect to, while targetPort must reach the actual backend listener. The two mechanisms should not be conflated.