-
Notifications
You must be signed in to change notification settings - Fork 175
/
ci-deploy.sh
executable file
·70 lines (55 loc) · 2.58 KB
/
ci-deploy.sh
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
#!/bin/bash
#
# Copyright (C) 2021 ScyllaDB
#
# This script deploys scylla-operator and scylla-manager.
# Usage: ${0} <operator_image_ref>
set -euxEo pipefail
function wait-for-object-creation {
for i in {1..30}; do
{ kubectl -n "${1}" get "${2}" && break; } || sleep 1
done
}
if [[ -z ${1+x} ]]; then
echo "Missing operator image ref.\nUsage: ${0} <operator_image_ref>" >&2 >/dev/null
exit 1
fi
function kubectl_create {
if [[ -z ${REENTRANT+x} ]]; then
# In an actual CI run we have to enforce that no two objects have the same name.
kubectl create "$@"
else
# For development iterations we want to update the objects.
kubectl apply "$@"
fi
}
ARTIFACTS_DIR=${ARTIFACTS_DIR:-$( mktemp -d )}
OPERATOR_IMAGE_REF=${1}
deploy_dir=${ARTIFACTS_DIR}/deploy
mkdir -p "${deploy_dir}/"{operator,manager}
cp ./deploy/manager/dev/*.yaml "${deploy_dir}/manager"
cp ./deploy/operator/*.yaml "${deploy_dir}/operator"
cp ./examples/common/cert-manager.yaml "${deploy_dir}/"
for f in $( find "${deploy_dir}"/ -type f -name '*.yaml' ); do
sed -i -E -e "s~docker.io/scylladb/scylla-operator(:|@sha256:)[^ ]*~${OPERATOR_IMAGE_REF}~" "${f}"
done
kubectl_create -f "${deploy_dir}"/cert-manager.yaml
# Wait for cert-manager
kubectl wait --for condition=established --timeout=60s crd/certificates.cert-manager.io crd/issuers.cert-manager.io
for d in cert-manager{,-cainjector,-webhook}; do
wait-for-object-creation cert-manager deployment.apps/"${d}"
kubectl -n cert-manager rollout status --timeout=5m deployment.apps/"${d}"
done
wait-for-object-creation cert-manager secret/cert-manager-webhook-ca
kubectl_create -f "${deploy_dir}"/operator
# Manager needs scylla CRD registered and the webhook running
kubectl wait --for condition=established crd/scyllaclusters.scylla.scylladb.com
kubectl -n scylla-operator rollout status --timeout=5m deployment.apps/scylla-operator
kubectl -n scylla-operator rollout status --timeout=5m deployment.apps/webhook-server
kubectl_create -f "${deploy_dir}"/manager
wait-for-object-creation scylla-manager statefulset.apps/scylla-manager-cluster-manager-dc-manager-rack
kubectl -n scylla-manager rollout status --timeout=5m statefulset.apps/scylla-manager-cluster-manager-dc-manager-rack
kubectl -n scylla-manager rollout status --timeout=5m deployment.apps/scylla-manager
kubectl -n scylla-manager rollout status --timeout=5m deployment.apps/scylla-manager-controller
kubectl wait --for condition=established crd/nodeconfigs.scylla.scylladb.com
kubectl wait --for condition=established crd/scyllaoperatorconfigs.scylla.scylladb.com