forked from konflux-ci/konflux-ci
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy-image-controller.sh
executable file
·61 lines (49 loc) · 1.46 KB
/
deploy-image-controller.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
#!/bin/bash -e
script_path="$(dirname -- "${BASH_SOURCE[0]}")"
main() {
local token="${1:?A token for quay should be provided}"
local org=${2:?Quay organization name should be provided}
deploy
create_secret "$token" "$org"
wait
}
deploy() {
echo "Deploying Image-Controller" >&2
kubectl apply -k "${script_path}/konflux-ci/image-controller"
}
create_secret() {
local token="${1:?A token for quay should be provided}"
local org=${2:?Quay organization name should be provided}
local ns=image-controller
local secret=quaytoken
if kubectl get secret "$secret" -n "$ns" &> /dev/null; then
echo "Image controller quay secret already exists" >&2
return
fi
echo "Creating secret $secret"
kubectl create secret generic "$secret" \
--namespace="$ns" \
--from-literal=quaytoken="$token" \
--from-literal=organization="$org"
}
wait() {
echo "Waiting for Image-Controller to be ready" >&2
retry "kubectl wait --for=condition=Ready --timeout=240s -l control-plane=controller-manager -n image-controller pod" \
"Image-Controller did not become available within the allocated time"
}
retry() {
for _ in {1..3}; do
local ret=0
$1 || ret="$?"
if [[ "$ret" -eq 0 ]]; then
return 0
fi
echo "Retrying"
sleep 3
done
echo "$1": "$2."
return "$ret"
}
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
main "$@"
fi