Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Two node edge clusters #70

Closed
wants to merge 67 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
6143c81
use custom k3s provider; add marmot & sqlite
TylerGillson Oct 4, 2023
b8c1312
fix marmot install
TylerGillson Oct 4, 2023
6322198
fix marmot install; add less
TylerGillson Oct 5, 2023
30dd861
revert Dockerfile, move two node packages into Earthfile
TylerGillson Oct 6, 2023
b9e32c3
revert Dockerfile
TylerGillson Oct 6, 2023
18c401b
Fix bug in earthfile
oz123 Oct 9, 2023
e73955c
revert kairos-provider-image change
TylerGillson Oct 11, 2023
7042cc4
Parametrize marmot version
oz123 Oct 12, 2023
be2c1f4
Don't install less (there is already more in the image)
oz123 Oct 12, 2023
bcacb79
Add marmot installation to opensuse-leap
oz123 Oct 12, 2023
7b41a6c
DRY single curl block to download marmot
oz123 Oct 13, 2023
a18f456
PAD-156: Add custom health check script
oz123 Oct 18, 2023
221a477
PAD-156: Update user-data template, include health-check-script
oz123 Oct 18, 2023
2fec909
chore: use patched marmot binary
TylerGillson Oct 19, 2023
4187d98
install ping for two node
TylerGillson Oct 26, 2023
54ef5b6
Merge branch 'main' into two-node
TylerGillson Oct 30, 2023
7e3f355
Add E2E automation, debug helpers (#94)
TylerGillson Nov 6, 2023
5efa2fe
chore: use 0.8.7-beta.1 marmot release
TylerGillson Nov 7, 2023
b22e102
fix: increase EARTHLY_BUILDKIT_CACHE_SIZE_MB & upgrade PE version
TylerGillson Nov 7, 2023
1cab1e7
docs: fix debug README
TylerGillson Nov 7, 2023
96558cd
Update README.md
TylerGillson Nov 8, 2023
e499803
fix: specify liveness backend, bump earthly cache, eject both ISOs
TylerGillson Nov 13, 2023
0a5c09b
Add kine to the base installation (#98)
oz123 Nov 28, 2023
f979835
Add option to specify the two node backend
oz123 Dec 20, 2023
6bc814b
Add postgresql (#111)
oz123 Dec 20, 2023
bc244a3
DRY configuration of postgresql (#112)
oz123 Dec 20, 2023
5965f79
Parameterize build branches (#113)
oz123 Dec 22, 2023
09d9162
Correct the two node variable name
oz123 Dec 22, 2023
c1cf44e
Explicitly pass TWO_NODE_BACKEND to earthly
oz123 Dec 22, 2023
3ae3327
Correct the variable name passed to userdata
oz123 Dec 22, 2023
9930d98
fix sourcing of test-two-node.sh
TylerGillson Dec 22, 2023
086b9e9
Fix perl path so psql works in CanvOS
oz123 Dec 22, 2023
295a395
Don't exit from function, instead use return
oz123 Dec 22, 2023
525e2ac
Add missing kine version
oz123 Dec 24, 2023
824d72c
Merge branch 'main' into two-node
TylerGillson Jan 4, 2024
92f463e
chore: tidy Dockerfile examples
TylerGillson Jan 4, 2024
4432f00
fix: configure postgres conditionally; tidy Earthfile
TylerGillson Jan 4, 2024
e997f22
Add external datastore to default k3s config
oz123 Jan 8, 2024
5ab6bfc
Fix format of cluster create
oz123 Jan 8, 2024
e479c83
Parameterize CE_VERSION
oz123 Jan 10, 2024
dc6bf12
fix: parameterize k3s & PE versions
TylerGillson Jan 10, 2024
a9fface
fix: add two-node provider option; tidy
TylerGillson Jan 10, 2024
a98809a
chore: add master-master template
TylerGillson Jan 11, 2024
98418b5
Update env.example
TylerGillson Jan 11, 2024
3f37db0
Add stylus hash to machine and cluster names
oz123 Jan 12, 2024
062ca38
fix: align edge host names w/ cluster template
TylerGillson Jan 15, 2024
7115c36
chore: update master-master template
TylerGillson Jan 15, 2024
27d8d17
chore: remove sqlite support
TylerGillson Jan 15, 2024
07d5716
chore: use node-role, not two-node
TylerGillson Jan 15, 2024
092b6e8
chore: switch to master-master, remove userdata customization
TylerGillson Jan 16, 2024
944f5cd
fix: include edge host names
TylerGillson Jan 18, 2024
6fe1bd8
fix typo
TylerGillson Jan 18, 2024
69b57d2
tidy
TylerGillson Jan 20, 2024
40c900c
feat: remove backend flag; configure pg log rotation
TylerGillson Jan 22, 2024
fd0ba50
add host replacement var, update template
TylerGillson Jan 23, 2024
47e0181
upgrade k3s & kine; parameterize k3s version
TylerGillson Jan 23, 2024
45b831b
fix: finish parameterizing k3s version
TylerGillson Jan 23, 2024
968d3b0
bump kine as releases are missing amd64 build for 0.11.0
TylerGillson Jan 23, 2024
166e24b
remove --pod-eviction-timeout
TylerGillson Jan 23, 2024
9cf8e16
revert k3s & kine versions; update templates for k3s 1.28.x
TylerGillson Jan 24, 2024
17b84af
move pg_data dir into COS_PERSISTENT
TylerGillson Jan 25, 2024
e218b83
move rsync to stylus
TylerGillson Jan 26, 2024
124548e
fix REPLACEMENT_HOST logic
TylerGillson Jan 26, 2024
5dc914a
move pg config to stylus
TylerGillson Jan 27, 2024
8599efc
add prepare_cluster_update
TylerGillson Jan 27, 2024
44a3c1b
add SUFFIX_OVERRIDE; fix vm_array
TylerGillson Jan 30, 2024
41fdc7f
chore: fix instructions & default K3S_VERSION; make function detectio…
TylerGillson Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ config.yaml
content-*/*
*.arg
.idea

.DS_Store
hack/*.img
.DS_Store
test/.env
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ RUN if [ "${OS_DISTRIBUTION}" = "opensuse-leap" ] && [ "${PROXY_CERT_PATH}" != "
update-ca-certificates; \
fi

###########################Add any other image customizations here #######################
########################### Add any other image customizations here #######################

#### Examples ####

### To install the nginx package for Ubuntu ###

# RUN apt-get update && apt-get install nginx -y
### or

### To install the nginx package for opensuse ###

# RUN zypper refresh && zypper install nginx -y

### To add a custom health script for two-node liveness checks ###

# ADD overlay/files/opt/spectrocloud/bin/check-disk-size.sh /opt/spectrocloud/bin/
74 changes: 49 additions & 25 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ ARG https_proxy=${HTTPS_PROXY}
ARG no_proxy=${NO_PROXY}
ARG PROXY_CERT_PATH
ARG UPDATE_KERNEL=false

ARG TWO_NODE=false
ARG KINE_VERSION=0.10.3
ARG ETCD_VERSION="v3.5.5"

IF [ "$OS_DISTRIBUTION" = "ubuntu" ] && [ "$BASE_IMAGE" = "" ]
Expand Down Expand Up @@ -73,20 +74,18 @@ build-all-images:
END

build-provider-images:
BUILD +provider-image --K8S_VERSION=1.24.6
BUILD +provider-image --K8S_VERSION=1.25.2
BUILD +provider-image --K8S_VERSION=1.26.4
BUILD +provider-image --K8S_VERSION=1.27.2
BUILD +provider-image --K8S_VERSION=1.25.13
BUILD +provider-image --K8S_VERSION=1.26.8
BUILD +provider-image --K8S_VERSION=1.27.5
BUILD +provider-image --K8S_VERSION=1.27.7
BUILD +provider-image --K8S_VERSION=1.26.10
BUILD +provider-image --K8S_VERSION=1.25.15
# BUILD +provider-image --K8S_VERSION=1.24.6
# BUILD +provider-image --K8S_VERSION=1.25.2
# BUILD +provider-image --K8S_VERSION=1.26.4
# BUILD +provider-image --K8S_VERSION=1.27.2
# BUILD +provider-image --K8S_VERSION=1.25.13
# BUILD +provider-image --K8S_VERSION=1.26.8
# BUILD +provider-image --K8S_VERSION=1.27.5
# BUILD +provider-image --K8S_VERSION=1.27.7
# BUILD +provider-image --K8S_VERSION=1.26.10
# BUILD +provider-image --K8S_VERSION=1.25.15
BUILD +provider-image --K8S_VERSION=1.28.2



build-provider-images-fips:
IF [ "$K8S_DISTRIBUTION" = "kubeadm-fips" ]
BUILD +provider-image --K8S_VERSION=1.24.13
Expand Down Expand Up @@ -247,6 +246,7 @@ base-image:
ARG BASE_K8S_VERSION=$K8S_VERSION-$K8S_DISTRIBUTION_TAG
END

# OS == Ubuntu
IF [ "$OS_DISTRIBUTION" = "ubuntu" ] && [ "$ARCH" = "amd64" ]
# Add proxy certificate if present
IF [ ! -z $PROXY_CERT_PATH ]
Expand Down Expand Up @@ -275,30 +275,46 @@ base-image:

RUN rm -rf /var/cache/* && \
apt clean

IF $TWO_NODE
RUN apt install -y apt-transport-https ca-certificates curl && \
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
curl -fsSL -o postgresql.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc && \
gpg --batch --yes --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg postgresql.asc && \
rm postgresql.asc && \
apt update && \
apt install -y postgresql-16 postgresql-contrib-16 iputils-ping
END

# IF OS Type is Opensuse
# OS == Opensuse
ELSE IF [ "$OS_DISTRIBUTION" = "opensuse-leap" ] && [ "$ARCH" = "amd64" ]
# Add proxy certificate if present
IF [ ! -z $PROXY_CERT_PATH ]
COPY sc.crt /usr/share/pki/trust/anchors
RUN update-ca-certificates
RUN update-ca-certificates
END

IF [ "$UPDATE_KERNEL" = "false" ]
RUN zypper al kernel-de*
END

RUN zypper refresh && \
zypper update -y

IF [ -e "/usr/bin/dracut" ]
RUN --no-cache kernel=$(ls /lib/modules | tail -n1) && depmod -a "${kernel}"
RUN --no-cache kernel=$(ls /lib/modules | tail -n1) && dracut -f "/boot/initrd-${kernel}" "${kernel}" && ln -sf "initrd-${kernel}" /boot/initrd
END
# zypper up kernel-default && \
# zypper purge-kernels && \
RUN zypper install -y zstd vim iputils bridge-utils curl ethtool tcpdump
RUN zypper cc && \
zypper update -y

IF [ -e "/usr/bin/dracut" ]
RUN --no-cache kernel=$(ls /lib/modules | tail -n1) && depmod -a "${kernel}"
RUN --no-cache kernel=$(ls /lib/modules | tail -n1) && dracut -f "/boot/initrd-${kernel}" "${kernel}" && ln -sf "initrd-${kernel}" /boot/initrd
END
# zypper up kernel-default && \
# zypper purge-kernels && \

IF $TWO_NODE
RUN zypper --non-interactive --quiet addrepo --refresh -p 90 http://download.opensuse.org/repositories/server:database:postgresql/openSUSE_Tumbleweed/ PostgreSQL && \
zypper --gpg-auto-import-keys ref && \
zypper install -y postgresql-16 postgresql-server-16 postgresql-contrib iputils
END
RUN zypper install -y zstd vim iputils bridge-utils curl ethtool tcpdump && \
zypper cc && \
zypper clean
END

Expand Down Expand Up @@ -337,6 +353,14 @@ base-image:
RUN if grep "security=selinux" /etc/cos/bootargs.cfg > /dev/null; then sed -i 's/security=selinux //g' /etc/cos/bootargs.cfg; fi &&\
if grep "selinux=1" /etc/cos/bootargs.cfg > /dev/null; then sed -i 's/selinux=1/selinux=0/g' /etc/cos/bootargs.cfg; fi

IF $TWO_NODE
RUN mkdir -p /opt/spectrocloud/bin && \
curl -L https://github.com/k3s-io/kine/releases/download/v${KINE_VERSION}/kine-amd64 | install -m 755 /dev/stdin /opt/spectrocloud/bin/kine

# ensure psql works ootb for the postgres user
RUN su postgres -c 'echo "export PERL5LIB=/usr/share/perl/5.34:/usr/share/perl5:/usr/lib/x86_64-linux-gnu/perl/5.34" > ~/.bash_profile'
END

# Used to build the installer image. The installer ISO will be created from this.
iso-image:
FROM --platform=linux/${ARCH} +base-image
Expand Down
16 changes: 16 additions & 0 deletions hack/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
VERSION 0.6

ARG OSBUILDER_VERSION=v0.7.11
ARG OSBUILDER_IMAGE=quay.io/kairos/osbuilder-tools:$OSBUILDER_VERSION
ARG ISO_NAME=debug

# replace with your CanvOS provider image
ARG PROVIDER_IMAGE=oci:tylergillson/ubuntu:k3s-1.26.4-v4.0.4-071c2c23

build:
FROM $OSBUILDER_IMAGE
WORKDIR /build
COPY . ./

RUN /entrypoint.sh --name $ISO_NAME --debug build-iso --squash-no-compression --date=false $PROVIDER_IMAGE --output /build/
SAVE ARTIFACT /build/$ISO_NAME.iso kairos.iso AS LOCAL build/$ISO_NAME.iso
19 changes: 19 additions & 0 deletions hack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Debugging Kairos

If you're facing hard-to-diagnose issues with your custom provider image, you can use the scripts in this directory to obtain verbose Kairos output.

## Steps
1. Use earthly to generate an ISO from your CanvOS provider image:
```
earthly +build --PROVIDER_IMAGE=<your_provider_image> # e.g., oci:tylergillson/ubuntu:k3s-1.26.4-v4.0.4-071c2c23
```
If successful, `build/debug.iso` will be created.

2. Launch a local VM based on the debug ISO using QEMU and pipe all output to a log file:
```
./launch-qemu.sh build/debug.iso | tee out.log
```

3. Boot the VM in `Kairos (manual)` mode. Once booted, create `userdata.yaml` with your desired Kairos config and execute a manual Kairos installation: `kairos-agent --debug manual-install --device auto userdata.yaml`.

4. The VM should eventually reboot itself once the installation completes. Rather than waiting, execute `reboot` to return to the GRUB menu, select `Palette eXtended Kubernetes Edge` and hit `e` to edit it. Add `rd.debug rd.immucore.debug` to the end of the `linux` line, then hit `CTRL+x` to boot with your edits. You should see verbose Kairos debug logs and they will be persisted to `out.log`.
Empty file added hack/build/.keep
Empty file.
25 changes: 25 additions & 0 deletions hack/launch-qemu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Screenshot capability:
# https://unix.stackexchange.com/a/476617

if [ ! -e disk.img ]; then
qemu-img create -f qcow2 disk.img 60g
fi

# -nic bridge,br=br0,model=virtio-net-pci \
qemu-system-x86_64 \
-enable-kvm \
-cpu "${CPU:=host}" \
-nographic \
-spice port=9000,addr=127.0.0.1,disable-ticketing=yes \
-m ${MEMORY:=10096} \
-smp ${CORES:=5} \
-monitor unix:/tmp/qemu-monitor.sock,server=on,wait=off \
-serial mon:stdio \
-rtc base=utc,clock=rt \
-chardev socket,path=qga.sock,server=on,wait=off,id=qga0 \
-device virtio-serial \
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
-drive if=virtio,media=disk,file=disk.img \
-drive if=ide,media=cdrom,file="${1}"
15 changes: 15 additions & 0 deletions overlay/files/opt/spectrocloud/bin/check-disk-size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

REQUIRED_FREE_DISK=$1

FREE=$(df -h --output=pcent /var/ | tail -n 1 | tr -d '\% ')

if (( $FREE < $REQUIRED_FREE_DISK )); then
echo "Not enough free disk, required: $1. Free: $FREE"
exit 1
fi

echo "Free disk ok, required: $1. Free: $FREE"
exit 0
37 changes: 37 additions & 0 deletions test/env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# govc vars
export GOVC_USERNAME=<YOUR_NAME>@vsphere.local
export GOVC_PASSWORD=<YOUR_VSPHERE_PASSWORD>
export GOVC_URL=10.10.128.10 # IP address of USDC; edit as needed
export GOVC_INSECURE=true
export GOVC_DATACENTER=Datacenter
export GOVC_DATASTORE=vsanDatastore2
export GOVC_NETWORK=VM-NETWORK
export GOVC_RESOURCE_POOL=<YOUR_RESOURCE_POOL>
export GOVC_FOLDER=<YOUR_FOLDER>

# vSphere vars
export HOST_SUFFIX=<YOUR_NAME>-$(git -C ../stylus describe --always) # required to ensure unique edge host IDs
export ISO_FOLDER=<YOUR_FOLDER> e.g. "ISO/01-tyler"
export STYLUS_ISO="${ISO_FOLDER}/stylus-dev-amd64.iso"
export NIC_NAME=ens160

# palette vars
export API_KEY=<YOUR_PALETTE_API_KEY>
export PROJECT_UID=<YOUR_PROJECT_ID>
export EDGE_REGISTRATION_TOKEN=<YOUR_REGISTRATION_TOKEN>
export DOMAIN=dev.spectrocloud.com
export PUBLIC_PACK_REPO_UID=<YOUR_PUBLIC_PACK_REPO_UID> # this varies per Palette tenant, identify via Chrome inspector on Tenant Admin -> Pack Registries page
export CLUSTER_NAME=two-node-<YOUR_NAME>-$(git -C ../stylus describe --always)
export CLUSTER_PROFILE_UID= # if left blank, a cluster profile will be created
export CLUSTER_VIP= # choose an unassigned VIP

# image vars
export EARTHLY_BUILDKIT_CACHE_SIZE_MB=500000
export OCI_REGISTRY=${OCI_REGISTRY:-ttl.sh}
export STYLUS_BRANCH=${STYLUS_BRANCH:-PAD-178-kine-validator}
export PROVIDER_K3S_BRANCH=${PROVIDER_K3S_BRANCH:-two-node}
export K3S_VERSION="1.28.2"
export PE_VERSION="4.1.2"

# two node vars
export TWO_NODE_BACKEND=postgres
Loading