Skip to content

Commit 1bbbf31

Browse files
authored
Set k3s node IP from access network IP (#556)
* set k3s node IP from access network IP * bump CI image
1 parent 25a1ebd commit 1bbbf31

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

ansible/roles/k3s/files/start_k3s.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
k3s_token: "{{ os_metadata.meta.k3s_token }}"
66
k3s_server_name: "{{ os_metadata.meta.control_address }}"
77
service_name: "{{ 'k3s-agent' if k3s_server_name is defined else 'k3s' }}"
8+
access_ip: "{{ os_metadata.meta.access_ip }}"
89
tasks:
910
- name: Ensure password directory exists
1011
ansible.builtin.file:
@@ -22,6 +23,13 @@
2223
path: "/etc/systemd/system/{{ service_name }}.service.env"
2324
line: "K3S_TOKEN={{ k3s_token }}"
2425

26+
- name: Add the node IP to the environment
27+
# NB this isn't natively setable via envvars, have to modify
28+
# INSTALL_K3S_EXEC to support it
29+
ansible.builtin.lineinfile:
30+
path: "/etc/systemd/system/{{ service_name }}.service.env"
31+
line: "K3S_NODE_IP={{ access_ip }}"
32+
2533
- name: Add server url to agents
2634
ansible.builtin.lineinfile:
2735
path: "/etc/systemd/system/{{ service_name }}.service.env"

ansible/roles/k3s/tasks/install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
cmd: /usr/bin/k3s-install.sh
4848
environment:
4949
INSTALL_K3S_VERSION: "{{ k3s_version }}"
50-
INSTALL_K3S_EXEC: "{{ item }}"
50+
INSTALL_K3S_EXEC: "{{ item }} --node-ip=${K3S_NODE_IP}"
5151
INSTALL_K3S_SKIP_START: "true"
5252
INSTALL_K3S_SKIP_ENABLE: "true"
5353
INSTALL_K3S_BIN_DIR: "/usr/bin"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"cluster_image": {
3-
"RL8": "openhpc-RL8-250122-1150-a0899ef8",
4-
"RL9": "openhpc-RL9-250122-1150-a0899ef8"
3+
"RL8": "openhpc-RL8-250130-1126-8f2a7703",
4+
"RL9": "openhpc-RL9-250130-1127-8f2a7703"
55
}
66
}

environments/skeleton/{{cookiecutter.environment}}/tofu/control.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ resource "openstack_compute_instance_v2" "control" {
6060
metadata = {
6161
environment_root = var.environment_root
6262
k3s_token = local.k3s_token
63-
# TODO: set k3s_subnet from access_network
63+
access_ip = openstack_networking_port_v2.control[var.cluster_networks[0].network].all_fixed_ips[0]
6464
}
6565

6666
user_data = <<-EOF

environments/skeleton/{{cookiecutter.environment}}/tofu/node_group/nodes.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ resource "openstack_compute_instance_v2" "compute_fixed_image" {
8787
environment_root = var.environment_root
8888
k3s_token = var.k3s_token
8989
control_address = var.control_address
90+
access_ip = openstack_networking_port_v2.compute["${each.key}-${var.networks[0].network}"].all_fixed_ips[0]
9091
},
9192
{for e in var.compute_init_enable: e => true}
9293
)
@@ -138,7 +139,7 @@ resource "openstack_compute_instance_v2" "compute" {
138139
environment_root = var.environment_root
139140
k3s_token = var.k3s_token
140141
control_address = var.control_address
141-
# TODO: set k3s_subnet from access_network
142+
access_ip = openstack_networking_port_v2.compute["${each.key}-${var.networks[0].network}"].all_fixed_ips[0]
142143
},
143144
{for e in var.compute_init_enable: e => true}
144145
)

0 commit comments

Comments
 (0)