2
2
set -x
3
3
4
4
# setup vars
5
+ export HOME=/root
5
6
export TERM=xterm-color
6
7
export KUBECONFIG=/opt/kubeconfig
7
8
echo " export TERM=xterm-color" >> /root/.bashrc
8
9
echo " export KUBECONFIG=/opt/kubeconfig" >> /root/.bashrc
9
- echo " export HOME=/root" >> /root /.bashrc
10
-
11
- ENS4IP= $( ip -4 -o addr show ens4 | awk ' {print $4} ' | cut -d " / " -f 1 )
10
+ echo " export HOME=/root" > /tmp /.bashrc
11
+ cat /root/.bashrc >> /tmp/.bashrc
12
+ mv /tmp/.bashrc /root/.bashrc
12
13
13
14
# set hostname
14
15
# INSTRUQT_HOSTNAME=$(curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/attributes/hostname)
15
16
16
- # Don't do this below causes issues later on, i believe.
17
- # hostnamectl set-hostname $HOSTNAME
18
-
19
17
eval $( curl -H " Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/attributes/startup-script | grep INSTRUQT_PARTICIPANT_ID)
20
18
21
- # dnsmasq config for crc-dnsmasq.service
22
- cat << EOF > /var/srv/dnsmasq.conf
23
- user=root
24
- port= 53
25
- bind-interfaces
19
+ # start openshift
20
+ systemctl start ovs-configuration.service
21
+ BREXIP=$( ip -4 -o addr show br-ex | awk ' {print $4}' | cut -d " /" -f 1)
22
+
23
+ cat << EOF > /etc/resolv.conf
24
+ search c.rhd-devx-instruqt.internal google.internal
25
+ nameserver $BREXIP
26
+ nameserver 169.254.169.254
27
+ EOF
28
+
29
+ systemctl reload NetworkManager
30
+
31
+ cat << EOF > /etc/dnsmasq.d/crc-dnsmasq.conf
32
+ listen-address=$BREXIP
26
33
expand-hosts
27
34
log-queries
28
35
local=/crc.testing/
29
36
domain=crc.testing
30
- address=/apps-crc.testing/$ENS4IP
31
- address=/api.crc.testing/$ENS4IP
32
- address=/api-int.crc.testing/$ENS4IP
33
- address=/$HOSTNAME .crc.testing/192.168.126.11
37
+ address=/apps-crc.testing/$BREXIP
38
+ address=/api.crc.testing/$BREXIP
39
+ address=/api-int.crc.testing/$BREXIP
40
+ address=/crc .crc.testing/192.168.126.11
34
41
EOF
35
42
36
- sed -i ' /^search.*/a nameserver 10.88.0.8' /etc/resolv.conf
37
-
38
- # start openshift
39
- systemctl start crc-dnsmasq.service
43
+ systemctl start dnsmasq.service
40
44
systemctl start kubelet
41
45
42
46
# INGRESS
110
114
echo " AVAILABLE"
111
115
done
112
116
113
-
117
+ # SSL Setup
118
+ curl -s -o /etc/ssl/certs/sandbox.crt -H " Metadata-Flavor: Google" " http://metadata.google.internal/computeMetadata/v1/instance/attributes/ssl-certificate"
119
+ curl -s -o /etc/ssl/certs/sandbox.key -H " Metadata-Flavor: Google" " http://metadata.google.internal/computeMetadata/v1/instance/attributes/ssl-certificate-key"
120
+ oc --namespace openshift-ingress create secret tls custom-certs-default --cert=/etc/ssl/certs/sandbox.crt --key=/etc/ssl/certs/sandbox.key
121
+ rm /etc/ssl/certs/sandbox.key
122
+ # oc patch --type=merge --namespace openshift-ingress-operator ingresscontrollers/default --patch '{"spec":{"defaultCertificate":{"name":"custom-certs-default"}}}'
114
123
115
124
# INGRESS
116
125
117
126
# check if ingresses.config.openshift.io cluster is present
118
- oc patch -p ' {"spec": {"domain": "' $HOSTNAME ' .crc. ' $INSTRUQT_PARTICIPANT_ID ' .instruqt.io"}}' ingresses.config.openshift.io cluster --type=merge
127
+ oc patch -p ' {"spec": {"domain": "' $HOSTNAME ' .' $INSTRUQT_PARTICIPANT_ID ' .instruqt.io"}}' ingresses.config.openshift.io cluster --type=merge
119
128
120
129
# Wait 30 seconds for the old pod to be terminated
121
130
sleep 30
@@ -130,7 +139,9 @@ metadata:
130
139
namespace: openshift-ingress-operator
131
140
spec:
132
141
replicas: 1
133
- domain: $HOSTNAME .crc.$INSTRUQT_PARTICIPANT_ID .instruqt.io
142
+ domain: $HOSTNAME .$INSTRUQT_PARTICIPANT_ID .instruqt.io
143
+ defaultCertificate:
144
+ name: custom-certs-default
134
145
EOF
135
146
136
147
oc rollout status deploy/oauth-openshift -n openshift-authentication
@@ -141,11 +152,11 @@ oc rollout status deploy/apiserver -n openshift-apiserver
141
152
until oc get routes -A 2> /dev/null 1>&2 ; do echo " Changing routes, waiting for cluster operators..." ; sleep 5; done
142
153
143
154
144
- oc patch -p ' {"spec": {"host": "console-openshift-console.' $HOSTNAME ' .crc. ' $INSTRUQT_PARTICIPANT_ID ' .instruqt.io"}}' route console -n openshift-console --type=merge
155
+ oc patch -p ' {"spec": {"host": "console-openshift-console.' $HOSTNAME ' .' $INSTRUQT_PARTICIPANT_ID ' .instruqt.io"}}' route console -n openshift-console --type=merge
145
156
146
- oc patch -p ' {"spec": {"host": "downloads-openshift-console.' $HOSTNAME ' .crc. ' $INSTRUQT_PARTICIPANT_ID ' .instruqt.io"}}' route downloads -n openshift-console --type=merge
157
+ oc patch -p ' {"spec": {"host": "downloads-openshift-console.' $HOSTNAME ' .' $INSTRUQT_PARTICIPANT_ID ' .instruqt.io"}}' route downloads -n openshift-console --type=merge
147
158
148
- oc patch -p ' {"spec": {"host": "default-route-openshift-image-registry.' $HOSTNAME ' .crc. ' $INSTRUQT_PARTICIPANT_ID ' .instruqt.io"}}' route default-route -n openshift-image-registry --type=merge
159
+ oc patch -p ' {"spec": {"host": "default-route-openshift-image-registry.' $HOSTNAME ' .' $INSTRUQT_PARTICIPANT_ID ' .instruqt.io"}}' route default-route -n openshift-image-registry --type=merge
149
160
150
161
151
162
# wait until cluster operators are "available"
@@ -184,43 +195,7 @@ done
184
195
# In this way we try to optimize the flow while we wait for oauth and routes to be finally OK
185
196
# https://bugzilla.redhat.com/show_bug.cgi?id=2082539
186
197
187
- export KN_VERSION=1.6.1
188
-
189
- curl -kL https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 -o /root/hey
190
- mv /root/hey /usr/local/bin/
191
- chmod +x /usr/local/bin/hey
192
-
193
- curl -kL https:/mirror.openshift.com/pub/openshift-v4/x86_64/clients/serverless/${KN_VERSION} /kn-linux-amd64.tar.gz -o /usr/local/bin/kn.tar.gz
194
- tar -xvzf /usr/local/bin/kn.tar.gz -C /usr/local/bin
195
- mv /usr/local/bin/kn-linux-amd64 /usr/local/bin/kn
196
- chmod +x /usr/local/bin/kn
197
-
198
- mkdir -p /root/02-serving
199
-
200
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/02-serving/service.yaml -o /root/02-serving/service.yaml
201
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/02-serving/watch-service.bash -o /root/02-serving/watch-service.bash
202
-
203
- mkdir -p /root/03-traffic-distribution
204
-
205
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/03-traffic-distribution/greeter-v1-service.yaml -o /root/03-traffic-distribution/greeter-v1-service.yaml
206
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/03-traffic-distribution/greeter-v2-service.yaml -o /root/03-traffic-distribution/greeter-v2-service.yaml
207
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/03-traffic-distribution/service-pinned.yaml -o /root/03-traffic-distribution/service-pinned.yaml
208
-
209
- mkdir -p /root/04-canary-releases
210
-
211
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/04-canary-releases/greeter-canary-service.yaml -o /root/04-canary-releases/greeter-canary-service.yaml
212
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/04-canary-releases/poll-svc-10.bash -o /root/04-canary-releases/poll-svc-10.bash
213
-
214
- mkdir -p /root/05-scaling
215
-
216
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/05-scaling/service-50.yaml -o /root/05-scaling/service-50.yaml
217
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/05-scaling/service-hpa.yaml -o /root/05-scaling/service-hpa.yaml
218
- curl -s https:/raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/05-scaling/service-min-max-scale.yaml -o /root/05-scaling/service-min-max-scale.yaml
219
-
220
- # Setting up Serverless
221
- curl https://raw.githubusercontent.com/openshift-instruqt/instruqt/master/instruqt-tracks/developing-on-openshift-serverless/scripts/01-prepare/install-serverless.bash | bash
222
-
223
-
198
+ # ##
224
199
225
200
until [[ ` oc get routes -A | awk ' !/^(NAME|openshift-ingress-canary)/{print$3}' | grep $HOSTNAME ` ]]; do
226
201
echo " Routes not patched yet, waiting 30 seconds.." ;
259
234
done
260
235
261
236
# Wait until web console is available
262
- until curl -k https://console-openshift-console.$HOSTNAME .crc.$INSTRUQT_PARTICIPANT_ID .instruqt.io > /dev/null 2> /dev/null
237
+ while [ " $( oc rollout status deploy console -n openshift-console) " != " deployment \" console\" successfully rolled out" ]
238
+ do
239
+ echo " Waiting for web console - rollout incomplete"
240
+ sleep 5
241
+ done
242
+
243
+ while [ " $( curl -k -I https://console-openshift-console.$HOSTNAME .$INSTRUQT_PARTICIPANT_ID .instruqt.io -o /dev/null -w ' %{http_code}\n' -s 2> /dev/null) " != " 200" ]
244
+ do
245
+ echo " Waiting for web console - unavailable via curl"
246
+ sleep 5
247
+ done
248
+
249
+ while [ " $( oc rollout status deploy apiserver -n openshift-oauth-apiserver) " != " deployment \" apiserver\" successfully rolled out" ]
263
250
do
264
- echo " Waiting for web console - not available yet "
265
- sleep 6
251
+ echo " Waiting for oauth API - rollout incomplete "
252
+ sleep 5
266
253
done
267
254
268
255
echo $( date)
269
- echo " ### Boostrap END ###"
256
+ echo " ### Boostrap END ###"
0 commit comments