From 029c867f5a7c320e406cefc65814631c026a1937 Mon Sep 17 00:00:00 2001 From: Mike Kolesnik Date: Tue, 12 Dec 2023 16:48:19 +0200 Subject: [PATCH 1/2] Add Shipyard support for deploying clusters This allows to quickly and easily deploy clusters (kind, ocp, acm) for testing. The kind clusters run locally and can be used for development, quick testing and CI. Signed-off-by: Mike Kolesnik --- .gitignore | 6 ++++++ .shipyard.yml | 5 +++++ Makefile | 29 +++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 .shipyard.yml diff --git a/.gitignore b/.gitignore index 825173c29..df7a2b849 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,9 @@ # Generated files manifest.json + +# Shipyard generated and downloaded +.dapper +Dockerfile.dapper +Makefile.shipyard +output/ diff --git a/.shipyard.yml b/.shipyard.yml new file mode 100644 index 000000000..75dde449a --- /dev/null +++ b/.shipyard.yml @@ -0,0 +1,5 @@ +--- +nodes: control-plane worker +clusters: + cluster1: + cluster2: diff --git a/Makefile b/Makefile index 49d0d97ec..53d4f24ea 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,14 @@ PLATFORMS ?= linux/amd64,linux/arm64 GOOS ?= linux GOARCH ?= amd64 +# Shipyard configuration +BASE_BRANCH = main +LOAD_BALANCER = true +ORG = skupperproject +PROJECT = skupper +SETTINGS = ./.shipyard.yml +export BASE_BRANCH ORG PROJECT SHIPYARD_REPO SHIPYARD_URL + all: generate-client build-cmd build-get build-config-sync build-controllers build-tests build-manifest build-tests: @@ -142,3 +150,24 @@ release/arm64/skupper: cmd/skupper/skupper.go release/arm64.tgz: release/arm64/skupper tar -czf release/arm64.tgz release/arm64/skupper + +ifneq (,$(DAPPER_HOST_ARCH)) + +# Running in Shipyard's container + +include $(SHIPYARD_DIR)/Makefile.clusters + +else + +# Not running in Shipyard's container + +Makefile.shipyard: +ifeq (,$(findstring s,$(firstword -$(MAKEFLAGS)))) + @echo Downloading $@ +endif + @curl -sfLO $(SHIPYARD_URL)/$@ + +ONLY_SHIPYARD_GOALS = true +include Makefile.shipyard + +endif From 82cb059781f5b4b4232d9121aedb14a7633cd7e6 Mon Sep 17 00:00:00 2001 From: Mike Kolesnik Date: Wed, 13 Dec 2023 11:05:04 +0200 Subject: [PATCH 2/2] Example of deploying "hello world" with Shipyard This exemplifies how the deployment on top of shipyard would work. This would probably be best put in the example repo itself, but I drafted it to make it clear how using Shipyard looks like. Signed-off-by: Mike Kolesnik --- .example.hello-world.yml | 5 ++++ Makefile | 7 +++++ scripts/deploy-example-hello-world.sh | 37 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 .example.hello-world.yml create mode 100755 scripts/deploy-example-hello-world.sh diff --git a/.example.hello-world.yml b/.example.hello-world.yml new file mode 100644 index 000000000..08f49fe15 --- /dev/null +++ b/.example.hello-world.yml @@ -0,0 +1,5 @@ +--- +nodes: control-plane worker +clusters: + west: + east: diff --git a/Makefile b/Makefile index 53d4f24ea..059959cf7 100644 --- a/Makefile +++ b/Makefile @@ -157,6 +157,12 @@ ifneq (,$(DAPPER_HOST_ARCH)) include $(SHIPYARD_DIR)/Makefile.clusters +deploy-example-hello-world: SETTINGS=.example.hello-world.yml +deploy-example-hello-world: build-cmd clusters + ./scripts/$@.sh + +.PHONY: deploy-example-hello-world + else # Not running in Shipyard's container @@ -168,6 +174,7 @@ endif @curl -sfLO $(SHIPYARD_URL)/$@ ONLY_SHIPYARD_GOALS = true +SHIPYARD_GOALS = deploy-example-hello-world include Makefile.shipyard endif diff --git a/scripts/deploy-example-hello-world.sh b/scripts/deploy-example-hello-world.sh new file mode 100755 index 000000000..dd6a0adbd --- /dev/null +++ b/scripts/deploy-example-hello-world.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -em + +source "${SCRIPTS_DIR}/lib/utils" +source "${SCRIPTS_DIR}/lib/debug_functions" + +print_env SETTINGS +declare_kubeconfig + +on_ctx() { + "$2" --context "$1" "${@:3}" +} + +# Create namespaces +on_ctx west kubectl create namespace west +kubectl config set-context west --namespace west +on_ctx east kubectl create namespace east +kubectl config set-context east --namespace east + +# Initialize and link +on_ctx west ./skupper init --enable-console --enable-flow-collector +on_ctx east ./skupper init +on_ctx west ./skupper token create ${DAPPER_OUTPUT}/secret.token +on_ctx east ./skupper link create ${DAPPER_OUTPUT}/secret.token + +# Deploy and expose services +on_ctx west kubectl create deployment frontend --image quay.io/skupper/hello-world-frontend +on_ctx west kubectl expose deployment/frontend --port 8080 --type LoadBalancer +on_ctx east kubectl create deployment backend --image quay.io/skupper/hello-world-backend --replicas 3 +on_ctx east ./skupper expose deployment/backend --port 8080 + +# Wait for service to become healthy +svc_ip=$(on_ctx west kubectl get service/frontend -o jsonpath={.status.loadBalancer.ingress[0].ip}) +with_retries 30 sleep_on_fail 5s curl "http://${svc_ip}:8080/api/health" + +echo "Success! You can access the web UI at http://${svc_ip}:8080"