apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
name: nginx
spec:
ports:
# the port that this service should serve on
- port: 80
targetPort: 80
nodePort: 30000
selector:
name: nginx
type: NodePort
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
name: nginx
spec:
ports:
# the port that this service should serve on
- port: 80
targetPort: 80
nodePort: 30000
selector:
name: nginx
type: LoadBalancer
两种方法都支持负载均衡器.
端口范围在30000-32000之间,为什么?
如果我想使用端口3000,我该怎么办?
最佳答案
http://kubernetes.io/v1.0/docs/user-guide/services.html#type-nodeport:
If you set the type field to “NodePort”, the Kubernetes master will
allocate a port from a flag-configured range (default: 30000-32767).
与主机上运行的真实事物存在低端口冲突的风险.这就是为什么港口有限的原因.您仍然可以配置kube-apiserver – flag –service-node-port-range =