From d2562a66df9b129b5fbf936394c0810f38737017 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Fri, 2 Dec 2022 12:24:23 +0100 Subject: [PATCH] adding install script --- butane/ckube-install | 5 ++++ butane/k8s-leader-install.yaml | 8 ++++-- ipxe/tftpboot/menu.ipxe | 51 +++++++++++++++++++++++++++------- 3 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 butane/ckube-install diff --git a/butane/ckube-install b/butane/ckube-install new file mode 100644 index 0000000..858a783 --- /dev/null +++ b/butane/ckube-install @@ -0,0 +1,5 @@ +#!/bin/sh + +target=$(xargs -n1 -a /proc/cmdline | awk -F '=' '/^flatcar.target=.*/ {print $NF}') + +flatcar-install -d ${target} -i /opt/ignition.json && udevadm settle && systemctl reboot" \ No newline at end of file diff --git a/butane/k8s-leader-install.yaml b/butane/k8s-leader-install.yaml index 5d72107..2eee2f5 100644 --- a/butane/k8s-leader-install.yaml +++ b/butane/k8s-leader-install.yaml @@ -21,7 +21,7 @@ systemd: Type=forking TimeoutStartSec=600 RemainAfterExit=yes - ExecStart=/usr/bin/sh -c "flatcar-install -d /dev/vda -i /opt/ignition.json && udevadm settle && systemctl reboot" + ExecStart=/usr/bin/sh -c "/opt/ckube-install" [Install] WantedBy=multi-user.target storage: @@ -29,4 +29,8 @@ storage: - path: /opt/ignition.json mode: 0700 contents: - source: http://192.168.40.3/leader.json \ No newline at end of file + source: http://192.168.40.3/leader.json + - path: /opt/ckube-install + mode: 0700 + contents: + source: http://192.168.40.3/ckube-install \ No newline at end of file diff --git a/ipxe/tftpboot/menu.ipxe b/ipxe/tftpboot/menu.ipxe index 93d33c9..49b3431 100644 --- a/ipxe/tftpboot/menu.ipxe +++ b/ipxe/tftpboot/menu.ipxe @@ -1,11 +1,23 @@ #!ipxe +set ignition-server 192.168.40.3 +#set base-url http://${ignition-server}/flatcar +set base-url http://stable.release.flatcar-linux.net/amd64-usr/current +set vm-install-target /dev/vda + :start menu Cadoles PXE Boot Options +item gap1 -------------------- CadolesKube -------------------- +item klead Run Leader (RAM) +item kmaster Run Master (RAM) +item knode Run Node (RAM) +item gap2 ----------------------------------------------------- +item iklead Install Leader (VM) +item ikmaster Install Master (VM) +item iknode Install Node (VM) +item gap2 ----------------------------------------------------- item shell iPXE shell -item klead CadolesKube Leader -item kmaster CadolesKube Master -item knode CadolesKube Node +item gap3 ----------------------------------------------------- item exit Exit to BIOS choose --default exit --timeout 10000 option && goto ${option} @@ -14,25 +26,44 @@ choose --default exit --timeout 10000 option && goto ${option} shell :klead -set base-url http://stable.release.flatcar-linux.net/amd64-usr/current -set ignition-url http://192.168.10.177:8001/leader.json +set ignition-url http://${ignition-server}/leader.json kernel ${base-url}/flatcar_production_pxe.vmlinuz initrd=flatcar_production_pxe_image.cpio.gz flatcar.first_boot=1 ignition.config.url=${ignition-url} initrd ${base-url}/flatcar_production_pxe_image.cpio.gz boot :kmaster -set base-url http://stable.release.flatcar-linux.net/amd64-usr/current -set ignition-url http://192.168.10.177:8001/master.json +set ignition-url http://${ignition-server}/leader.json kernel ${base-url}/flatcar_production_pxe.vmlinuz initrd=flatcar_production_pxe_image.cpio.gz flatcar.first_boot=1 ignition.config.url=${ignition-url} initrd ${base-url}/flatcar_production_pxe_image.cpio.gz :knode -set base-url http://stable.release.flatcar-linux.net/amd64-usr/current -set ignition-url http://192.168.10.177:8001/worker.json +set ignition-url http://${ignition-server}/leader.json kernel ${base-url}/flatcar_production_pxe.vmlinuz initrd=flatcar_production_pxe_image.cpio.gz flatcar.first_boot=1 ignition.config.url=${ignition-url} initrd ${base-url}/flatcar_production_pxe_image.cpio.gz + +:iklead +set ignition-url http://${ignition-server}/leader-install.json + +kernel ${base-url}/flatcar_production_pxe.vmlinuz initrd=flatcar_production_pxe_image.cpio.gz flatcar.first_boot=1 flatcar.target=${vm-install-target} ignition.config.url=${ignition-url} +initrd ${base-url}/flatcar_production_pxe_image.cpio.gz +boot + +:iknode +set ignition-url http://${ignition-server}/leader.json + +kernel ${base-url}/flatcar_production_pxe.vmlinuz initrd=flatcar_production_pxe_image.cpio.gz flatcar.first_boot=1 flatcar.target=${vm-install-target} ignition.config.url=${ignition-url} +initrd ${base-url}/flatcar_production_pxe_image.cpio.gz +boot + +:iknode +set ignition-url http://${ignition-server}/leader.json + +kernel ${base-url}/flatcar_production_pxe.vmlinuz initrd=flatcar_production_pxe_image.cpio.gz flatcar.first_boot=1 flatcar.target=${vm-install-target} ignition.config.url=${ignition-url} +initrd ${base-url}/flatcar_production_pxe_image.cpio.gz +boot + :exit -exit +exit \ No newline at end of file