NodePort 和 LoadBalancer 之间的区别?
Difference between NodePort and LoadBalancer?
我刚开始使用 Kubernetes,我对 NodePort 和 LoadBalancer 服务类型之间的区别感到困惑。
我理解的区别是 LoadBalancer 不支持 UDP,但除此之外,每当我们创建服务 Nodeport
或 Loadbalancer
时,我们都会获得服务 IP 和端口、NodePort 和端点.
来自 Kubernetes 文档:
NodePort: on top of having a cluster-internal IP, expose the service
on a port on each node of the cluster (the same port on each node).
You'll be able to contact the service on any NodeIP:NodePort
address.
LoadBalancer: on top of having a cluster-internal IP and
exposing service on a NodePort also, ask the cloud provider for a load
balancer which forwards to the Service exposed as a NodeIP:NodePort
for each Node.
因此,我将始终在 NodeIP:NodePort 上访问服务。
我的理解是,每当我们访问 node:NodePort 时,kubeproxy 将拦截请求并将其转发到相应的 pod。
关于 LoadBalancer 提到的另一件事是我们可以有一个外部 LB,它将在节点之间进行 LB。是什么阻止我们为创建为 nodeport 的服务放置 LB?
我真的很困惑。大多数文档或教程只讨论 LoadBalancer 服务,因此我在互联网上找不到太多内容。
没有什么能阻止您在节点前放置外部负载平衡器并使用 NodePort 选项。
LoadBalancer 选项仅用于在后台自动额外向您的云提供商请求新的软件 LB 实例。
我还不知道支持哪些云提供商的最新信息,但我看到它已经适用于 Compute Engine 和 OpenStack。
Difference between Node port and Load Balancer services.
Node Port
Load balancer
By creating a NodePort
service, you are saying to Kubernetes reserve a port on all its nodes and forwards incoming connections to the pods that are part of the service.
There is no such port reserve with Load balancer
on each node in the cluster.
NodePort
service can be accessed not only through the service’s internal cluster IP
, but also through any node’s IP and the reserved node port.
Only accessible by Load balancer
public IP
Specifying the port isn’t mandatory. Kubernetes will choose a random port if you omit it( default range 30000 - 32767).
Load balancer
will have its own unique, publicly accessible IP address and will redirect all connections to your service
If you only point your clients to the first node, when that node fails, your clients can’t access the service anymore
With Load balancer
in front of the nodes to make sure you’re spreading requests across all healthy nodes and never sending them to a node that’s offline at that moment.
Check out here两者的区别:
- 节点端口服务
- 负载均衡器服务
您将找到有关这些的信息:
- 集群 IP 服务
- 入口
我刚开始使用 Kubernetes,我对 NodePort 和 LoadBalancer 服务类型之间的区别感到困惑。
我理解的区别是 LoadBalancer 不支持 UDP,但除此之外,每当我们创建服务 Nodeport
或 Loadbalancer
时,我们都会获得服务 IP 和端口、NodePort 和端点.
来自 Kubernetes 文档:
NodePort: on top of having a cluster-internal IP, expose the service on a port on each node of the cluster (the same port on each node). You'll be able to contact the service on any NodeIP:NodePort address.
LoadBalancer: on top of having a cluster-internal IP and exposing service on a NodePort also, ask the cloud provider for a load balancer which forwards to the Service exposed as a NodeIP:NodePort for each Node.
因此,我将始终在 NodeIP:NodePort 上访问服务。 我的理解是,每当我们访问 node:NodePort 时,kubeproxy 将拦截请求并将其转发到相应的 pod。
关于 LoadBalancer 提到的另一件事是我们可以有一个外部 LB,它将在节点之间进行 LB。是什么阻止我们为创建为 nodeport 的服务放置 LB?
我真的很困惑。大多数文档或教程只讨论 LoadBalancer 服务,因此我在互联网上找不到太多内容。
没有什么能阻止您在节点前放置外部负载平衡器并使用 NodePort 选项。
LoadBalancer 选项仅用于在后台自动额外向您的云提供商请求新的软件 LB 实例。
我还不知道支持哪些云提供商的最新信息,但我看到它已经适用于 Compute Engine 和 OpenStack。
Difference between Node port and Load Balancer services.
Node Port |
Load balancer |
---|---|
By creating a NodePort service, you are saying to Kubernetes reserve a port on all its nodes and forwards incoming connections to the pods that are part of the service. |
There is no such port reserve with Load balancer on each node in the cluster. |
NodePort service can be accessed not only through the service’s internal cluster IP , but also through any node’s IP and the reserved node port. |
Only accessible by Load balancer public IP |
Specifying the port isn’t mandatory. Kubernetes will choose a random port if you omit it( default range 30000 - 32767). | Load balancer will have its own unique, publicly accessible IP address and will redirect all connections to your service |
If you only point your clients to the first node, when that node fails, your clients can’t access the service anymore | With Load balancer in front of the nodes to make sure you’re spreading requests across all healthy nodes and never sending them to a node that’s offline at that moment. |
Check out here两者的区别:
- 节点端口服务
- 负载均衡器服务
您将找到有关这些的信息:
- 集群 IP 服务
- 入口