From 22f047beb12b5c53a194cc49a4a0c38ca16e59ba Mon Sep 17 00:00:00 2001 From: Pierre Ugaz Date: Thu, 29 Oct 2020 22:28:54 -0300 Subject: [PATCH] chore: fix cluster recreation on node reboot --- k3s.yml | 21 ++++++++++----------- terraform/agent.tf | 10 +++++----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/k3s.yml b/k3s.yml index 6bbc5bb..3fb52f4 100644 --- a/k3s.yml +++ b/k3s.yml @@ -15,10 +15,9 @@ onboot: image: linuxkit/sysfs:v0.8 - name: format image: linuxkit/format:v0.8 - command: ["/usr/bin/format", "-force", "-verbose", "-type", "ext4", "-label", "ephemeral0", "/dev/vda"] - name: mount image: linuxkit/mount:v0.8 - command: ["/usr/bin/mountie", "-label", "ephemeral0", "/var/lib"] + command: ["/usr/bin/mountie", "/var/lib/rancher"] - name: move-logs image: busybox:latest binds: @@ -27,8 +26,8 @@ onboot: - name: mkdir image: busybox:latest binds: - - /var/lib:/host_var_lib - command: ["/bin/sh", "-c", "mkdir -p /host_var_lib/rancher /host_var_lib/etc-rancher"] + - /var/lib/rancher:/host_var_lib_rancher + command: ["/bin/sh", "-c", "mkdir -p /host_var_lib_rancher/k3s /host_var_lib_rancher/etc"] - name: dhcpcd image: linuxkit/dhcpcd:v0.8 command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] @@ -74,8 +73,8 @@ services: - /etc/resolv.conf:/etc/resolv.conf - /lib/modules:/lib/modules - /run/config/rancher:/bin/rancher - - /var/lib/etc-rancher:/etc/rancher - - /var/lib/rancher:/var/lib/rancher + - /var/lib/rancher/etc:/etc/rancher + - /var/lib/rancher/k3s:/var/lib/rancher rootfsPropagation: shared cgroupsPath: podruntime/k3s - name: getty @@ -85,17 +84,17 @@ services: binds.add: - /boot:/boot - /etc/motd:/etc/motd - - /var/lib/etc-rancher:/etc/rancher - - /var/lib/rancher:/var/lib/rancher + - /var/lib/rancher/etc:/etc/rancher + - /var/lib/rancher/k3s:/var/lib/rancher cgroupsPath: systemreserved/getty - name: sshd image: linuxkit/sshd:v0.8 binds.add: - /boot:/boot - /etc/motd:/etc/motd - - /var/lib/etc-rancher:/etc/rancher - - /var/lib/rancher:/var/lib/rancher - /run/config/ssh:/root/.ssh + - /var/lib/rancher/etc:/etc/rancher + - /var/lib/rancher/k3s:/var/lib/rancher cgroupsPath: systemreserved/sshd files: - path: etc/linuxkit.yml @@ -111,7 +110,7 @@ files: Project on GitHub: https://github.com/ulm0/k3skit mode: "0644" - - path: /etc/os-release + - path: etc/os-release contents: | NAME="k3skit" ID="k3skit" diff --git a/terraform/agent.tf b/terraform/agent.tf index a754d5e..aafb555 100644 --- a/terraform/agent.tf +++ b/terraform/agent.tf @@ -1,6 +1,6 @@ resource libvirt_volume agent_os { count = var.agents - name = format("k3skit-agent-%s-os.img", count.index) + name = format("k3skit-agent-%s-os.img", count.index + 1) pool = libvirt_pool.k3skit.name source = var.k3skit_os format = "raw" @@ -8,7 +8,7 @@ resource libvirt_volume agent_os { resource libvirt_volume agent_volume { count = var.agents - name = format("k3skit-agent-%s-volume.img", count.index) + name = format("k3skit-agent-%s-volume.img", count.index + 1) pool = libvirt_pool.k3skit.name size = 20 * 1024 * 1024 * 1024 # Size in bytes (N (GiB) * 1024 (MiB) * 1024 (KiB) * 1024 (Bytes)) format = "raw" @@ -16,7 +16,7 @@ resource libvirt_volume agent_volume { resource libvirt_volume agent_kernel { count = var.agents - name = format("k3skit-agent-%s-kernel.img", count.index) + name = format("k3skit-agent-%s-kernel.img", count.index + 1) source = var.k3skit_kernel pool = libvirt_pool.k3skit.name format = "raw" @@ -40,7 +40,7 @@ resource libvirt_cloudinit_disk agent_metadata { resource libvirt_domain agent { depends_on = [libvirt_domain.server] count = var.agents - name = format("k3skit-agent-%s", count.index) + name = format("k3skit-agent-%s", count.index + 1) memory = "2048" vcpu = 1 qemu_agent = false @@ -57,7 +57,7 @@ resource libvirt_domain agent { network_interface { network_name = "default" - hostname = format("k3skit-agent-%s", count.index) + hostname = format("k3skit-agent-%s", count.index + 1) wait_for_lease = true }