Kuberntes部署MetalLB负载均衡器
MetalLB简介
MetalLB是一个为基础 Kubernetes集群提供负载均衡实现的工具,使用标准路由协议。
Kubernetes在基础集群中不提供网络负载均衡器(类型为LoadBalancer的服务)的实现。Kubernetes提供的网络负载平衡器实现都是调用各种IaaS平台(如GCP、AWS、Azure等)的接口代码。如果您没有运行在受支持的IaaS平台上(如GCP、AWS、Azure等),则创建时LoadBalancers将无限期处于“挂起”状态。
在基础集群中,操作员只有两个接口来将用户流量引入他们的集群,“NodePort”和“externalIPs”服务。
这两个选项在生产使用中都有显著的缺点,这使得基础集群成为 Kubernetes 生态系统中的二等公民。
MetalLB旨在通过提供与标准网络设备集成的网络负载均衡器实现来解决这种不平衡,以便基础群集上的external services尽可能“正常工作”。
root@master:~# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-master01 Ready control-plane 18h v1.30.2 192.168.1.31 <none> Ubuntu 24.04 LTS 6.8.0-35-generic containerd://1.7.18
k8s-master02 Ready control-plane 18h v1.30.2 192.168.1.32 <none> Ubuntu 24.04 LTS 6.8.0-35-generic containerd://1.7.18
k8s-master03 Ready control-plane 18h v1.30.2 192.168.1.33 <none> Ubuntu 24.04 LTS 6.8.0-35-generic containerd://1.7.18
k8s-node01 Ready <none> 18h v1.30.2 192.168.1.34 <none> Ubuntu 24.04 LTS 6.8.0-35-generic containerd://1.7.18
k8s-node02 Ready <none> 18h v1.30.2 192.168.1.35 <none> Ubuntu 24