godwot 2019-09-17
Kubernetes - Port,Targetport和NodePort 1
使用Kubernetes Service时,会遇到以下一些术语:
看一下定义示例服务的以下规范:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
ports:
- port: 8080
targetPort: 8070
nodePort: 8888
protocol: TCP
selector:
component: my-service-app请注意上述规范中的以下部分内容:
这是 Kubernetes 的ipTables 配置的结果。它维护 nodePort 与 targetPort 的映射。K8s Kube-Proxy使用ipTables来解析特定nodePort上的请求,并将它们重定向到适当的pod。