forked from kiali/kiali
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-bookinfo-demo.sh
executable file
·476 lines (439 loc) · 19.8 KB
/
install-bookinfo-demo.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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
#!/bin/bash
##############################################################################
# install-bookinfo-demo.sh
#
# Installs the Istio Bookinfo Sample Demo Application into your cluster
# (either Kubernetes or OpenShift).
#
# If you do not yet have it, this script will download a copy of Istio.
#
# See --help for more details on options to this script.
#
##############################################################################
HACK_SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
source ${HACK_SCRIPT_DIR}/functions.sh
# ISTIO_DIR is where the Istio download is installed and thus where the bookinfo demo files are found.
# CLIENT_EXE_NAME is going to either be "oc" or "kubectl"
ISTIO_DIR=
CLIENT_EXE_NAME="oc"
NAMESPACE="bookinfo"
ISTIO_NAMESPACE="istio-system"
RATE=1
AUTO_INJECTION="true"
MANUAL_INJECTION="false"
DELETE_BOOKINFO="false"
MINIKUBE_PROFILE="minikube"
ARCH="amd64"
WAIT_TIMEOUT="0" # can be things like "60s" or "30m"
WAYPOINT="false"
AMBIENT_ENABLED="false" # the script will set this to true only if Ambient is enabled and no sidecars are injected
# process command line args
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-a|--arch)
ARCH="$2"
shift;shift
;;
-ai|--auto-injection)
AUTO_INJECTION="$2"
shift;shift
;;
-db|--delete-bookinfo)
DELETE_BOOKINFO="$2"
shift;shift
;;
-id|--istio-dir)
ISTIO_DIR="$2"
shift;shift
;;
-in|--istio-namespace)
ISTIO_NAMESPACE="$2"
shift;shift
;;
-c|--client-exe)
CLIENT_EXE_NAME="$2"
shift;shift
;;
-n|--namespace)
NAMESPACE="$2"
shift;shift
;;
-mi|--manual-injection)
MANUAL_INJECTION="$2"
shift;shift
;;
-mp|--minikube-profile)
MINIKUBE_PROFILE="$2"
shift;shift
;;
-b|--bookinfo.yaml)
BOOKINFO_YAML="$2"
shift;shift
;;
-g|--gateway.yaml)
GATEWAY_YAML="$2"
shift;shift
;;
--mongo)
MONGO_ENABLED="true"
shift;
;;
--mysql)
MYSQL_ENABLED="true"
shift;
;;
-tg|--traffic-generator)
TRAFFIC_GENERATOR_ENABLED="true"
shift;
;;
-w|--waypoint)
WAYPOINT="$2"
shift;shift
;;
-wt|--wait-timeout)
WAIT_TIMEOUT="$2"
shift;shift
;;
-h|--help)
cat <<HELPMSG
Valid command line arguments:
-a|--arch <amd64|ppc64le|s390x>: Images for given arch will be used (default: amd64). Custom bookinfo yaml file provided via '-b' argument is ignored when using different arch than the default.
-ai|--auto-injection <true|false>: If you want sidecars to be auto-injected (default: true).
-db|--delete-bookinfo <true|false>: If true, uninstall bookinfo. If false, install bookinfo. (default: false).
-id|--istio-dir <dir>: Where Istio has already been downloaded. If not found, this script aborts.
-in|--istio-namespace <name>: Where the Istio control plane is installed (default: istio-system).
-c|--client-exe <name>: Cluster client executable name - valid values are "kubectl" or "oc"
-mi|--manual-injection <true|false>: If you want sidecars to be manually injected via istioctl (default: false).
-mp|--minikube-profile <name>: If using minikube, this is the minikube profile name (default: minikube).
-n|--namespace <name>: Install the demo in this namespace (default: bookinfo)
-b|--bookinfo.yaml <file>: A custom yaml file to deploy the bookinfo demo. This is ignored when not using default arch via '-a' argument.
-g|--gateway.yaml <file>: A custom yaml file to deploy the bookinfo-gateway resources
--mongo: Install a Mongo DB that a ratings service will access
--mysql: Install a MySQL DB that a ratings service will access
-w|--waypoint: Install a waypoint proxy in bookinfo namespace when Ambient is enabled. By default is false.
-wt|--wait-timeout <timeout>: If not "0", then this script will wait for all pods in the new bookinfo namespace to be Ready before exiting. This value can be things like "60s" or "30m". (default: 0)
-tg|--traffic-generator: Install Kiali Traffic Generator on Bookinfo
-h|--help : this message
HELPMSG
exit 1
;;
*)
echo "Unknown argument [$key]. Aborting."
exit 1
;;
esac
done
if [ "${ISTIO_DIR}" == "" ]; then
# Go to the main output directory and try to find an Istio there.
HACK_SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
OUTPUT_DIR="${OUTPUT_DIR:-${HACK_SCRIPT_DIR}/../../_output}"
ALL_ISTIOS=$(ls -dt1 ${OUTPUT_DIR}/istio-*)
if [ "$?" != "0" ]; then
${HACK_SCRIPT_DIR}/download-istio.sh
if [ "$?" != "0" ]; then
echo "ERROR: You do not have Istio installed and it cannot be downloaded"
exit 1
fi
fi
# use the Istio release that was last downloaded (that's the -t option to ls)
ISTIO_DIR=$(ls -dt1 ${OUTPUT_DIR}/istio-* | head -n1)
fi
if [ ! -d "${ISTIO_DIR}" ]; then
echo "ERROR: Istio cannot be found at: ${ISTIO_DIR}"
exit 1
fi
echo "Istio is found here: ${ISTIO_DIR}"
if [[ -x "${ISTIO_DIR}/bin/istioctl" ]]; then
echo "istioctl is found here: ${ISTIO_DIR}/bin/istioctl"
ISTIOCTL="${ISTIO_DIR}/bin/istioctl"
${ISTIOCTL} version
else
echo "ERROR: istioctl is NOT found at ${ISTIO_DIR}/bin/istioctl"
exit 1
fi
CLIENT_EXE=`which ${CLIENT_EXE_NAME}`
if [ "$?" = "0" ]; then
echo "The cluster client executable is found here: ${CLIENT_EXE}"
else
echo "You must install the cluster client ${CLIENT_EXE_NAME} in your PATH before you can continue"
exit 1
fi
IS_OPENSHIFT="false"
IS_MAISTRA="false"
if [[ "${CLIENT_EXE}" = *"oc" ]]; then
IS_OPENSHIFT="true"
IS_MAISTRA=$([ "$(oc get crd | grep servicemesh | wc -l)" -gt "0" ] && echo "true" || echo "false")
fi
# If no sidecars are to be injected, then see if Ambient is enabled.
# Look everywhere for a "ztunnel" daemonset (in case it is in a kube internal namespace and not just istio-system)
if [ "${AUTO_INJECTION}" == "false" -a "${MANUAL_INJECTION}" == "false" ]; then
for n in $(${CLIENT_EXE} get daemonset --all-namespaces -o jsonpath='{.items[*].metadata.name}')
do
if [ "${n}" == "ztunnel" ]; then
AMBIENT_ENABLED="true"
break
fi
done
if [ "${AMBIENT_ENABLED}" == "false" ] && [ "${WAYPOINT}" == "true" ]; then
echo "Waypoint proxy cannot be installed as Ambient is not enabled."
exit 1
fi
fi
echo "IS_OPENSHIFT=${IS_OPENSHIFT}"
echo "IS_MAISTRA=${IS_MAISTRA}"
echo "AMBIENT_ENABLED=${AMBIENT_ENABLED}"
# check arch values and prepare new bookinfo-arch.yaml with matching images
if [ "${ARCH}" == "ppc64le" ]; then
cp ${HACK_SCRIPT_DIR}/kustomization/bookinfo-ppc64le.yaml ${ISTIO_DIR}/samples/bookinfo/platform/kube/kustomization.yaml
${CLIENT_EXE} kustomize ${ISTIO_DIR}/samples/bookinfo/platform/kube --reorder=none > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ppc64le.yaml
BOOKINFO_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ppc64le.yaml"
elif [ "${ARCH}" == "s390x" ]; then
cp ${HACK_SCRIPT_DIR}/kustomization/bookinfo-s390x.yaml ${ISTIO_DIR}/samples/bookinfo/platform/kube/kustomization.yaml
${CLIENT_EXE} kustomize ${ISTIO_DIR}/samples/bookinfo/platform/kube --reorder=none > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-s390x.yaml
BOOKINFO_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-s390x.yaml"
elif [ "${ARCH}" != "amd64" ]; then
echo "${ARCH} is not supported. Exiting."
exit 1
fi
# use default bookinfo.yaml when there was no custom file provided or different arch selected
if [ "${BOOKINFO_YAML}" == "" ]; then
BOOKINFO_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo.yaml"
fi
if [ "${GATEWAY_YAML}" == "" ]; then
GATEWAY_YAML="${ISTIO_DIR}/samples/bookinfo/networking/bookinfo-gateway.yaml"
fi
# If we are to delete, remove everything and exit immediately after
if [ "${DELETE_BOOKINFO}" == "true" ]; then
echo "====== UNINSTALLING ANY EXISTING BOOKINFO DEMO ====="
if [ "${IS_OPENSHIFT}" == "true" ]; then
if [ "${IS_MAISTRA}" != "true" ]; then
$CLIENT_EXE delete network-attachment-definition istio-cni -n ${NAMESPACE}
else
$CLIENT_EXE delete smm default -n ${NAMESPACE}
fi
$CLIENT_EXE delete scc bookinfo-scc
$CLIENT_EXE delete project ${NAMESPACE}
# oc delete project does not wait for a namespace to be removed, we need to also call 'oc delete namespace'
$CLIENT_EXE delete namespace ${NAMESPACE}
else
$CLIENT_EXE delete namespace ${NAMESPACE}
fi
echo "====== BOOKINFO UNINSTALLED ====="
exit 0
fi
# If OpenShift, we need to do some additional things
if [ "${IS_OPENSHIFT}" == "true" ]; then
$CLIENT_EXE new-project ${NAMESPACE}
else
$CLIENT_EXE create namespace ${NAMESPACE}
fi
# If OpenShift, we need to do some additional things
if [ "${IS_OPENSHIFT}" == "true" ]; then
$CLIENT_EXE expose svc/productpage -n ${NAMESPACE}
$CLIENT_EXE expose svc/istio-ingressgateway --port http2 -n ${ISTIO_NAMESPACE}
if [ "${IS_MAISTRA}" != "true" ]; then
cat <<NAD | $CLIENT_EXE -n ${NAMESPACE} apply -f -
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: istio-cni
NAD
fi
cat <<SCC | $CLIENT_EXE apply -f -
apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata:
name: bookinfo-scc
runAsUser:
type: RunAsAny
seLinuxContext:
type: RunAsAny
supplementalGroups:
type: RunAsAny
priority: 9
users:
- "system:serviceaccount:${NAMESPACE}:bookinfo-details"
- "system:serviceaccount:${NAMESPACE}:bookinfo-productpage"
- "system:serviceaccount:${NAMESPACE}:bookinfo-ratings"
- "system:serviceaccount:${NAMESPACE}:bookinfo-ratings-v2"
- "system:serviceaccount:${NAMESPACE}:bookinfo-reviews"
- "system:serviceaccount:${NAMESPACE}:default"
SCC
fi
if [ "${AUTO_INJECTION}" == "true" ]; then
$CLIENT_EXE label namespace ${NAMESPACE} "istio-injection=enabled"
$CLIENT_EXE apply -n ${NAMESPACE} -f ${BOOKINFO_YAML}
else
if [ "${MANUAL_INJECTION}" == "true" ]; then
$ISTIOCTL kube-inject -f ${BOOKINFO_YAML} | $CLIENT_EXE apply -n ${NAMESPACE} -f -
else
$CLIENT_EXE apply -n ${NAMESPACE} -f ${BOOKINFO_YAML}
fi
fi
$CLIENT_EXE apply -n ${NAMESPACE} -f ${GATEWAY_YAML}
if [ "${MONGO_ENABLED}" == "true" ]; then
echo "Installing Mongo DB and a ratings service that uses it"
MONGO_DB_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-db.yaml"
MONGO_SERVICE_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2.yaml"
if [ "${ARCH}" == "ppc64le" ]; then
sed "s;docker.io/istio.*;quay.io/maistra/examples-bookinfo-mongodb:2.0.0-ibm-p;g" ${MONGO_DB_YAML} > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-db-ppc64le.yaml
MONGO_DB_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-db-ppc64le.yaml"
sed "s;docker.io/istio.*;quay.io/maistra/examples-bookinfo-ratings-v2:2.0.0-ibm-p-mod;g" ${MONGO_SERVICE_YAML} > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2-ppc64le.yaml
MONGO_SERVICE_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2-ppc64le.yaml"
fi
if [ "${ARCH}" == "s390x" ]; then
sed "s;docker.io/istio.*;quay.io/maistra/examples-bookinfo-mongodb:2.0.0-ibm-z;g" ${MONGO_DB_YAML} > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-db-s390x.yaml
MONGO_DB_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-db-s390x.yaml"
sed "s;docker.io/istio.*;quay.io/maistra/examples-bookinfo-ratings-v2:2.0.0-ibm-z;g" ${MONGO_SERVICE_YAML} > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2-s390x.yaml
MONGO_SERVICE_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2-s390x.yaml"
fi
if [ "${AUTO_INJECTION}" == "true" ]; then
$CLIENT_EXE apply -n ${NAMESPACE} -f ${MONGO_DB_YAML}
$CLIENT_EXE apply -n ${NAMESPACE} -f ${MONGO_SERVICE_YAML}
else
if [ "${MANUAL_INJECTION}" == "true" ]; then
$ISTIOCTL kube-inject -f ${MONGO_DB_YAML} | $CLIENT_EXE apply -n ${NAMESPACE} -f -
$ISTIOCTL kube-inject -f ${MONGO_SERVICE_YAML} | $CLIENT_EXE apply -n ${NAMESPACE} -f -
else
$CLIENT_EXE apply -n ${NAMESPACE} -f ${MONGO_DB_YAML}
$CLIENT_EXE apply -n ${NAMESPACE} -f ${MONGO_SERVICE_YAML}
fi
fi
fi
if [ "${MYSQL_ENABLED}" == "true" ]; then
echo "Installing MySql DB and a ratings service that uses it"
MYSQL_DB_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-mysql.yaml"
MYSQL_SERVICE_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2-mysql.yaml"
if [ "${ARCH}" == "ppc64le" ]; then
sed "s;docker.io/istio.*;quay.io/maistra/examples-bookinfo-mysqldb:2.0.0-ibm-p;g" ${MYSQL_DB_YAML} > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-mysql-ppc64le.yaml
MYSQL_DB_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-mysql-ppc64le.yaml"
sed "s;docker.io/istio.*;quay.io/maistra/examples-bookinfo-ratings-v2:2.0.0-ibm-p;g" ${MYSQL_SERVICE_YAML} > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2-mysql-ppc64le.yaml
MYSQL_SERVICE_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2-mysql-ppc64le.yaml"
fi
if [ "${ARCH}" == "s390x" ]; then
sed "s;docker.io/istio.*;quay.io/maistra/examples-bookinfo-mysqldb:2.0.0-ibm-z;g" ${MYSQL_DB_YAML} > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-mysql-s390x.yaml
MYSQL_DB_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-mysql-s390x.yaml"
sed "s;docker.io/istio.*;quay.io/maistra/examples-bookinfo-ratings-v2:2.0.0-ibm-z;g" ${MYSQL_SERVICE_YAML} > ${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2-mysql-s390x.yaml
MYSQL_SERVICE_YAML="${ISTIO_DIR}/samples/bookinfo/platform/kube/bookinfo-ratings-v2-mysql-s390x.yaml"
fi
if [ "${AUTO_INJECTION}" == "true" ]; then
$CLIENT_EXE apply -n ${NAMESPACE} -f ${MYSQL_DB_YAML}
$CLIENT_EXE apply -n ${NAMESPACE} -f ${MYSQL_SERVICE_YAML}
else
if [ "${MANUAL_INJECTION}" == "true" ]; then
$ISTIOCTL kube-inject -f ${MYSQL_DB_YAML} | $CLIENT_EXE apply -n ${NAMESPACE} -f -
$ISTIOCTL kube-inject -f ${MYSQL_SERVICE_YAML} | $CLIENT_EXE apply -n ${NAMESPACE} -f -
else
$CLIENT_EXE apply -n ${NAMESPACE} -f ${MYSQL_DB_YAML}
$CLIENT_EXE apply -n ${NAMESPACE} -f ${MYSQL_SERVICE_YAML}
fi
fi
fi
if [ "${IS_MAISTRA}" == "true" ]; then
prepare_maistra "${NAMESPACE}"
fi
sleep 4
echo "Bookinfo Demo should be installed and starting up - here are the pods and services"
$CLIENT_EXE get services -n ${NAMESPACE}
$CLIENT_EXE get pods -n ${NAMESPACE}
if [ "${AMBIENT_ENABLED}" == "true" ]; then
echo "Sidecar injection was not performed. Ambient support will be enabled."
${CLIENT_EXE} label namespace ${NAMESPACE} istio.io/dataplane-mode=ambient
# It could also be applied to service account
if [ "${WAYPOINT}" == "true" ]; then
# Verify Gateway API
echo "Verifying that Gateway API is installed; if it is not then it will be installed now."
$CLIENT_EXE get crd gateways.gateway.networking.k8s.io &> /dev/null || \
{ $CLIENT_EXE kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.6.2" | $CLIENT_EXE apply -f -; }
# Create Waypoint proxy
echo "Create Waypoint proxy"
${ISTIOCTL} x waypoint apply -n ${NAMESPACE}
fi
else
if [ "${AUTO_INJECTION}" == "false" -a "${MANUAL_INJECTION}" == "false" ]; then
echo "WARNING! Sidecar injection was not performed and there is no Ambient support. This demo may not work until sidecars are injected."
fi
fi
if [ "${TRAFFIC_GENERATOR_ENABLED}" == "true" ]; then
echo "Installing Traffic Generator"
if [ "${IS_OPENSHIFT}" == "true" ]; then
INGRESS_ROUTE=$(${CLIENT_EXE} get route istio-ingressgateway -o jsonpath='{.spec.host}{"\n"}' -n ${ISTIO_NAMESPACE})
echo "Traffic Generator will use the OpenShift ingress route of: ${INGRESS_ROUTE}"
else
# Important note for minikube users
# Ingress and Egress configuration depend on the platform
# Check your "minikube tunnel" and/or Istio mesh config i.e. meshConfig.outboundTrafficPolicy.mode=REGISTRY_ONLY
# if you experiment some weird behaviour compared with the CI results
# for now, we only support minikube k8s environments and maybe a good guess otherwise (e.g. for kind clusters)
if minikube -p ${MINIKUBE_PROFILE} status > /dev/null 2>&1 ; then
INGRESS_HOST=$(minikube -p ${MINIKUBE_PROFILE} ip)
INGRESS_PORT=$($CLIENT_EXE -n ${ISTIO_NAMESPACE} get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
INGRESS_ROUTE=$INGRESS_HOST:$INGRESS_PORT
echo "Wait for productpage to come up to see if it is accessible via minikube ingress"
$CLIENT_EXE wait pods --all -n ${NAMESPACE} --for=condition=Ready --timeout=5m
if curl --fail http://${INGRESS_ROUTE}/productpage &> /dev/null; then
echo "Traffic Generator will use the Kubernetes (minikube) ingress route of: ${INGRESS_ROUTE}"
else
INGRESS_HOST="productpage.${NAMESPACE}"
INGRESS_PORT="9080"
INGRESS_ROUTE=$INGRESS_HOST:$INGRESS_PORT
echo "Ingress does not seem to work. Falling back to using the internal productpage endpoint: ${INGRESS_ROUTE}"
fi
else
echo "Failed to get minikube ip. If you are using minikube, make sure it is up and your profile is defined properly (--minikube-profile option)"
echo "Will try to get the ingressgateway IP in case you are running 'kind' and we can access it directly."
INGRESS_HOST=$($CLIENT_EXE get service -n ${ISTIO_NAMESPACE} istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
INGRESS_PORT="80"
INGRESS_ROUTE=$INGRESS_HOST:$INGRESS_PORT
echo "Wait for productpage to come up to see if it is accessible via ingress"
$CLIENT_EXE wait pods --all -n ${NAMESPACE} --for=condition=Ready --timeout=5m
if curl --fail http://${INGRESS_ROUTE}/productpage &> /dev/null; then
echo "Traffic Generator will use the Kubernetes (loadBalancer) route of: ${INGRESS_ROUTE}"
else
INGRESS_HOST="productpage.${NAMESPACE}"
INGRESS_PORT="9080"
INGRESS_ROUTE=$INGRESS_HOST:$INGRESS_PORT
echo "Ingress loadBalancer does not seem to work. Falling back to using the internal productpage endpoint: ${INGRESS_ROUTE}"
fi
fi
fi
if [ "${INGRESS_ROUTE}" != "" ] ; then
if [ "${IS_OPENSHIFT}" == "true" ]; then
$CLIENT_EXE adm policy add-scc-to-user anyuid -z default -n ${NAMESPACE}
fi
# TODO - these access the "openshift" yaml files - but there are no kubernetes specific versions. using --validate=false
curl https://raw.githubusercontent.com/kiali/kiali-test-mesh/master/traffic-generator/openshift/traffic-generator-configmap.yaml | DURATION='0s' ROUTE="http://${INGRESS_ROUTE}/productpage" RATE="${RATE}" envsubst | $CLIENT_EXE apply -n ${NAMESPACE} -f -
url="https://raw.githubusercontent.com/kiali/kiali-test-mesh/master/traffic-generator/openshift/traffic-generator.yaml"
if [ "${ARCH}" == "ppc64le" ]; then
curl ${url} | sed 's;quay.io/kiali.*;quay.io/maistra/kiali-test-mesh-traffic-generator:0.0-ibm-p;g' | $CLIENT_EXE apply --validate=false -n ${NAMESPACE} -f -
elif [ "${ARCH}" == "s390x" ]; then
curl ${url} | sed 's;quay.io/kiali.*;quay.io/maistra/kiali-test-mesh-traffic-generator:0.0-ibm-z;g' | $CLIENT_EXE apply --validate=false -n ${NAMESPACE} -f -
else
curl ${url} | $CLIENT_EXE apply --validate=false -n ${NAMESPACE} -f -
fi
if [ "${AMBIENT_ENABLED}" == "true" ]; then
cat <<AUTHPOLICY | $CLIENT_EXE -n ${NAMESPACE} apply -f -
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: productpage-viewer
spec:
selector:
matchLabels:
app: productpage
action: ALLOW
rules:
- from:
- source:
principals:
- cluster.local/ns/${NAMESPACE}/sa/default
- cluster.local/ns/${ISTIO_NAMESPACE}/sa/istio-ingressgateway-service-account
AUTHPOLICY
fi
fi
fi
if [ "${WAIT_TIMEOUT}" != "0" ]; then
echo "Waiting for all pods to be ready in namespace [${NAMESPACE}]"
$CLIENT_EXE wait pods --all -n ${NAMESPACE} --for=condition=Ready --timeout=${WAIT_TIMEOUT}
fi