k3s-io / k3s-ansible

Apache License 2.0
2.01k stars 802 forks source link

Set firewall rules for custom CIDR ranges #293

Closed laszlojau closed 7 months ago

laszlojau commented 8 months ago

Changes

role: prereq

Linked Issues

292

laszlojau commented 8 months ago

I tried to keep multiple options open for passing the CIDR range to the prereq role, happy to update/simplify the logic if needed.

dereknola commented 8 months ago

I'm happy to support this since we introduced the firewall exception as an addon. But you should simplify the logic. Just have a cluster_cidr and service_cidr default vars that could be overriden by the inventory var.

Additionally, you need to sign all your commits to comply with the DCO.

laszlojau commented 8 months ago

I'm happy to support this since we introduced the firewall exception as an addon. But you should simplify the logic. Just have a cluster_cidr and service_cidr default vars that could be overriden by the inventory var.

Wouldn't that mean having to set the variable twice? Or you mean pass those values through as k3s server arguments as well? I'd prefer setting it once if possible. What if I just looked at the server_config_yaml?

I.e. do something like this instead:

cluster_cidr: "{{ (server_config_yaml | from_yaml)['cluster-cidr'] | default('10.42.0.0/16') }}"
service_cidr: "{{ (server_config_yaml | from_yaml)['service-cidr'] | default('10.43.0.0/16') }}"

And then the loop could be something like:

  loop: "{{ (cluster_cidr + ',' + service_cidr) | split(',') }}"
dereknola commented 7 months ago

Yeah i think that would work:

laszlojau commented 7 months ago

Updated the logic and signed the commit, let me know if you need anything else.