From 6470815298f5da91b957bc55eaaa6974380dec9e Mon Sep 17 00:00:00 2001 From: Oz Tiram Date: Mon, 23 Oct 2023 16:27:15 +0200 Subject: [PATCH] WIP: automation of cluster launch --- test-two-node.sh | 66 +++++++++++++++---- .../two-node-cluster-profile.json.tmpl | 0 test/two-node-network.xml | 16 +++++ 3 files changed, 70 insertions(+), 12 deletions(-) rename {templates => test/templates}/two-node-cluster-profile.json.tmpl (100%) create mode 100644 test/two-node-network.xml diff --git a/test-two-node.sh b/test-two-node.sh index bc07663f..ae2d1406 100755 --- a/test-two-node.sh +++ b/test-two-node.sh @@ -3,6 +3,41 @@ set -e OCI_REGISTRY=ozspectro +CANVOS_VM_VCPU=${CANVOS_VM_VCPU:-4} +CANVOS_VM_DISK=${CANVOS_VM_DISK:-35} +CANVOS_VM_RAM=${CANVOS_VM_RAM:-8192} +CANVOS_VM_OSINFO=${CANVOS_VM_OSINFO:-ubuntujammy} +CANVOS_VM_CDROM=${CANVOS_VM_CDROM:-build/palette-edge-installer.iso} + +function prepare_user_data_iso(){ + test -f site-user-data.iso && rm -f site-user-data.iso + touch meta-data + mkisofs -output site-user-data.iso -volid cidata \ + -joliet -rock $1 meta-data +} + +function start_machine(){ + local NAME=$1 + local DISK=$2 + virt-install \ + --osinfo ${CANVOS_VM_OSINFO} \ + --name ${NAME} \ + --cdrom ${DISK} \ + --memory ${CANVOS_VM_RAM} \ + --vcpu ${CANVOS_VM_VCPU} \ + --disk size=${CANVOS_VM_DISK} \ + --disk "site-user-data.iso",device=cdrom \ + --virt-type kvm \ + --network two-node + --noautoconsole \ + --import +} + +function prepare_network(){ + if [ $(virsh net-list | grep two-node | awk '{print $2}') != 'active' ]; then + virsh net-define test/two-node-network.xml + fi +} function build_provider_k3s(){ echo "Build provider k3s" @@ -10,16 +45,20 @@ function build_provider_k3s(){ docker push $OCI_REGISTRY/provider-k3s:v0.0.0-${PROVIDER_K3S_HASH} } -function build_stylus_package(){ - echo "Build Stylus" - earthly --push +package --IMAGE_REPOSITORY=${OCI_REGISTRY} +function build_stylus_package_and_framework(){ + echo "Build Stylus image and framework" + earthly --push --allow-privileged +package --IMAGE_REPOSITORY=${OCI_REGISTRY} \ + --platform=linux/amd64 \ + --BASE_IMAGE=quay.io/kairos/core-opensuse-leap:v2.3.2 \ + --IMAGE_REPOSITORY=tylergillson --VERSION=v0.0.0-twonode + docker push $OCI_REGISTRY/stylus-linux-amd64:v0.0.0-${STYLUS_HASH} - docker push $OCI_REGISTRY/stylus-framework-linux-amd64:v0.0.0-${STYLUS_HASH} + docker push $OCI_REGISTRY/stylus-framework-linux-amd64:v0.0.0-twonode } function create_cluster(){ - apiKey="ZWE0OTU2ODhiZTRmN2Y3NTgwMjJmOGUyZDFkNmQ5MzY=" + apiKey="" projectUid="650ab2782df5377f52bb7cc0" domain=tylerdev-spectrocloud.console.spectrocloud.com @@ -35,7 +74,7 @@ function prepare_cluster_profile(){ } function create_cluster_profile(){ - apiKey="ZWE0OTU2ODhiZTRmN2Y3NTgwMjJmOGUyZDFkNmQ5MzY=" + apiKey="" projectUid="650ab2782df5377f52bb7cc0" domain=tylerdev-spectrocloud.console.spectrocloud.com @@ -89,24 +128,25 @@ function main(){ STYLUS_HASH=$(git describe --always) - ( docker image ls --format "{{.Repository}}:{{.Tag}}" | grep -q $OCI_REGISTRY/stylus-linux-amd64:v0.0.0-${STYLUS_HASH} ) || ( build_stylus_package ) + ( docker image ls --format "{{.Repository}}:{{.Tag}}" | grep -q $OCI_REGISTRY/stylus-linux-amd64:v0.0.0-${STYLUS_HASH} ) || ( build_stylus_package_and_framework ) cd ../CanvOS test -f build/pallete-edge-installer-stylus-${STYLUS_HASH}-k3s-${PROVIDER_K3S_HASH}.iso || \ - earthly +build-all-images --ARCH=amd64 \ + ( echo "Build ISO" && \ + earthly +build-all-images --ARCH=amd64 \ --PROVIDER_BASE=${OCI_REGISTRY}/provider-k3s:v0.0.0-${PROVIDER_K3S_HASH} \ --STYLUS_BASE=${OCI_REGISTRY}/stylus-framework-linux-amd64:twonode \ - --ISO_NAME=pallete-edge-installer-stylus-${STYLUS_HASH}-k3s-${PROVIDER_K3S_HASH} \ - --IMAGE_REGISTRY=${OCI_REGISTRY} \ + --ISO_NAME=pallete-edge-installer-stylus-${STYLUS_HASH}-k3s-${PROVIDER_K3S_HASH} \ + --IMAGE_REGISTRY=${OCI_REGISTRY} \ --TWO_NODE=true --CUSTOM_TAG=twonode - + docker push ${OCI_REGISTRY}/ubuntu:k3s-1.27.2-v4.0.4-twonode + ) MACHINE1="1" MACHINE2="2" - create_user_data ${MACHINE1} bash launch-canvos-vm.sh -i build/pallete-edge-installer-stylus-${STYLUS_HASH}-k3s-${PROVIDER_K3S_HASH}.iso \ -u user-data -n ${MACHINE1} @@ -139,3 +179,5 @@ if [[ $sourced == 1 ]]; then else main fi + +# vim: ts=4 sw=4 sts=4 et diff --git a/templates/two-node-cluster-profile.json.tmpl b/test/templates/two-node-cluster-profile.json.tmpl similarity index 100% rename from templates/two-node-cluster-profile.json.tmpl rename to test/templates/two-node-cluster-profile.json.tmpl diff --git a/test/two-node-network.xml b/test/two-node-network.xml new file mode 100644 index 00000000..fa4f4831 --- /dev/null +++ b/test/two-node-network.xml @@ -0,0 +1,16 @@ + + two-node + f3ed49d5-83f5-4e3c-8ede-71615db4f15f + + + + + + + + + + + + +