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.

106 lines
3.1 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_avoid_buggy_ips: true
  16. metallb_ip_range:
  17. - 10.5.0.0/16
  18. ```
  19. 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:
  20. ```yaml
  21. metallb_controller_tolerations:
  22. - key: "node-role.kubernetes.io/master"
  23. operator: "Equal"
  24. value: ""
  25. effect: "NoSchedule"
  26. - key: "node-role.kubernetes.io/control-plane"
  27. operator: "Equal"
  28. value: ""
  29. effect: "NoSchedule"
  30. ```
  31. ## BGP Mode
  32. When operating in BGP Mode MetalLB needs to have defined upstream peers:
  33. ```yaml
  34. metallb_protocol: bgp
  35. metallb_ip_range:
  36. - 10.5.0.0/16
  37. metallb_peers:
  38. - peer_address: 192.0.2.1
  39. peer_asn: 64512
  40. my_asn: 4200000000
  41. - peer_address: 192.0.2.2
  42. peer_asn: 64513
  43. my_asn: 4200000000
  44. ```
  45. Some upstream BGP peers may require password authentication:
  46. ```yaml
  47. metallb_protocol: bgp
  48. metallb_ip_range:
  49. - 10.5.0.0/16
  50. metallb_peers:
  51. - peer_address: 192.0.2.1
  52. peer_asn: 64512
  53. my_asn: 4200000000
  54. password: "changeme"
  55. ```
  56. When using calico >= 3.18 you can replace MetalLB speaker by calico Service LoadBalancer IP advertisement.
  57. See [calico service IPs advertisement documentation](https://docs.projectcalico.org/archive/v3.18/networking/advertise-service-ips#advertise-service-load-balancer-ip-addresses).
  58. In this scenarion you should disable the MetalLB speaker and configure the `calico_advertise_service_loadbalancer_ips` to match your `metallb_ip_range`
  59. ```yaml
  60. metallb_speaker_enabled: false
  61. metallb_avoid_buggy_ips: true
  62. metallb_ip_range:
  63. - 10.5.0.0/16
  64. calico_advertise_service_loadbalancer_ips: "{{ metallb_ip_range }}"
  65. ```
  66. If you have additional loadbalancer IP pool in `metallb_additional_address_pools` , ensure to add them to the list.
  67. ```yaml
  68. metallb_speaker_enabled: false
  69. metallb_ip_range:
  70. - 10.5.0.0/16
  71. metallb_additional_address_pools:
  72. kube_service_pool_1:
  73. ip_range:
  74. - 10.6.0.0/16
  75. protocol: "bgp"
  76. auto_assign: false
  77. avoid_buggy_ips: true
  78. kube_service_pool_2:
  79. ip_range:
  80. - 10.10.0.0/16
  81. protocol: "bgp"
  82. auto_assign: false
  83. avoid_buggy_ips: true
  84. calico_advertise_service_loadbalancer_ips:
  85. - 10.5.0.0/16
  86. - 10.6.0.0/16
  87. - 10.10.0.0/16
  88. ```