Skip to content

Commit

Permalink
chore: fix cluster recreation on node reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Ugaz committed Oct 30, 2020
1 parent 78f6c57 commit 22f047b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
21 changes: 10 additions & 11 deletions k3s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions terraform/agent.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
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"
}

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"
}

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"
Expand All @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 22f047b

Please sign in to comment.