From 6305dd39e99b3965831b0d315d722eb6e174abe1 Mon Sep 17 00:00:00 2001
From: Seal1998 <25196679+Seal1998@users.noreply.github.com>
Date: Wed, 8 Nov 2023 14:43:48 +0300
Subject: [PATCH] Metallb --lb-class cmd arg to support multiple LoadBalancer
 implementations (#10550)

* metallb --lb-class cmd arg to support multiple load balancer implementations

* removed loadbalancer_class from metallb_config; metallb_loadbalancer_class in role defaults
---
 roles/kubernetes-apps/metallb/defaults/main.yml         | 1 +
 roles/kubernetes-apps/metallb/templates/metallb.yaml.j2 | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/roles/kubernetes-apps/metallb/defaults/main.yml b/roles/kubernetes-apps/metallb/defaults/main.yml
index 22e2935b2..02f4e3cae 100644
--- a/roles/kubernetes-apps/metallb/defaults/main.yml
+++ b/roles/kubernetes-apps/metallb/defaults/main.yml
@@ -13,3 +13,4 @@ metallb_speaker_tolerations:
     key: node-role.kubernetes.io/control-plane
     operator: Exists
 metallb_controller_tolerations: []
+metallb_loadbalancer_class: ""
\ No newline at end of file
diff --git a/roles/kubernetes-apps/metallb/templates/metallb.yaml.j2 b/roles/kubernetes-apps/metallb/templates/metallb.yaml.j2
index eab386ff8..608ad31cd 100644
--- a/roles/kubernetes-apps/metallb/templates/metallb.yaml.j2
+++ b/roles/kubernetes-apps/metallb/templates/metallb.yaml.j2
@@ -1724,6 +1724,9 @@ spec:
       - args:
         - --port={{ metallb_port }}
         - --log-level={{ metallb_log_level }}
+{% if metallb_loadbalancer_class != "" %}
+        - --lb-class={{ metallb_loadbalancer_class }}
+{% endif %}
         env:
         - name: METALLB_ML_SECRET_NAME
           value: memberlist
@@ -1814,6 +1817,9 @@ spec:
       - args:
         - --port={{ metallb_port }}
         - --log-level={{ metallb_log_level }}
+{% if metallb_loadbalancer_class != "" %}
+        - --lb-class={{ metallb_loadbalancer_class }}
+{% endif %}
         env:
         - name: METALLB_NODE_NAME
           valueFrom:
-- 
GitLab