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.

89 lines
2.8 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. ## Prerequisites
  6. You have to configure arp_ignore and arp_announce to avoid answering ARP queries from kube-ipvs0 interface for MetalLB to work.
  7. ```yaml
  8. kube_proxy_strict_arp: true
  9. ```
  10. ## Install
  11. You have to explicitly enable the MetalLB extension and set an IP address range from which to allocate LoadBalancer IPs.
  12. ```yaml
  13. metallb_enabled: true
  14. metallb_speaker_enabled: true
  15. metallb_ip_range:
  16. - 10.5.0.0/16
  17. ```
  18. 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:
  19. ```yaml
  20. metallb_controller_tolerations:
  21. - key: "node-role.kubernetes.io/master"
  22. operator: "Equal"
  23. value: ""
  24. effect: "NoSchedule"
  25. - key: "node-role.kubernetes.io/control-plane"
  26. operator: "Equal"
  27. value: ""
  28. effect: "NoSchedule"
  29. ```
  30. ## BGP Mode
  31. When operating in BGP Mode MetalLB needs to have defined upstream peers:
  32. ```yaml
  33. metallb_protocol: bgp
  34. metallb_ip_range:
  35. - 10.5.0.0/16
  36. metallb_peers:
  37. - peer_address: 192.0.2.1
  38. peer_asn: 64512
  39. my_asn: 4200000000
  40. - peer_address: 192.0.2.2
  41. peer_asn: 64513
  42. my_asn: 4200000000
  43. ```
  44. When using calico >= 3.18 you can replace MetalLB speaker by calico Service LoadBalancer IP advertisement.
  45. See [calico service IPs advertisement documentation](https://docs.projectcalico.org/archive/v3.18/networking/advertise-service-ips#advertise-service-load-balancer-ip-addresses).
  46. In this scenarion you should disable the MetalLB speaker and configure the `calico_advertise_service_loadbalancer_ips` to match your `metallb_ip_range`
  47. ```yaml
  48. metallb_speaker_enabled: false
  49. metallb_ip_range:
  50. - 10.5.0.0/16
  51. calico_advertise_service_loadbalancer_ips: "{{ metallb_ip_range }}"
  52. ```
  53. If you have additional loadbalancer IP pool in `metallb_additional_address_pools`, ensure to add them to the list.
  54. ```yaml
  55. metallb_speaker_enabled: false
  56. metallb_ip_range:
  57. - 10.5.0.0/16
  58. metallb_additional_address_pools:
  59. kube_service_pool_1:
  60. ip_range:
  61. - 10.6.0.0/16
  62. protocol: "bgp"
  63. auto_assign: false
  64. kube_service_pool_2:
  65. ip_range:
  66. - 10.10.0.0/16
  67. protocol: "bgp"
  68. auto_assign: false
  69. calico_advertise_service_loadbalancer_ips:
  70. - 10.5.0.0/16
  71. - 10.6.0.0/16
  72. - 10.10.0.0/16
  73. ```