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

Parameterize build branches #113

Merged
merged 11 commits into from
Dec 22, 2023
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ content-*/*
.idea
hack/*.img
.DS_Store
test/.env
34 changes: 19 additions & 15 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ARG no_proxy=${NO_PROXY}
ARG PROXY_CERT_PATH
ARG UPDATE_KERNEL=false
ARG TWO_NODE=false
# You can use either sqlite or postgres as backend
# You can use either sqlite or postgres
ARG TWO_NODE_BACKEND=sqlite
ARG MARMOT_VERSION=0.8.7-beta.1

Expand All @@ -49,6 +49,17 @@ ELSE IF [ "$OS_DISTRIBUTION" = "rhel" ] || [ "$OS_DISTRIBUTION" = "sles" ]
ARG BASE_IMAGE
END

# Determine PG config dir (only relevant if TWO_NODE=true)
IF [ "$OS_DISTRIBUTION" = "ubuntu" ]
IF [ "$TWO_NODE_BACKEND" = "postgres" ]
ARG PG_CONF_DIR=/etc/postgresql/16/main
END
ELSE IF [ "$OS_DISTRIBUTION" = "opensuse-leap" ]
IF [ "$TWO_NODE_BACKEND" = "postgres" ]
ARG PG_CONF_DIR=/var/lib/pgsql/data
END
END

IF [[ "$BASE_IMAGE" =~ "ubuntu-20-lts-arm-nvidia-jetson-agx-orin" ]]
ARG IS_JETSON=true
END
Expand Down Expand Up @@ -242,15 +253,8 @@ base-image:
RUN mkdir -p /opt/spectrocloud/bin && \
curl -sL https://github.com/maxpert/marmot/releases/download/v"${MARMOT_VERSION}"/marmot-v"${MARMOT_VERSION}"-linux-amd64-static.tar.gz | tar -zxv marmot && \
install marmot -o root -g root -m 755 /opt/spectrocloud/bin/ && \
rm -f marmot \
rm -f marmot && \
curl -sL https://github.com/k3s-io/kine/releases/download/v${KINE_VERSION}/kine-amd64 | install -m 755 /dev/stdin /opt/spectrocloud/bin/kine
IF [ TWO_NODE_BACKEND = "postgres" ]
IF [ $OS_DISTRIBUTION = "ubuntu" ]
ARG PG_CONF_DIR=/etc/postgresql/16/main/
ELSE IF [ $OS_DISTRIBUTION = "opensuse-leap" ]
ARG PG_CONF_DIR=/var/lib/pgsql/data/
END
END
END

IF [ "$OS_DISTRIBUTION" = "ubuntu" ] && [ "$ARCH" = "amd64" ]
Expand Down Expand Up @@ -281,7 +285,7 @@ base-image:
apt clean

IF $TWO_NODE
IF [ $TWO_NODE_BACKEND = "sqlite" ]
IF [ "$TWO_NODE_BACKEND" = "sqlite" ]
RUN apt install -y sqlite3 iputils-ping
ELSE
RUN apt install -y apt-transport-https ca-certificates curl && \
Expand Down Expand Up @@ -360,11 +364,11 @@ base-image:
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 sed -i '/^#wal_level = replica/ s/#wal_level = replica/wal_level = logical/' $PG_CONF_DIR/postgresql.conf && \
sed -i '/^#max_worker_processes = 8/ s/#max_worker_processes = 8/max_worker_processes = 16/' $PG_CONF_DIR/postgresql.conf && \
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" $PG_CONF_DIR/postgresql.conf && \
echo "host all all 0.0.0.0/0 md5" | sudo tee -a PG_CONF_DIR/pg_hba.conf && \
systemctl enable postresql
RUN sed -i '/^#wal_level = replica/ s/#wal_level = replica/wal_level = logical/' "${PG_CONF_DIR}"/postgresql.conf && \
sed -i '/^#max_worker_processes = 8/ s/#max_worker_processes = 8/max_worker_processes = 16/' ${PG_CONF_DIR}/postgresql.conf && \
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" ${PG_CONF_DIR}/postgresql.conf && \
echo "host all all 0.0.0.0/0 md5" | tee -a ${PG_CONF_DIR}/pg_hba.conf && \
systemctl enable postgresql
END

# Used to build the installer image. The installer ISO will be created from this.
Expand Down
35 changes: 35 additions & 0 deletions test/env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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> # 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
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=100000
export OCI_REGISTRY=${OCI_REGISTRY:-ttl.sh}
export STYLUS_BRANCH=${STYLUS_BRANCH:-two-node}
export PROVIDER_K3S_BRANCH=${PROVIDER_K3S_BRANCH:-2-node-health-checks}

# two node vars
export BACKEND=postgres # one of: [ postgres | sqlite ]
52 changes: 12 additions & 40 deletions test/test-two-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,24 @@ set -e
# credentials capable of cloning Spectro Cloud internal repos
# (required for building stylus).
#
# 4. Edit the global variables below as needed.
# 4. Copy the test/env.example file to test/.env and edit test/.env
# as required.
#
# 5. Source and execute this script:
#
# source ./test/test-two-node.sh
# ./test/test-two-node.sh

# Edit these variables

# govc vars
export GOVC_USERNAME=<YOUR_NAME>@vsphere.local
export GOVC_PASSWORD=<YOUR_VSPHERE_PASSWORD>
export GOVC_URL=10.10.128.10
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> # 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
export CLUSTER_NAME=two-node
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=100000
export OCI_REGISTRY=ttl.sh

# cluster vars
export BACKEND=postgres # postgres or sqlite


# Do not edit anything below

envfile=$(dirname $0)/.env
if [ -f ${envfile} ]; then
source ${envfile}
else
echo "Please create a .env file in the test directory and populate it with the required variables."
exit 1
fi

declare -a vm_array=("2n1-$HOST_SUFFIX" "2n2-$HOST_SUFFIX")
export HOST_1="${vm_array[0]}-$HOST_SUFFIX"
export HOST_2="${vm_array[1]}-$HOST_SUFFIX"
Expand Down Expand Up @@ -408,7 +380,7 @@ function build_canvos() {
function build_all() {

# optionally build/rebuild provider-k3s
test -d ../provider-k3s || ( cd .. && git clone https://github.com/kairos-io/provider-k3s -b two-node )
test -d ../provider-k3s || ( cd .. && git clone https://github.com/kairos-io/provider-k3s -b ${PROVIDER_K3S_BRANCH})
cd ../provider-k3s
export PROVIDER_K3S_HASH=$(git describe --always)
(
Expand All @@ -417,7 +389,7 @@ function build_all() {
) || ( build_provider_k3s )

# optionally build/rebuild stylus images
test -d ../stylus || ( cd .. && git clone https://github.com/spectrocloud/stylus -b 2-node-health-checks )
test -d ../stylus || ( cd .. && git clone https://github.com/spectrocloud/stylus -b ${STYLUS_BRANCH} )
cd ../stylus
export STYLUS_HASH=$(git describe --always)
(
Expand Down