You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.6 KiB

  1. # MetalLB
  2. MetalLB hooks into your Kubernetes cluster, and provides a network load-balancer implementation.
  3. It allows you to create Kubernetes services of type "LoadBalancer" in clusters that don't run on a cloud provider, and thus cannot simply hook into 3rd party products to provide load-balancers.
  4. The default operationg mode of MetalLB is in ["Layer2"](https://metallb.universe.tf/concepts/layer2/) but it can also operate in ["BGP"](https://metallb.universe.tf/concepts/bgp/) mode.
  5. ## Install
  6. You have to explicitly enable the MetalLB extension and set an IP address range from which to allocate LoadBalancer IPs.
  7. ```yaml
  8. metallb_enabled: true
  9. metallb_speaker_enabled: true
  10. metallb_ip_range:
  11. - 10.5.0.0/16
  12. ```
  13. By default only the MetalLB BGP speaker is allowed to run on control plane nodes. If you have a single node cluster or a cluster where control plane are also worker nodes you may need to enable tolerations for the MetalLB controller:
  14. ```yaml
  15. metallb_controller_tolerations:
  16. - key: "node-role.kubernetes.io/master"
  17. operator: "Equal"
  18. value: ""
  19. effect: "NoSchedule"
  20. - key: "node-role.kubernetes.io/control-plane"
  21. operator: "Equal"
  22. value: ""
  23. effect: "NoSchedule"
  24. ```
  25. ## BGP Mode
  26. When operating in BGP Mode MetalLB needs to have defined upstream peers:
  27. ```yaml
  28. metallb_protocol: bgp
  29. metallb_ip_range:
  30. - 10.5.0.0/16
  31. metallb_peers:
  32. - peer_address: 192.0.2.1
  33. peer_asn: 64512
  34. my_asn: 4200000000
  35. - peer_address: 192.0.2.2
  36. peer_asn: 64513
  37. my_asn: 4200000000
  38. ```
  39. When using calico >= 3.18 you can replace MetalLB speaker by calico Service LoadBalancer IP advertisement.
  40. See [calico service IPs advertisement documentation](https://docs.projectcalico.org/archive/v3.18/networking/advertise-service-ips#advertise-service-load-balancer-ip-addresses).
  41. In this scenarion you should disable the MetalLB speaker and configure the `calico_advertise_service_loadbalancer_ips` to match your `metallb_ip_range`
  42. ```yaml
  43. metallb_speaker_enabled: false
  44. metallb_ip_range:
  45. - 10.5.0.0/16
  46. calico_advertise_service_loadbalancer_ips: "{{ metallb_ip_range }}"
  47. ```
  48. If you have additional loadbalancer IP pool in `metallb_additional_address_pools`, ensure to add them to the list.
  49. ```yaml
  50. metallb_speaker_enabled: false
  51. metallb_ip_range:
  52. - 10.5.0.0/16
  53. metallb_additional_address_pools:
  54. kube_service_pool_1:
  55. ip_range:
  56. - 10.6.0.0/16
  57. protocol: "bgp"
  58. auto_assign: false
  59. kube_service_pool_2:
  60. ip_range:
  61. - 10.10.0.0/16
  62. protocol: "bgp"
  63. auto_assign: false
  64. calico_advertise_service_loadbalancer_ips:
  65. - 10.5.0.0/16
  66. - 10.6.0.0/16
  67. - 10.10.0.0/16
  68. ```