From c68a09dcf1002f74ad9583dd43ecea1f627dd954 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sat, 23 Dec 2023 18:45:45 +0200 Subject: [PATCH] chore(metallb): add lb ip on service as annotation (#645) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --- library/common-test/tests/service/load_balancer_test.yaml | 5 +++++ library/common/Chart.yaml | 2 +- .../common/templates/lib/service/_additionalAnnotations.tpl | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/library/common-test/tests/service/load_balancer_test.yaml b/library/common-test/tests/service/load_balancer_test.yaml index 6db7ae23..6e79ab7b 100644 --- a/library/common-test/tests/service/load_balancer_test.yaml +++ b/library/common-test/tests/service/load_balancer_test.yaml @@ -142,3 +142,8 @@ tests: app.kubernetes.io/instance: test-release-name app.kubernetes.io/name: common-test pod.name: my-workload + - documentIndex: *serviceDoc + isSubset: + path: metadata.annotations + content: + metallb.universe.tf/loadBalancerIPs: "10.100.200.45" diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index e3288146..46cb4669 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 16.2.14 +version: 16.2.15 diff --git a/library/common/templates/lib/service/_additionalAnnotations.tpl b/library/common/templates/lib/service/_additionalAnnotations.tpl index e314083c..8144e0fd 100644 --- a/library/common/templates/lib/service/_additionalAnnotations.tpl +++ b/library/common/templates/lib/service/_additionalAnnotations.tpl @@ -21,6 +21,9 @@ annotations: The annotations variable reference, to append the MetalLB annotatio {{- if (hasKey $rootCtx.Values.global "metallb") -}} {{- if $rootCtx.Values.global.metallb.addServiceAnnotations -}} {{- $_ := set $annotations "metallb.universe.tf/allow-shared-ip" $sharedKey -}} + {{- if $objectData.loadBalancerIP -}} + {{- $_ := set $annotations "metallb.universe.tf/loadBalancerIPs" (tpl $objectData.loadBalancerIP $rootCtx) -}} + {{- end -}} {{- end -}} {{- end -}} {{- end -}}