今天我遇到了一个关于servicePort的误解。
我以为服务可以与ingress链接,只指定servicePort: 80,但是servicePort: 80和servicePort: 8080 也都可以。
谁能帮助我理解为什么服务同时暴露port和targetPort,而不是只有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