-
Notifications
You must be signed in to change notification settings - Fork 0
/
start
executable file
·75 lines (60 loc) · 1.43 KB
/
start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
set -e
needed_tools=()
if ! [ -x "$(command -v k3d)" ]; then
needed_tools+=("k3d")
fi
if ! [ -x "$(command -v docker)" ]; then
needed_tools+=("docker")
fi
if ! [ -x "$(command -v kubectl)" ]; then
needed_tools+=("kubectl")
fi
if [ ${#needed_tools[@]} != 0 ]; then
echo "The following tools are missing:"
for item in "${needed_tools[@]}"; do
echo "${item}"
done
exit 1
fi
IMAGE_NAME=duplication-example
function setup_cluster {
k3d cluster create --config k3d.conf.yaml
kubectl config use-context k3d-duplication-example
kubectl create namespace example
}
function build_and_push_image {
local REGISTRY="localhost:15000"
local PROJECT_ROOT=./check-duplication-example
local CURRDIR
CURRDIR=$(pwd)
cd "${PROJECT_ROOT}" || exit 1
./mvnw clean package -DskipTests
cd "${CURRDIR}" || exit 1
local IMAGE="${REGISTRY}/${IMAGE_NAME}:latest"
docker build -f ./check-duplication-example/src/main/docker/Dockerfile.jvm "${PROJECT_ROOT}" -t "${IMAGE}"
docker push "${IMAGE}"
}
function deploy {
kubectl apply -f k8s.conf.yaml
}
function wait_for_rollout {
echo "Waiting for deployment to finish..."
local rolled_out=1
while [ $rolled_out -ne 0 ]; do
sleep 1s
kubectl rollout status deploy/example -n example
rolled_out=$?
done
echo "Deployment finished"
}
########
# MAIN #
########
setup_cluster
build_and_push_image
deploy
wait_for_rollout
echo
echo "=== DONE SETUP ==="
echo