From e31890806cd2f87b41d09a5827a257f1a928720d Mon Sep 17 00:00:00 2001 From: Ho Kim Date: Fri, 19 Aug 2022 13:49:51 +0900 Subject: [PATCH] Add 'avoid-buggy-ips' support of MetalLB (#9166) --- docs/metallb.md | 6 +++++- inventory/sample/group_vars/k8s_cluster/addons.yml | 3 ++- roles/kubernetes-apps/metallb/defaults/main.yml | 1 + .../metallb/templates/metallb-config.yml.j2 | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/metallb.md b/docs/metallb.md index 71fabde47..7121f1ea0 100644 --- a/docs/metallb.md +++ b/docs/metallb.md @@ -19,6 +19,7 @@ You have to explicitly enable the MetalLB extension and set an IP address range ```yaml metallb_enabled: true metallb_speaker_enabled: true +metallb_avoid_buggy_ips: true metallb_ip_range: - 10.5.0.0/16 ``` @@ -73,12 +74,13 @@ In this scenarion you should disable the MetalLB speaker and configure the `cali ```yaml metallb_speaker_enabled: false +metallb_avoid_buggy_ips: true metallb_ip_range: - 10.5.0.0/16 calico_advertise_service_loadbalancer_ips: "{{ metallb_ip_range }}" ``` -If you have additional loadbalancer IP pool in `metallb_additional_address_pools`, ensure to add them to the list. +If you have additional loadbalancer IP pool in `metallb_additional_address_pools` , ensure to add them to the list. ```yaml metallb_speaker_enabled: false @@ -90,11 +92,13 @@ metallb_additional_address_pools: - 10.6.0.0/16 protocol: "bgp" auto_assign: false + avoid_buggy_ips: true kube_service_pool_2: ip_range: - 10.10.0.0/16 protocol: "bgp" auto_assign: false + avoid_buggy_ips: true calico_advertise_service_loadbalancer_ips: - 10.5.0.0/16 - 10.6.0.0/16 diff --git a/inventory/sample/group_vars/k8s_cluster/addons.yml b/inventory/sample/group_vars/k8s_cluster/addons.yml index 7391fd82a..a3923195b 100644 --- a/inventory/sample/group_vars/k8s_cluster/addons.yml +++ b/inventory/sample/group_vars/k8s_cluster/addons.yml @@ -166,6 +166,7 @@ metallb_speaker_enabled: true # - "10.5.0.50-10.5.0.99" # metallb_pool_name: "loadbalanced" # metallb_auto_assign: true +# metallb_avoid_buggy_ips: false # metallb_speaker_nodeselector: # kubernetes.io/os: "linux" # metallb_controller_nodeselector: @@ -198,6 +199,7 @@ metallb_speaker_enabled: true # - "10.5.1.50-10.5.1.99" # protocol: "layer2" # auto_assign: false +# avoid_buggy_ips: false # metallb_protocol: "bgp" # metallb_peers: # - peer_address: 192.0.2.1 @@ -207,7 +209,6 @@ metallb_speaker_enabled: true # peer_asn: 64513 # my_asn: 4200000000 - argocd_enabled: false # argocd_version: v2.4.7 # argocd_namespace: argocd diff --git a/roles/kubernetes-apps/metallb/defaults/main.yml b/roles/kubernetes-apps/metallb/defaults/main.yml index 1d2be5301..3679aebe8 100644 --- a/roles/kubernetes-apps/metallb/defaults/main.yml +++ b/roles/kubernetes-apps/metallb/defaults/main.yml @@ -20,3 +20,4 @@ metallb_speaker_tolerations: metallb_controller_tolerations: [] metallb_pool_name: "loadbalanced" metallb_auto_assign: true +metallb_avoid_buggy_ips: false diff --git a/roles/kubernetes-apps/metallb/templates/metallb-config.yml.j2 b/roles/kubernetes-apps/metallb/templates/metallb-config.yml.j2 index 35f3d4e7e..8fda50674 100644 --- a/roles/kubernetes-apps/metallb/templates/metallb-config.yml.j2 +++ b/roles/kubernetes-apps/metallb/templates/metallb-config.yml.j2 @@ -34,6 +34,9 @@ data: {% if metallb_auto_assign == false %} auto-assign: false {% endif %} +{% if metallb_avoid_buggy_ips == true %} + avoid-buggy-ips: true +{% endif %} {% if metallb_additional_address_pools is defined %}{% for pool in metallb_additional_address_pools %} - name: {{ pool }} protocol: {{ metallb_additional_address_pools[pool].protocol }} @@ -41,6 +44,11 @@ data: {% for ip_range in metallb_additional_address_pools[pool].ip_range %} - {{ ip_range }} {% endfor %} +{% if metallb_additional_address_pools[pool].auto_assign is defined %} auto-assign: {{ metallb_additional_address_pools[pool].auto_assign }} +{% endif %} +{% if metallb_additional_address_pools[pool].avoid_buggy_ips is defined %} + avoid-buggy-ips: {{ metallb_additional_address_pools[pool].avoid_buggy_ips }} +{% endif %} {% endfor %} {% endif %}