forked from IBM/kube101
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab2-1.sh
executable file
·34 lines (23 loc) · 1.03 KB
/
lab2-1.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
#!/bin/bash
source ./common.sh
SERVICE_PORT=$(kubectl get svc guestbook -ojson | grep nodePort | sed "s/.*: *\([0-9]*\).*/\1/g")
WORKER_IP=$(bx cs workers ${CLUSTER_NAME} --json | grep publicIP | sed "s/.*\"\([0-9].*\)\".*/\1/g" )
GUESTBOOK_CURL=${WORKER_IP}:${SERVICE_PORT}/hello
# make sure the service works
comment "We're starting with the same output as the previous lab"
doit curl -s ${GUESTBOOK_CURL}
comment we have the pods
doit kubectl get pods -l run=guestbook
# these pods come from the deployment
# kubectl get deployment ${DEPLOYMENT_NAME}
comment --nolf "You should start this watch in a separate terminal"
comment " watch -d -n 0.2 curl -s ${GUESTBOOK_CURL}"
comment --pauseafter "Press ENTER when ready"
replicas=$(( ( RANDOM % 5 ) + 2 ))
comment --nocr --nohash --pauseafter "How many replicas? "
comment --nohash $replicas
# use `kubectl scale`
doit kubectl scale deployment ${DEPLOYMENT_NAME} --replicas ${replicas}
# show the pods
doit kubectl get pods -l run=guestbook
comment --pauseafter "*** End of "$(basename $0)