forked from redhatdemocentral/ocp-install-demo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.sh
executable file
·382 lines (337 loc) · 14.2 KB
/
init.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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
#!/bin/sh
DOCKER_MAJOR_VER=17
DOCKER_MINOR_VER=06
OC_MAJOR_VER="v3"
OC_MINOR_VER=7
OC_MINI_VER=9
OCP_VERSION="$OC_MAJOR_VER.$OC_MINOR_VER"
ISO_URL="https://github.com/boot2docker/boot2docker/releases/download/v1.13.1/boot2docker.iso"
ISO_CACHE="file://$HOME/.docker/machine/cache/boot2docker.iso"
VIRT_DRIVER="xhyve"
VIRT_MEM="memory-size"
STREAM_JBOSS="https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v3.7/xpaas-streams/jboss-image-streams.json"
STREAM_FUSE="https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v3.7/xpaas-streams/fis-image-streams.json"
STREAM_RHEL="https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v3.7/image-streams/image-streams-rhel7.json"
STREAM_DOTNET="https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v3.7/image-streams/dotnet_imagestreams.json"
TEMPLATE_EAP="https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v3.7/xpaas-templates/eap70-basic-s2i.json"
TEMPLATE_BRMS_63="https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v3.6/xpaas-templates/decisionserver63-basic-s2i.json"
TEMPLATE_BRMS_64="https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v3.7/xpaas-templates/decisionserver64-basic-s2i.json"
# uncomment amount memory needed, sets RAM usage limit for OCP, default 6 GB.
#VM_MEMORY=10240 # 10GB
#VM_MEMORY=8192 # 8GB
VM_MEMORY=6144 # 6GB
#VM_MEMORY=3072 # 3GB
# wipe screen.
clear
echo
echo "##############################################################"
echo "## ##"
echo "## Setting up your very own ##"
echo "## ##"
echo "## ### #### ##### # # #### # # ##### ##### ##### ##"
echo "## # # # # # ## # # # # # # # ##"
echo "## # # #### ### # # # ### ##### # #### # ##"
echo "## # # # # # ## # # # # # # ##"
echo "## ### # ##### # # #### # # ##### # # ##"
echo "## ##"
echo "## #### ### # # ##### ### ##### # # ##### ##### ##"
echo "## # # # ## # # # # # ## # # # # ##"
echo "## # # # # # # # ##### # # # # ### ##### ##"
echo "## # # # # ## # # # # # ## # # # ##"
echo "## #### ### # # # # # ##### # # ##### # # ##"
echo "## ##"
echo "## #### # ### ##### ##### ### ##### # # ##"
echo "## # # # # # # # # # # # ## ## ##"
echo "## #### # ##### # #### # # ##### # # # ##"
echo "## # # # # # # # # # # # # ##"
echo "## # ##### # # # # ### # # # # ##"
echo "## ##"
echo "## https://github.com/redhatdemocentral/ocp-install-demo ##"
echo "## ##"
echo "##############################################################"
echo
# Ensure VirtualBox available.
#
if [ `uname` == 'Darwin' ]; then
command -v xhyve -v >/dev/null 2>&1 || { echo >&2 "OSX driver xhyve is required but not installed yet... use 'brew install xhyve' to install"; exit 1; }
echo "Xhyve is installed..."
echo
elif [ `uname` == 'Linux' ]; then
VIRT_DRIVER='kvm'
VIRT_MEM='memory'
echo "You are running on Linux."
echo "This script assumes you are going to use KVM on Linux."
echo "You'll need to install docker-machine and docker-machine-driver-kvm in your \$PATH manually."
echo "Download them from https://github.com/docker/machine/releases and https://github.com/dhiltgen/docker-machine-kvm/releases, respectively."
elif [ `uname` == 'Darwin' ]; then
VIRT_DRIVER='virtualbox'
VIRT_MEM='memory'
command -v VirtualBox -h >/dev/null 2>&1 || { echo >&2 "VirtualBox is required but not installed yet... download here: https://www.virtualbox.org/wiki/Downloads"; exit 1; }
echo "VirtualBox is installed..."
echo
fi
# Ensure OpenShift command line tools available.
#
command -v oc help >/dev/null 2>&1 || { echo >&2 "OpenShift CLI tooling is required but not installed yet... download $OCP_VERSION here: https://access.redhat.com/downloads/content/290"; exit 1; }
echo "OpenShift command line tools installed... checking for valid version..."
echo
# Check oc version.
verfull=$(oc version | awk '/oc/{print $2}')
verone=$(echo $verfull | awk -F[=.] '{print $1}')
vertwo=$(echo $verfull | awk -F[=.] '{print $2}')
verthree=$(echo $verfull | awk -F[=.] '{print $3}')
# Check version elements, first is a string so using '==', the rest are integers.
if [ $verone == $OC_MAJOR_VER ] && [ $vertwo -eq $OC_MINOR_VER ] && [ $verthree -ge $OC_MINI_VER ]; then
echo "Version of installed OpenShift command line tools correct... $verone.$vertwo.$verthree"
echo
else
echo "Version of installed OpenShift command line tools is $verone.$vertwo.$verthree, must be $OC_MAJOR_VER.$OC_MINOR_VER.$OC_MINI_VER..."
echo
if [ `uname` == 'Darwin' ]; then
echo "Download for Mac here: https://access.redhat.com/downloads/content/290"
exit
else
echo "Download for Linux here: https://access.redhat.com/downloads/content/290/"
exit
fi
fi
echo "Setting up OpenShift docker machine using $VIRT_DRIVER..."
echo
docker-machine create --driver ${VIRT_DRIVER} --${VIRT_DRIVER}-cpu-count "2" --${VIRT_DRIVER}-${VIRT_MEM} "$VM_MEMORY" --engine-insecure-registry 172.30.0.0/16 --${VIRT_DRIVER}-boot2docker-url $ISO_CACHE openshift
if [ $? -ne 0 ]; then
echo
echo "Error occurred during openshift docker machine creation..."
echo
echo "Cleaning out existing 'openshift' machine..."
echo
docker-machine rm -f openshift
echo "Setting up OpenShift docker machine using $VIRT_DRIVER..."
echo
docker-machine create --driver ${VIRT_DRIVER} --${VIRT_DRIVER}-cpu-count "2" --${VIRT_DRIVER}-${VIRT_MEM} "$VM_MEMORY" --engine-insecure-registry 172.30.0.0/16 --${VIRT_DRIVER}-boot2docker-url $ISO_CACHE openshift
if [ $? -ne 0 ]; then
echo
echo "Problem with docker machine creation that I can't resolve, please raise an issue and add error output:"
echo
echo " https://github.com/redhatdemocentral/ocp-install-demo/issues/new"
echo
exit
fi
fi
echo "Installing OCP with cluster up..."
echo
oc cluster up --image=registry.access.redhat.com/openshift3/ose --host-data-dir=/var/lib/boot2docker/ocp-data --docker-machine=openshift --host-config-dir=/var/lib/boot2docker/ocp-config --use-existing-config=true --version=$OCP_VERSION --host-pv-dir=/var/lib/boot2docker/ocp-pv
if [ $? -ne 0 ]; then
echo
echo "Error occurred during 'oc cluster up' command..."
echo
echo "Cleaning out existing 'openshift' machine..."
echo
docker-machine rm -f openshift
echo "Setting up OpenShift docker machine using $VIRT_DRIVER..."
echo
docker-machine create --driver ${VIRT_DRIVER} --${VIRT_DRIVER}-cpu-count "2" --${VIRT_DRIVER}-${VIRT_MEM} "$VM_MEMORY" --engine-insecure-registry 172.30.0.0/16 --${VIRT_DRIVER}-boot2docker-url $ISO_CACHE openshift
echo
echo "Trying again to install OCP with cluster up..."
echo
echo "Using osX version of cluster up... installing second try OCP version: $OCP_VERSION"
echo
oc cluster up --image=registry.access.redhat.com/openshift3/ose --host-data-dir=/var/lib/boot2docker/ocp-data --docker-machine=openshift --host-config-dir=/var/lib/boot2docker/ocp-config --use-existing-config=true --version=$OCP_VERSION --host-pv-dir=/var/lib/boot2docker/ocp-pv
if [ $? -ne 0 ]; then
echo
echo "Problem with installation that I can't resolve, please raise an issue and add error output:"
echo
echo " https://github.com/redhatdemocentral/ocp-install-demo/issues/new"
echo
exit
fi
fi
echo
echo "Logging in as admin user..."
echo
oc login -u system:admin
# capturing OCP IP address from status command.
OCP_IP=$(oc status | awk '/My Project/{print $8}')
echo
echo "Set OCP IP to $OCP_IP..."
echo
# set console environment to openshift container.
eval "$(docker-machine env openshift)"
echo "Granting admin user full cluster-admin rights..."
echo
oc adm policy add-cluster-role-to-user cluster-admin admin
if [ $? -ne 0 ]; then
echo
echo "Problem granting admin user full cluster-admin rights!"
echo
exit
fi
echo
echo "Granting rights to service catalog access..."
echo
oc adm policy add-cluster-role-to-group system:openshift:templateservicebroker-client system:unauthenticated system:authenticated
if [ $? -ne 0 ]; then
echo
echo "Problem granting service catalog rights!"
echo
exit
fi
echo
echo "Updating JBoss image streams..."
echo
oc delete -n openshift -f $STREAM_JBOSS >/dev/null 2>&1
oc create -n openshift -f $STREAM_JBOSS
if [ $? -ne 0 ]; then
echo
echo "Problem with accessing JBoss product streams for OCP..."
echo
echo "Trying again..."
echo
sleep 10
oc delete -n openshift -f $STREAM_JBOSS >/dev/null 2>&1
oc create -n openshift -f $STREAM_JBOSS
if [ $? -ne 0 ]; then
echo "Failed again, exiting, check output messages and network connectivity before running install again..."
echo
docker-machine rm -f openshift
exit
fi
fi
echo
echo "Updating Fuse image streams..."
echo
oc delete -n openshift -f $STREAM_FUSE >/dev/null 2>&1
oc create -n openshift -f $STREAM_FUSE
if [ $? -ne 0 ]; then
echo
echo "Problem with accessing Fuse Integration product streams for OCP..."
echo
echo "Trying again..."
echo
sleep 10
oc delete -n openshift -f $STREAM_FUSE >/dev/null 2>&1
oc create -n openshift -f $STREAM_FUSE
if [ $? -ne 0 ]; then
echo "Failed again, exiting, check output messages and network connectivity before running install again..."
echo
docker-machine rm -f openshift
exit
fi
fi
echo
echo "Updating EAP templates..."
echo
oc delete -n openshift -f $TEMPLATE_EAP >/dev/null 2>&1
oc create -n openshift -f $TEMPLATE_EAP
if [ $? -ne 0 ]; then
echo
echo "Problem with accessing JBoss EAP product streams for OCP..."
echo
echo "Trying again..."
echo
sleep 10
oc delete -n openshift -f $TEMPLATE_EAP >/dev/null 2>&1
oc create -n openshift -f $TEMPLATE_EAP
if [ $? -ne 0 ]; then
echo "Failed again, exiting, check output messages and network connectivity before running install again..."
echo
docker-machine rm -f openshift
exit
fi
fi
echo
echo "Updating Decision Server templates..."
echo
oc delete -n openshift -f $TEMPLATE_BRMS_63 >/dev/null 2>&1
oc delete -n openshift -f $TEMPLATE_BRMS_64 >/dev/null 2>&1
oc create -n openshift -f $TEMPLATE_BRMS_63
oc create -n openshift -f $TEMPLATE_BRMS_64
if [ $? -ne 0 ]; then
echo
echo "Problem with accessing JBoss BRMS product streams for OCP..."
echo
echo "Trying again..."
echo
sleep 10
oc delete -n openshift -f $TEMPLATE_BRMS_63 >/dev/null 2>&1
oc delete -n openshift -f $TEMPLATE_BRMS_64 >/dev/null 2>&1
oc create -n openshift -f $TEMPLATE_BRMS_63
oc create -n openshift -f $TEMPLATE_BRMS_64
if [ $? -ne 0 ]; then
echo "Failed again, exiting, check output messages and network connectivity before running install again..."
echo
docker-machine rm -f openshift
exit
fi
fi
echo
echo "Updating RHEL 7 image streams..."
echo
oc delete -n openshift -f $STREAM_RHEL >/dev/null 2>&1
oc create -n openshift -f $STREAM_RHEL
if [ $? -ne 0 ]; then
echo
echo "Problem with accessing RHEL product streams for OCP..."
echo
echo "Trying again..."
echo
sleep 10
oc delete -n openshift -f $STREAM_RHEL >/dev/null 2>&1
oc create -n openshift -f $STREAM_RHEL
if [ $? -ne 0 ]; then
echo "Failed again, exiting, check output messages and network connectivity before running install again..."
echo
docker-machine rm -f openshift
exit
fi
fi
echo
echo "Update .Net image streams..."
echo
oc delete -n openshift -f $STREAM_DOTNET >/dev/null 2>&1
oc create -n openshift -f $STREAM_DOTNET
if [ $? -ne 0 ]; then
echo
echo "Problem with accessing .Net image streams for OCP..."
echo
echo "Trying again..."
echo
sleep 10
oc delete -n openshift -f $STREAM_DOTNET >/dev/null 2>&1
oc create -n openshift -f $STREAM_DOTNET
if [ $? -ne 0 ]; then
echo "Failed again, exiting, check output messages and network connectivity before running install again..."
echo
docker-machine rm -f openshift
exit
fi
fi
echo
echo "===================================================="
echo "= ="
echo "= Install complete, get ready to rock your Cloud. ="
echo "= Look for information at end of OCP install. ="
echo "= ="
echo "= The server is accessible via web console at: ="
echo "= ="
echo "= $OCP_IP ="
echo "= ="
echo "= Log in as user: openshift-dev ="
echo "= password: devel ="
echo "= ="
echo "= Admin log in as: admin ="
echo "= password: admin ="
echo "= ="
echo "= Now get your Red Hat Demo Central example ="
echo "= projects here: ="
echo "= ="
echo "= https://github.com/redhatdemocentral ="
echo "= ="
echo "= To stop and restart your OCP cluster with ="
echo "= installed containers, see Readme.md in the ="
echo "= NOTES section for details. ="
echo "= ="
echo "= When finished, clean up your demo with: ="
echo "= ="
echo "= $ docker-machine rm -f openshift ="
echo "= ="
echo "===================================================="