This repository was archived by the owner on Jul 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·191 lines (169 loc) · 4.87 KB
/
install.sh
File metadata and controls
executable file
·191 lines (169 loc) · 4.87 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/sh
function install_bluemix_cli() {
#statements
echo "Installing Bluemix cli"
curl -L "https://cli.run.pivotal.io/stable?release=linux64-binary&source=github" | tar -zx
sudo mv cf /usr/local/bin
sudo curl -o /usr/share/bash-completion/completions/cf https://raw.githubusercontent.com/cloudfoundry/cli/master/ci/installers/completion/cf
cf --version
curl -L public.dhe.ibm.com/cloud/bluemix/cli/bluemix-cli/Bluemix_CLI_0.5.1_amd64.tar.gz > Bluemix_CLI.tar.gz
tar -xvf Bluemix_CLI.tar.gz
sudo ./Bluemix_CLI/install_bluemix_cli
}
function install_kubectl() {
bx plugin install container-service -r Bluemix
echo "Installing kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
}
function cluster_setup() {
bx cs workers $CLUSTER_NAME
$(bx cs cluster-config $CLUSTER_NAME | grep export)
kubectl delete --ignore-not-found=true -f gameon-configmap.yaml
kubectl delete pvc -l app=gameon
kubectl delete --ignore-not-found=true -f core
kubectl delete --ignore-not-found=true -f platform
kubectl delete --ignore-not-found=true -f setup.yaml
kuber=$(kubectl get pods -l app=gameon)
while [ ${#kuber} -ne 0 ]
do
sleep 5s
kubectl get pods -l app=gameon
kuber=$(kubectl get pods -l app=gameon)
done
kubectl delete --ignore-not-found=true -f local-volume.yaml
}
function initial_setup() {
IP=$(bx cs workers $CLUSTER_NAME | grep normal | awk '{print $2}' | head -1)
kubectl create -f local-volume.yaml
sleep 5s
sed -i s#PLACEHOLDER_IP#$IP#g gameon-configmap.yaml
kubectl create -f gameon-configmap.yaml
kubectl create -f setup.yaml
echo "Waiting for container to setup"
sleep 45
keystore=$(kubectl logs setup | grep Import | awk '{print $4}')
TRIES=0
while [ "$keystore" != "104" ]
do
echo "Setting up keystore values..."
keystore=$(kubectl logs setup | grep Import | awk '{print $4}')
if [ "$keystore" = "104" ]
then
echo "Setup successfull"
break
fi
if [ $TRIES -eq 40 ]
then
echo "Failed setting up keystore values."
exit 1
fi
TRIES=$((TRIES+1))
sleep 5s
done
}
function create_platform_services() {
kubectl create -f platform
echo "Waiting for pods to setup"
sleep 10s
PODS=$(kubectl get pods | grep Pending)
while [ ${#PODS} -ne 0 ]
do
echo "Some Pods are Pending..."
PODS=$(kubectl get pods | grep Pending)
sleep 5s
done
PODS=$(kubectl get pods | grep ContainerCreating)
while [ ${#PODS} -ne 0 ]
do
echo "Some Pods are not yet Running..."
PODS=$(kubectl get pods | grep ContainerCreating)
sleep 5s
done
echo "Pods for the platform services are now Running."
echo "Waiting for the amalgam8 controlplane to finish setup..."
IP=$(bx cs workers $CLUSTER_NAME | grep normal | awk '{print $2}' | head -1)
TRIES=0
while true
do
code=$(curl -sw '%{http_code}' http://$IP:31200/health -o /dev/null)
if [ "$code" = "200" ]; then
echo "Controller is up"
break
fi
if [ $TRIES -eq 10 ]
then
echo "Failed setting up controlplane."
exit 1
fi
TRIES=$((TRIES+1))
sleep 5s
done
IP=$(bx cs workers $CLUSTER_NAME | grep normal | awk '{print $2}' | head -1)
TRIES=0
while true
do
code=$(curl -sw '%{http_code}' http://$IP:31300/uptime -o /dev/null)
if [ "$code" = "200" ]; then
echo "Registry is up"
break
fi
if [ $TRIES -eq 10 ]
then
echo "Failed setting up controlplane."
exit 1
fi
TRIES=$((TRIES+1))
sleep 5s
done
}
function create_core_services() {
kubectl create -f core
echo "Waiting for pods to setup"
sleep 10s
PODS=$(kubectl get pods | grep Pending)
while [ ${#PODS} -ne 0 ]
do
echo "Some Pods are Pending..."
PODS=$(kubectl get pods | grep Pending)
sleep 5s
done
PODS=$(kubectl get pods | grep ContainerCreating)
while [ ${#PODS} -ne 0 ]
do
echo "Some Pods are not yet Running..."
PODS=$(kubectl get pods | grep ContainerCreating)
sleep 5s
done
echo "Pods for the core services are now Running."
echo "Waiting for core services to finish setting up..."
# kubectl logs $(kubectl get pods | grep proxy | awk '{print $1}') | tail -10
TRIES=0
while true
do
CORE=$(kubectl logs $(kubectl get pods | grep proxy | awk '{print $1}') | grep UP | awk '{print $8}' | xargs | sed -e s/,//g)
if [ "$CORE" = "UP UP UP UP UP" ]
then
kubectl logs $(kubectl get pods | grep proxy | awk '{print $1}') | grep UP
echo "Everything seems to be working fine!"
echo "Travis build has finished. Cleaning up..."
break
fi
if [ $TRIES -eq 60 ]
then
echo "Failed to setup core services."
echo "Printing running services detected by proxy:"
kubectl logs $(kubectl get pods | grep proxy | awk '{print $1}') | grep UP | awk '{print $6}'
exit 1
fi
echo "Waiting for core services to finish setting up..."
sleep 10s
done
}
install_bluemix_cli
install_kubectl
cluster_setup
initial_setup
create_platform_services
create_core_services
cluster_setup