Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(k3s): Add option to set MetalLB interfaces #583

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions roles/k3s_server_post/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ metal_lb_mode: layer2
metal_lb_available_timeout: 240s
metal_lb_controller_tag_version: v0.14.3
metal_lb_ip_range: 192.168.30.80-192.168.30.90
metal_lb_interfaces:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an empty list by default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way I can have a condition on this in metallb.crs.j2. If empty, no interfaces are set in the L2Advertisement resource, which in turn triggers the default of metallb: https://metallb.universe.tf/configuration/_advanced_l2_configuration/#specify-network-interfaces-that-lb-ip-can-be-announced-from

Let me know if there's a better default and I'll adjust.

4 changes: 4 additions & 0 deletions roles/k3s_server_post/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ argument_specs:
description: MetalLB ip range for load balancer
default: 192.168.30.80-192.168.30.90

metal_lb_interfaces:
description: MetalLB interfaces to announce on. By default, announces on all interfaces.
default:

metal_lb_controller_tag_version:
description: Image tag for MetalLB
default: v0.14.3
Expand Down
7 changes: 7 additions & 0 deletions roles/k3s_server_post/templates/metallb.crs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ kind: L2Advertisement
metadata:
name: default
namespace: metallb-system
{% if metal_lb_interfaces %}
spec:
interfaces:
{% for interface in metal_lb_interfaces %}
- {{ interface }}
{% endfor %}
{% endif %}
{% endif %}
{% if metal_lb_mode == "bgp" %}
---
Expand Down
Loading