gpt4 book ai didi

kubernetes - 服务类型 : NodePort & LoadBalancer 有什么区别

转载 作者:行者123 更新时间:2023-12-04 18:29:09 28 4
gpt4 key购买 nike

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 - 标志 --service-node-port-range=
http://kubernetes.io/v1.0/docs/admin/kube-apiserver.html

关于kubernetes - 服务类型 : NodePort & LoadBalancer 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35761684/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com