From 6448948e9f2d0bc3c87678ceedf0aab7e712d405 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Mon, 20 Feb 2023 06:24:19 +0100 Subject: [PATCH] Fix dual-stack clusters with multiple master nodes (#237) * Test IPv6 scenario with two master nodes * Fix IPv6 multimaster setup --------- Co-authored-by: Techno Tim --- molecule/ipv6/host_vars/control2.yml | 3 +++ molecule/ipv6/molecule.yml | 17 ++++++++++++++++- roles/k3s/master/defaults/main.yml | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 molecule/ipv6/host_vars/control2.yml diff --git a/molecule/ipv6/host_vars/control2.yml b/molecule/ipv6/host_vars/control2.yml new file mode 100644 index 00000000..97fbc81a --- /dev/null +++ b/molecule/ipv6/host_vars/control2.yml @@ -0,0 +1,3 @@ +--- +node_ipv4: 192.168.123.12 +node_ipv6: fdad:bad:ba55::de:12 diff --git a/molecule/ipv6/molecule.yml b/molecule/ipv6/molecule.yml index d6935cb7..2ad64234 100644 --- a/molecule/ipv6/molecule.yml +++ b/molecule/ipv6/molecule.yml @@ -4,7 +4,6 @@ dependency: driver: name: vagrant platforms: - - name: control1 box: generic/ubuntu2204 memory: 2048 @@ -21,6 +20,22 @@ platforms: ssh.username: "vagrant" ssh.password: "vagrant" + - name: control2 + box: generic/ubuntu2204 + memory: 2048 + cpus: 2 + groups: + - k3s_cluster + - master + interfaces: + - network_name: private_network + ip: fdad:bad:ba55::de:12 + config_options: + # We currently can not use public-key based authentication on Ubuntu 22.04, + # see: https://github.com/chef/bento/issues/1405 + ssh.username: "vagrant" + ssh.password: "vagrant" + - name: node1 box: generic/ubuntu2204 memory: 2048 diff --git a/roles/k3s/master/defaults/main.yml b/roles/k3s/master/defaults/main.yml index 9776f893..9e2fe633 100644 --- a/roles/k3s/master/defaults/main.yml +++ b/roles/k3s/master/defaults/main.yml @@ -9,7 +9,7 @@ server_init_args: >- {% if ansible_hostname == hostvars[groups['master'][0]]['ansible_hostname'] %} --cluster-init {% else %} - --server https://{{ hostvars[groups['master'][0]].k3s_node_ip }}:6443 + --server https://{{ hostvars[groups['master'][0]].k3s_node_ip | split(",") | first | ansible.utils.ipwrap }}:6443 {% endif %} --token {{ k3s_token }} {% endif %}