From 533b1be5f311a355126362005d5be5d05b5eb0de Mon Sep 17 00:00:00 2001 From: Raj Chaudhuri Date: Tue, 7 Jun 2022 18:08:28 +0530 Subject: [PATCH] Invoke-Build script and updated documentation --- BUILDING.md | 6 +-- COMPONENTS.md | 2 +- Makefile | 10 ++--- PACKER.md | 14 ++++--- buildscripts/setup-kubernetes.sh | 2 +- buildscripts/stamp-kuttirelease.sh | 13 +++++++ invoke.build.ps1 | 61 ++++++++++++++++++++++++++++++ kutti.step2.pkr.hcl | 12 +++++- 8 files changed, 104 insertions(+), 16 deletions(-) create mode 100644 buildscripts/stamp-kuttirelease.sh create mode 100644 invoke.build.ps1 diff --git a/BUILDING.md b/BUILDING.md index 4cf545b..f116299 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -46,9 +46,9 @@ The following instructions are for manual building of images. For automated buil 25. Use SSH to log on to the installation VM as kuttiadmin. Go to the **kutti-installscripts** directory and run `chmod +x *.sh`. Then, run `ln -v -s -t /usr/local/bin/ /home/kuttiadmin/kutti-installscripts/*.sh`. 26. Run `KUBE_VERSION= ./setup-kubernetes.sh` to install kubernetes with containderd. Currently suppported versions are: -* 1.24\* (The '*' is important) -* 1.23* -* 1.22* +* 1.24 +* 1.23 +* 1.22 27. Verify that kubeadm is installed by running `kubeadm`. Verify the kubectl autocomplete works. diff --git a/COMPONENTS.md b/COMPONENTS.md index c21a010..c0a305a 100644 --- a/COMPONENTS.md +++ b/COMPONENTS.md @@ -1,5 +1,5 @@ # Components - Debian Linux v11.3.0 -- containerd.io v1.6.4-1 +- containerd.io v1.6.6 - kubelet, kubectl, kubeadm (appropriate versions) diff --git a/Makefile b/Makefile index aed6f9f..a5a52e0 100644 --- a/Makefile +++ b/Makefile @@ -25,25 +25,25 @@ usage: output-kutti-base/Virtual\ Machines/box.xml: kutti.step1.pkr.hcl packer build -var "iso-url=$(OS_ISO_PATH)" -var "iso-checksum=$(OS_ISO_CHECKSUM)" $< -output-kutti-hyperv/kutti-hyperv.vhdx: kutti.step2.pkr.hcl output-kutti-base/Virtual\ Machines/box.xml - packer build -var "vm-version=$(VERSION_STRING)" -var "vm-description=$$VM_DESCRIPTION" $< +output-kutti-hyperv/Virtual\ Hard\ Disks/kutti-base.vhdx: kutti.step2.pkr.hcl output-kutti-base/Virtual\ Machines/box.xml + packer build -var "vm-version=$(VERSION_STRING)" -var "kube-version=$KUBE_VERSION" $< .PHONY: step1 step1: output-kutti-base/Virtual\ Machines/box.xml .PHONY: step2 -step2: output-kutti-hyperv/kutti-hyperv.vhdx +step2: output-kutti-hyperv/Virtual\ Hard\ Disks/kutti-base.vhdx .PHONY: all all: step1 step2 .PHONY: clean-step1 clean-step1: - rm -r output-kutti-base/ + rd /s output-kutti-base .PHONY: clean-step2 clean-step2: - rd /s output-kutti-hyperv/ + rd /s output-kutti-hyperv .PHONY: clean clean: clean-step2 clean-step1 \ No newline at end of file diff --git a/PACKER.md b/PACKER.md index bc4584f..57eab5a 100644 --- a/PACKER.md +++ b/PACKER.md @@ -19,9 +19,9 @@ second step can be run multiple times to generate images for different versions 4. Run `packer build kutti.step1.pkr.hcl` to generate an exported VM for a bare OS image. 5. Run `packer -var "kube-version=DESIREDVERSION" kutti.step2.pkr.hcl`. Here, DESIREDVERSION is the kubernetes version, as it is published in the google debian repository for Kubernetes. If you leave out the `-var "kube-version=` part, the script will pick up the latest available Kubernetes version. Currently supported values are: -* 1.24\* (The '*' is important) -* 1.23* -* 1.22* +* 1.24 +* 1.23 +* 1.22 ## Details @@ -52,11 +52,15 @@ The second step is the script `kutti.step.pkr.hcl`. This starts from a VM import * Adds an icon * Exports to the final VHDX. -## Makefile +## Makefile or Invoke-Build script -The steps described above can also be performed via a supplied makefile and GNU make. +The steps described above can be performed via a supplied makefile and GNU make. `make step1` and `make step2` can be used. +They can also be performed via the supplied build script **invoke.build.ps1** and +[Invoke-Build](https://github.com/nightroman/Invoke-Build). You can use +`Invoke-Build step1` and `Invoke-Build step1`. + ## Compressing the .vhdx file The .vhdx file produced by the second step should be renamed to **kutti-\.vhdx**, and then compressed to a file called **kutti-\.vhdx.zip**. **NOTE:** Do not use Windows Explorer to create the .zip file. On Windows, use 7Zip instead. diff --git a/buildscripts/setup-kubernetes.sh b/buildscripts/setup-kubernetes.sh index 5179e0d..49568df 100644 --- a/buildscripts/setup-kubernetes.sh +++ b/buildscripts/setup-kubernetes.sh @@ -67,7 +67,7 @@ if [ "" = "${KUBE_VERSION:-}" ]; then apt-get install -y kubelet kubeadm kubectl else echo "Version $KUBE_VERSION" - apt-get install -y kubelet="$KUBE_VERSION" kubeadm="$KUBE_VERSION" kubectl="$KUBE_VERSION" + apt-get install -y kubelet="$KUBE_VERSION*" kubeadm="$KUBE_VERSION*" kubectl="$KUBE_VERSION*" fi apt-mark hold kubelet kubeadm kubectl echo "Done." diff --git a/buildscripts/stamp-kuttirelease.sh b/buildscripts/stamp-kuttirelease.sh new file mode 100644 index 0000000..63e7f42 --- /dev/null +++ b/buildscripts/stamp-kuttirelease.sh @@ -0,0 +1,13 @@ +#!/bin/sh -eu + +if [ "$(id -ur)" -ne "0" ]; then + echo "$0 can only be run as root. Use sudo." + exit 1 +fi + +cat > /etc/kutti-release <