-
Notifications
You must be signed in to change notification settings - Fork 33
/
install.sh
executable file
·93 lines (65 loc) · 3.07 KB
/
install.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
# Copyright (C) 2021 Michael Joseph Walsh - All Rights Reserved
# You may use, distribute and modify this code under the
# terms of the the license.
#
# You should have received a copy of the license with
# this file. If not, please email <[email protected]>
set -a
skip_encrypted_variables=true
. ../.env
taiga_protocol="${taiga_protocol,,}"
if [ "${taiga_protocol}" == "https" ]; then
taiga_websocket_protocol="wss"
taiga_entrypoint="websecure"
taiga_tls="true"
else
taiga_websocket_protocol="ws"
taiga_entrypoint="web"
taiga_tls="false"
fi
taiga_secret_key=`pwgen -Bsv1 64`
is_current_context_correct
is_cluster_running
images_into_registry taiga_images
template_file ./templates/taiga-chart-values.yaml.tpl taiga-chart-values.yaml
template_file ./templates/createsuperuser.sh.tpl createsuperuser.sh
notify "Spinning up Taiga..."
helm repo add nemonik https://nemonik.github.io/helm-charts/
helm repo update
helm install taiga nemonik/taiga --namespace ${taiga_namespace} --create-namespace -f taiga-chart-values.yaml
taiga_gateway_pod_name=`kubectl get pods -n taiga -l app.kubernetes.io/component=taiga-gateway -o json | jq -r '.items | .[] | .metadata.name'`
notify "Waiting for pod/${taiga_gateway_pod_name} -n ${taiga_namespace} to become ready..."
kubectl wait --for=condition=Ready pod/${taiga_gateway_pod_name} -n ${taiga_namespace} --timeout 360s
loop=0
while : ; do
if [ $loop -eq 4 ]; then
error "Failed post step."
break
fi
notify "Attempting to pull ${taiga_protocol}://${taiga_fdqn}..."
if curl -sD - -o /dev/null "${taiga_protocol}://${taiga_fdqn}"; then
kubectl run create-super-user --image=${taiga_back_image_name}:${taiga_back_image_tag} -n ${taiga_namespace} --env "RABBITMQ_USER=taiga" --env "RABBITMQ_PASS=taiga" \
--env "CELERY_ENABLED=false" --env "TAIGA_SECRET_KEY=${taiga_secret_key}" --env "POSTGRES_DB=taiga" --env "POSTGRES_USER=taiga" \
--env "POSTGRES_PASSWORD=taiga" --env "POSTGRES_HOST=taiga-db" --env "TAIGA_SITES_DOMAIN=${taiga_fdqn}" --env "TAIGA_SITES_SCHEME=${taiga_protocol}" \
--restart=Never --command -- /bin/bash -c "while true; do sleep 30; done"
kubectl wait --for=condition=Ready pod/create-super-user -n ${taiga_namespace} --timeout 360s
kubectl cp createsuperuser.sh ${taiga_namespace}/create-super-user:/taiga-back/.
notify "Waiting for taiga-db to be listening and the Django migrations of occured..."
kubectl exec -it create-super-user -n ${taiga_namespace} -n ${taiga_namespace} -- /bin/bash -c ' \
apt update && \
apt install netcat expect -y && \
while ! nc -zv taiga-db 5432; do sleep 15; done && \
chmod +x ./createsuperuser.sh && \
echo -n "Attempting to create root user..." && \
until ./createsuperuser.sh &>/dev/null; do sleep 15; echo -n "."; done && \
echo "" && \
echo "Done."'
kubectl delete pod -n ${taiga_namespace} create-super-user --wait=false
notify "Complete post step"
break
else
notify "Taiga not yet reponding to ${taiga_protocol}..."
sleep 30
fi
done