PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
640 stars 135 forks source link

Add advertised address #139

Closed abelfodil closed 3 years ago

abelfodil commented 3 years ago

Add advertised address

Summary

Add the option to specify an advertised address for each node in the cluster. This is useful when one uses a VPN and would like to use the address of the node in the VPN.

Issue type

Test instructions

Define an (different) advertised address for each node (one can use ansible_host). See if the cluster builds.

Acceptance Criteria

Additional Information

Here's an example of a project using this feature.

xanmanning commented 3 years ago

Could this not be used with?:

---
k3s_agent:
  node-ip: "{{ advertised_address }}"

eg.

    - name: Ensure the node registration address is defined from advertised address
      ansible.builtin.set_fact:
        k3s_registration_address: "{{ hostvars[k3s_control_delegate].k3s_agent.node-ip }}"
      check_mode: false
      when:
        - k3s_registration_address is not defined
        - k3s_control_node_address is not defined
        - hostvars[k3s_control_delegate].k3s_agent.node-ip is defined

See:

abelfodil commented 3 years ago

It would indeed be better. One can also define node-ip in the k3s_server dict (see https://rancher.com/docs/k3s/latest/en/installation/install-options/server-config/#agent-networking). We should we take that into account perhaps.

EDIT: in fact, it should solely come from the k3s_server dict since the control delegate is a server itself (or is this logic flawed?)

EDIT2: in the current changes, k3s_server has precedence

xanmanning commented 3 years ago

Apologies for the delay btw, hectic time at work!

abelfodil commented 3 years ago

@xanmanning the changes don't work with k3s_server or k3s_agent, but when I set k3s_runtime_config directly, they work perfectly fine.