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

Example of deploying "hello world" with Shipyard #1318

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 0 deletions .example.hello-world.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
nodes: control-plane worker
clusters:
west:
east:
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@

# Generated files
manifest.json

# Shipyard generated and downloaded
.dapper
Dockerfile.dapper
Makefile.shipyard
output/
5 changes: 5 additions & 0 deletions .shipyard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
nodes: control-plane worker
clusters:
cluster1:
cluster2:
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -142,3 +150,31 @@ 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

deploy-example-hello-world: SETTINGS=.example.hello-world.yml
deploy-example-hello-world: build-cmd clusters
./scripts/[email protected]

.PHONY: deploy-example-hello-world

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
SHIPYARD_GOALS = deploy-example-hello-world
include Makefile.shipyard

endif
37 changes: 37 additions & 0 deletions scripts/deploy-example-hello-world.sh
Original file line number Diff line number Diff line change
@@ -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"