可靠地将流量路由到裸机 kubernetes 集群
Reliably routing traffic to bare metal kubernetes cluster
我已经在家里启动了自己的 kubernetes 集群来学习 kubernetes,但在尝试公开我的 Web 服务时我总是卡住。
我已经使用 k3s 引导集群并且一切正常,但我不知道如何可靠地公开我的 web 服务。
我已经安装了 traefik 2.2 作为入口控制器,它通过负载均衡器服务公开(我使用 k3s 的 lb)。
我有一个指向集群节点之一的全局 IP 的 A 记录,并且我已经转发了我想要公开的端口,以该节点为目标。
我认为我没有以正确的方式将流量路由到我的负载均衡器。将流量路由到我的一个节点上的负载均衡器服务是可行的,但如果我出于某种原因需要重新启动集群,负载均衡器可能最终会在另一个节点上,我必须更改端口转发的目标 IP。设置负载均衡器服务的 externalIP
字段没有任何效果。
如何可靠地将流量路由到我的集群?我觉得我误解了设置的某些部分,如果有人能指出正确的方向,我将不胜感激。
通常你想使用 ServiceType:
LoadBalancer:
Exposes the Service externally using a cloud provider's load balancer.
NodePort
and ClusterIP
Services, to which the external load
balancer routes, are automatically created.
但是,由于 Kubernetes 没有为裸机环境提供 load-balancer 解决方案,因此该服务很难暴露在裸机集群中。
您可以尝试的解决方案是 MetalLB:
MetalLB is a load-balancer implementation for bare metal Kubernetes
clusters, using standard routing protocols.
Kubernetes does not offer an implementation of network load-balancers
(Services of type LoadBalancer) for bare metal clusters. The
implementations of Network LB that Kubernetes does ship with are all
glue code that calls out to various IaaS platforms (GCP, AWS, Azure…).
If you’re not running on a supported IaaS platform (GCP, AWS, Azure…),
LoadBalancers will remain in the “pending” state indefinitely when
created.
您可以在链接文档中找到有关安装、配置和使用的必要详细信息。有了它,您应该能够轻松设置负载平衡。
我已经在家里启动了自己的 kubernetes 集群来学习 kubernetes,但在尝试公开我的 Web 服务时我总是卡住。 我已经使用 k3s 引导集群并且一切正常,但我不知道如何可靠地公开我的 web 服务。 我已经安装了 traefik 2.2 作为入口控制器,它通过负载均衡器服务公开(我使用 k3s 的 lb)。
我有一个指向集群节点之一的全局 IP 的 A 记录,并且我已经转发了我想要公开的端口,以该节点为目标。
我认为我没有以正确的方式将流量路由到我的负载均衡器。将流量路由到我的一个节点上的负载均衡器服务是可行的,但如果我出于某种原因需要重新启动集群,负载均衡器可能最终会在另一个节点上,我必须更改端口转发的目标 IP。设置负载均衡器服务的 externalIP
字段没有任何效果。
如何可靠地将流量路由到我的集群?我觉得我误解了设置的某些部分,如果有人能指出正确的方向,我将不胜感激。
通常你想使用 ServiceType:
LoadBalancer:
Exposes the Service externally using a cloud provider's load balancer.
NodePort
andClusterIP
Services, to which the external load balancer routes, are automatically created.
但是,由于 Kubernetes 没有为裸机环境提供 load-balancer 解决方案,因此该服务很难暴露在裸机集群中。
您可以尝试的解决方案是 MetalLB:
MetalLB is a load-balancer implementation for bare metal Kubernetes clusters, using standard routing protocols.
Kubernetes does not offer an implementation of network load-balancers (Services of type LoadBalancer) for bare metal clusters. The implementations of Network LB that Kubernetes does ship with are all glue code that calls out to various IaaS platforms (GCP, AWS, Azure…). If you’re not running on a supported IaaS platform (GCP, AWS, Azure…), LoadBalancers will remain in the “pending” state indefinitely when created.
您可以在链接文档中找到有关安装、配置和使用的必要详细信息。有了它,您应该能够轻松设置负载平衡。