Today I confronted with a misunderstanding about servicePort
.
I expected that service can be linked with ingress specifying only servicePort: 80
, but both servicePort: 80
and servicePort: 8080
works.
Can someone help me to understand why both ports port
and targetPort
are exposed by Service, not only port
?
Service (app)
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 8080
Ingress (ingress-nginx)
spec:
rules:
- host: example.com
http:
paths:
- path: /
backend:
serviceName: app
servicePort: 8080