techno-tim / k3s-ansible

The easiest way to bootstrap a self-hosted High Availability Kubernetes cluster. A fully automated HA k3s etcd install with kube-vip, MetalLB, and more. Build. Destroy. Repeat.
https://technotim.live/posts/k3s-etcd-ansible/
Apache License 2.0
2.41k stars 1.05k forks source link

Feature request: skip MetalLB installation if Traefik is enabled? #85

Closed gbyczyns closed 2 years ago

gbyczyns commented 2 years ago

I modified the scripts so that the MetalLB (which I don't want) won't be installed if the Traefik is enabled:

diff --git a/roles/prereq/tasks/main.yml b/roles/prereq/tasks/main.yml
index dcab613..354497b 100644
--- a/roles/prereq/tasks/main.yml
+++ b/roles/prereq/tasks/main.yml
@@ -1,4 +1,9 @@
 ---
+- name: Set install_metal_lb fact to true if Traefik is disabled
+  set_fact:
+    install_metal_lb: true
+  when: extra_server_args is search('--disable traefik')
+
 - name: Set same timezone on every Server
   timezone:
     name: "{{ system_timezone }}"

Then I added the following clause to all the tasks related to metallb:

  when: install_metal_lb|default(false)

It's a dirty solution, but works for me. I could create a pull request, but I was wondering if this is the right approach? My assumption is that metallb and traefik are mutually exclusive, but maybe I'm wrong and such an approach doesn't make sense...

timothystewart6 commented 2 years ago

Hi! Thanks! They are actually not mutually exclusive, you can (and I do) run both MetalLB and traefik on the same instance. MetalLB is your service load balancer and traefik is your Ingress Controller. Maybe you are confusing this with Klipper and MetalLB? Either way, since MetalLB is core to this playbook for now I don't think I would merge in a PR to disable it. There are other resources and even tests built to test it and adding this condition would increase the changes needed exponentially. But, that being said MetalLB is core to this repo. This issue can be a reference if anyone else wants to do this.