Why define a named container port (for example name: http) and set the Service targetPort: http instead of only numeric ports?
Select an answer to reveal the explanation.
Short Explanation
Names are sticky labels on the door while room numbers can move. If the container still calls the port http, the Service can keep targeting http even after you renumber 8080 to 9090. Fewer brittle YAML chases.
Full Explanation
Kubernetes allows targetPort to reference a container port by name. When the numeric listen port changes but the port name remains stable, Services using that name continue to select the correct port without editing every numeric targetPort. Named ports do not disable Endpoints, do not force LoadBalancer, and are not limited to a single Service type.