-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathaddons-setup
executable file
·374 lines (326 loc) · 16.2 KB
/
addons-setup
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
#!/usr/bin/env bash
#
# Maintainer: Jorge Morales <jmorales@redhat.com>
#
#
# Functions
. /scripts/base/common_functions
must_run_as_root
load_configuration
osetemplates-setup(){
# Installing templates into OpenShift
if [ -f ${__TESTS_DIR}/addons.osetemplates.wanted ]; then
if [ ! -f ${__TESTS_DIR}/addons.osetemplates.configured ]; then
echo "[INFO] Installing OpenShift templates"
template_list=(
## SCL: Ruby 2, Ruby 2.2, Node.js 0.10, Perl 5.16, Perl 5.20, PHP 5.5, PHP 5.6, Python 3.4, Python 3.3, Python 2.7)
## Databases: Mysql 5.5, Mysql 5.6, PostgreSQL 9.2, PostgreSQL 9.4, Mongodb 2.4, Mongodb 2.6, Jenkins
https://raw.githubusercontent.com/openshift/origin/master/examples/image-streams/image-streams-rhel7.json
)
for template in ${template_list[@]}; do
echo "[INFO] Importing template ${template}"
oc replace -f $template -n openshift >/dev/null
done
touch ${__TESTS_DIR}/addons.osetemplates.configured
fi
rm ${__TESTS_DIR}/addons.osetemplates.wanted
fi
}
xpaastemplates-setup(){
# Installing templates into OpenShift
if [ -f ${__TESTS_DIR}/addons.xpaastemplates.wanted ]; then
if [ ! -f ${__TESTS_DIR}/addons.xpaastemplates.configured ]; then
echo "[INFO] Installing xPaaS templates"
template_list=(
## SCL: Ruby 2, Ruby 2.2, Node.js 0.10, Perl 5.16, Perl 5.20, PHP 5.5, PHP 5.6, Python 3.4, Python 3.3, Python 2.7)
## Databases: Mysql 5.5, Mysql 5.6, PostgreSQL 9.2, PostgreSQL 9.4, Mongodb 2.4, Mongodb 2.6, Jenkins
https://raw.githubusercontent.com/openshift/origin/master/examples/image-streams/image-streams-rhel7.json
## JBoss Image streams(JWS, EAP, JDG, BRMS, AMQ)
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/jboss-image-streams.json
## Fuse Image Streams
https://raw.githubusercontent.com/jboss-fuse/application-templates/master/fis-image-streams.json
# EAP
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-amq-persistent-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-amq-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-basic-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-https-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-mongodb-persistent-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-mongodb-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-mysql-persistent-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-mysql-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-postgresql-persistent-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/eap/eap64-postgresql-s2i.json
# DecisionServer
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/decisionserver/decisionserver62-amq-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/decisionserver/decisionserver62-basic-s2i.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/decisionserver/decisionserver62-https-s2i.json
# Fuse
## No templates. They are created by mvn:io.fabric8.archetypes
# DataGrid
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/datagrid/datagrid65-basic.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/datagrid/datagrid65-https.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/datagrid/datagrid65-mysql-persistent.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/datagrid/datagrid65-mysql.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/datagrid/datagrid65-postgresql-persistent.json
https://raw.githubusercontent.com/jboss-openshift/application-templates/${__OS_XPAAS_TAG}/datagrid/datagrid65-postgresql.json
)
for template in ${template_list[@]}; do
echo "[INFO] Importing template ${template}"
oc create -f $template -n openshift >/dev/null
done
touch ${__TESTS_DIR}/addons.xpaastemplates.configured
fi
rm ${__TESTS_DIR}/addons.xpaastemplates.wanted
fi
}
metrics-setup(){
# Create metrics
if [ -f ${__TESTS_DIR}/addons.metrics.wanted ]; then
if [ ! -f ${__TESTS_DIR}/addons.metrics.configured ]; then
echo "[INFO] Creating and configuring metrics"
oc create -f https://raw.githubusercontent.com/openshift/origin-metrics/master/metrics-deployer-setup.yaml -n openshift-infra
oc adm policy add-role-to-user edit system:serviceaccount:openshift-infra:metrics-deployer -n openshift-infra
oc adm policy add-cluster-role-to-user cluster-reader system:serviceaccount:openshift-infra:heapster -n openshift-infra
oc secrets new metrics-deployer nothing=/dev/null -n openshift-infra
# This file is placed in /scripts in the VM by Vagrant. If you change, adapt the path.
oc process -f /scripts/metrics/metrics.yaml -v HAWKULAR_METRICS_HOSTNAME=hawkular-metrics.${__OS_APPS_DOMAIN} -v USE_PERSISTENT_STORAGE=false -v IMAGE_VERSION=${__VERSION} | oc create -n openshift-infra -f -
# Add metricsPublicURL to master-config
sed -i.orig -e "s/\(.*metricsPublicURL:\).*/\1 https:\/\/hawkular-metrics.${__OS_APPS_DOMAIN}\/hawkular\/metrics/g" ${__MASTER_CONFIG}
systemctl restart origin
# Add capabilities to enable/disable metrics to every authenticated user
oc create -f /scripts/metrics/allinone-metrics-scaler-clusterrole.json
oc adm policy add-role-to-group allinone:metrics-scaler system:authenticated -n openshift-infra
echo "[INFO] Installing disable-metrics script"
chmod 755 /scripts/metrics/disable-metrics
ln -s /scripts/metrics/disable-metrics /usr/local/bin/disable-metrics
echo "[INFO] Installing enable-metrics script"
chmod 755 /scripts/metrics/enable-metrics
ln -s /scripts/metrics/enable-metrics /usr/local/bin/enable-metrics
echo ""
echo "[INFO] Please visit https:\/\/hawkular-metrics.${__OS_APPS_DOMAIN} and accept the ssl certificate for the metrics to work"
echo ""
touch ${__TESTS_DIR}/addons.metrics.configured
fi
rm ${__TESTS_DIR}/addons.metrics.wanted
fi
}
logging-setup(){
# Create logging
# TODO: For now it doesn't properly work, but still adding here
if [ -f ${__TESTS_DIR}/addons.logging.wanted ]; then
if [ ! -f ${__TESTS_DIR}/addons.logging.configured ]; then
echo "[INFO] Creating and configuring logging"
oc create -n openshift -f https://raw.githubusercontent.com/openshift/origin-aggregated-logging/master/deployer/deployer.yaml
# oc adm new-project logging --node-selector=""
oc project openshift-infra
oc secrets new logging-deployer nothing=/dev/null
# This step creates all the required service accounts
oc new-app logging-deployer-account-template
# Modify the service accounts adding all the required roles
oc policy add-role-to-user edit --serviceaccount logging-deployer
oc policy add-role-to-user daemonset-admin --serviceaccount logging-deployer
oc adm policy add-cluster-role-to-user oauth-editor system:serviceaccount:openshift-infra:logging-deployer
oc adm policy add-scc-to-user privileged system:serviceaccount:openshift-infra:aggregated-logging-fluentd
oc adm policy add-cluster-role-to-user cluster-reader system:serviceaccount:openshift-infra:aggregated-logging-fluentd
# Deploy EFK stack and configure all the created pods (Add these if you want ops cluster: ENABLE_OPS_CLUSTER=true)
oc new-app logging-deployer-template \
-p IMAGE_VERSION=${__VERSION} \
-p KIBANA_HOSTNAME=kibana.${__OS_APPS_DOMAIN} \
-p ES_CLUSTER_SIZE=1 \
-p KIBANA_OPS_HOSTNAME=kibana-ops.${__OS_APPS_DOMAIN} \
-p PUBLIC_MASTER_URL=https://${__OS_PUBLIC_IP}:8443
oc label nodes --all logging-infra-fluentd=true
sed -i.orig -e "s/\(.*loggingPublicURL:\).*/\1 \"https:\/\/kibana.${__OS_APPS_DOMAIN}\"/" ${__MASTER_CONFIG}
systemctl restart origin
# Wait for startup
while [ `oc get pods --no-headers | grep Running | wc -l` -eq 0 ]; do sleep 1; done
echo "Configuring resources"
while [ `oc get pods --no-headers | grep Running | wc -l` -eq 1 ]; do sleep 1; done
echo "Logging ready"
# Add capabilities to enable/disable logging to every authenticated user
oc create -f /scripts/logging/allinone-logging-scaler-clusterrole.json
oc adm policy add-role-to-group allinone:logging-scaler system:authenticated -n openshift-infra
echo "[INFO] Installing disable-logging script"
chmod 755 /scripts/logging/disable-logging
ln -s /scripts/logging/disable-logging /usr/local/bin/disable-logging
echo "[INFO] Installing enable-logging script"
chmod 755 /scripts/logging/enable-logging
ln -s /scripts/logging/enable-logging /usr/local/bin/enable-logging
touch ${__TESTS_DIR}/addons.logging.configured
fi
rm ${__TESTS_DIR}/addons.logging.wanted
fi
}
testusers-setup(){
# Create users
if [ -f ${__TESTS_DIR}/addons.testusers.wanted ]; then
if [ ! -f ${__TESTS_DIR}/addons.testusers.configured ]; then
echo "[INFO] Creating and configuring test users"
useradd -m -N -g vagrant dev; echo dev | passwd dev --stdin
# TODO: Add .kube profile with the user logged in
echo "[INFO] User dev created"
useradd -m -N -g vagrant test; echo test | passwd test --stdin
echo "[INFO] User test created"
useradd -m -N -g vagrant prod; echo prod | passwd prod --stdin
echo "[INFO] User prod created"
touch ${__TESTS_DIR}/addons.testusers.configured
fi
rm ${__TESTS_DIR}/addons.testusers.wanted
fi
}
origin-images-setup(){
origin_image_list=(
# Origin images
docker.io/openshift/origin-deployer:latest
docker.io/openshift/origin-docker-registry:latest
docker.io/openshift/origin-haproxy-router:latest
docker.io/openshift/origin-pod:latest
docker.io/openshift/origin-sti-builder:latest
docker.io/openshift/origin-docker-builder:latest
# docker.io/openshift/origin-custom-docker-builder:latest
docker.io/openshift/origin-gitserver:latest
# docker.io/openshift/origin-f5-router:latest
# docker.io/openshift/origin-keepalived-ipfailover:latest
docker.io/openshift/origin-recycler:latest
# Metrics
docker.io/openshift/origin-metrics-deployer:latest
docker.io/openshift/origin-metrics-hawkular-metrics:latest
docker.io/openshift/origin-metrics-heapster:latest
docker.io/openshift/origin-metrics-cassandra:latest
)
# Pull down images
if [ -f ${__TESTS_DIR}/addons.originimages.wanted ]
then
if [ ! -f ${__TESTS_DIR}/addons.originimages.configured ]
then
echo "[INFO] Downloading Origin images"
for image in ${origin_image_list[@]}; do
echo "[INFO] Downloading image ${image}"
docker pull $image
done
touch ${__TESTS_DIR}/addons.originimages.configured
fi
rm ${__TESTS_DIR}/addons.originimages.wanted
fi
}
centos-images-setup(){
centos_image_list=(
# Centos SCL
docker.io/openshift/jenkins-1-centos7:latest
docker.io/centos/mongodb-26-centos7:latest
docker.io/centos/mysql-56-centos7:latest
docker.io/centos/nodejs-010-centos7:latest
docker.io/centos/perl-520-centos7:latest
docker.io/centos/php-56-centos7:latest
docker.io/centos/postgresql-94-centos7:latest
docker.io/centos/python-34-centos7:latest
docker.io/centos/ruby-22-centos7:latest
# Add wildfly
)
if [ -f ${__TESTS_DIR}/addons.centosimages.wanted ]
then
if [ ! -f ${__TESTS_DIR}/addons.centosimages.configured ]
then
echo "[INFO] Downloading CENTOS7 based images"
for image in ${centos_image_list[@]}; do
echo "[INFO] Downloading image ${image}"
docker pull $image
done
touch ${__TESTS_DIR}/addons.centosimages.configured
fi
rm ${__TESTS_DIR}/addons.centosimages.wanted
fi
}
rhel-images-setup(){
rhel_image_list=(
# RHEL SCL
registry.access.redhat.com/openshift3/jenkins-1-rhel7:latest
registry.access.redhat.com/rhscl/mongodb-26:Q-rhel7:latest
registry.access.redhat.com/rhscl/mysql-56-rhel7:latest
registry.access.redhat.com/rhscl/nodejs-010-rhel7:latest
registry.access.redhat.com/rhscl/perl-520-rhel7:latest
registry.access.redhat.com/rhscl/php-56-rhel7:latest
registry.access.redhat.com/rhscl/postgresql-94-rhel7:latest
registry.access.redhat.com/rhscl/python-34-rhel7:latest
registry.access.redhat.com/rhscl/ruby-22-rhel7:latest
# RHEL images
)
if [ -f ${__TESTS_DIR}/addons.rhelimages.wanted ]
then
if [ ! -f ${__TESTS_DIR}/addons.rhelimages.configured ]
then
echo "[INFO] Downloading RHEL7 based images"
for image in ${rhel_image_list[@]}; do
echo "[INFO] Downloading image ${image}"
docker pull $image
done
touch ${__TESTS_DIR}/addons.rhelimages.configured
fi
rm ${__TESTS_DIR}/addons.rhelimages.wanted
fi
}
xpaas-images-setup(){
xpaas_image_list=(
# New
registry.access.redhat.com/jboss-webserver-3/webserver30-tomcat7-openshift
registry.access.redhat.com/jboss-webserver-3/webserver30-tomcat8-openshift
registry.access.redhat.com/jboss-eap-6/eap64-openshift
registry.access.redhat.com/jboss-decisionserver-6/decisionserver62-openshift
registry.access.redhat.com/jboss-datagrid-6/datagrid65-openshift
registry.access.redhat.com/jboss-amq-6/amq62-openshift
# Old
registry.access.redhat.com/jboss-amq-6/amq-openshift:6.2
registry.access.redhat.com/jboss-eap-6/eap-openshift:6.4
registry.access.redhat.com/jboss-webserver-3/tomcat7-openshift:3.0
registry.access.redhat.com/jboss-webserver-3/tomcat8-openshift:3.0
)
if [ -f ${__TESTS_DIR}/addons.xpaasimages.wanted ]
then
if [ ! -f ${__TESTS_DIR}/addons.xpaasimages.configured ]
then
echo "[INFO] Downloading xPaaS RHEL7 based images"
for image in ${xpaas_image_list[@]}; do
echo "[INFO] Downloading image ${image}"
docker pull $image
done
touch ${__TESTS_DIR}/addons.xpaasimages.configured
fi
rm ${__TESTS_DIR}/addons.xpaasimages.wanted
fi
}
other-images-setup(){
other_image_list=(
# Samples
docker.io/openshift/hello-openshift:latest
)
if [ -f ${__TESTS_DIR}/addons.otherimages.wanted ]
then
if [ ! -f ${__TESTS_DIR}/addons.otherimages.configured ]
then
echo "[INFO] Downloading other images"
for image in ${other_image_list[@]}; do
echo "[INFO] Downloading image ${image}"
docker pull $image
done
touch ${__TESTS_DIR}/addons.otherimages.configured
fi
rm ${__TESTS_DIR}/addons.otherimages.wanted
fi
}
ADDONS-Setup(){
# TODO: Depending on the action, delete control files
arr=$(echo ${__OS_CONFIG} | tr "," "\n")
for x in ${arr}
do
touch ${__TESTS_DIR}/addons.${x}.wanted
done
osetemplates-setup
metrics-setup
logging-setup
testusers-setup
origin-images-setup
centos-images-setup
rhel-images-setup
xpaas-images-setup
other-images-setup
}