forked from GoogleCloudPlatform/python-docs-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·53 lines (45 loc) · 1.61 KB
/
setup.sh
File metadata and controls
executable file
·53 lines (45 loc) · 1.61 KB
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
#!/bin/bash
################## Set up service a ###########################
echo "Creating service a"
kubectl apply -f app/demo-service-a.yaml
################## Set up service b ###########################
echo "Fetching the external IP of service a"
endpoint=""
for run in {1..20}
do
echo "Attempt #${run} to fetch the external IP of service a..."
sleep 5
endpoint=`kubectl get svc cloud-trace-demo-a -ojsonpath='{.status.loadBalancer.ingress[0].ip}'`
if [[ "$endpoint" != "" ]]; then
break
fi
done
if [[ "$endpoint" == "" ]]; then
echo "Unable to get external IP for service cloud-trace-demo-a"
exit 1
fi
echo "Passing external IP for the first service ${endpoint} to the second service template"
sed "s/{{ endpoint }}/${endpoint}/g" app/demo-service-b.yaml.template > app/demo-service-b.yaml
kubectl apply -f app/demo-service-b.yaml
rm app/demo-service-b.yaml
################## Set up service c ###########################
echo "Fetching the external IP of service b"
endpoint=""
for run in {1..20}
do
echo "Attempt #${run} to fetch the external IP of service b..."
sleep 5
endpoint=`kubectl get svc cloud-trace-demo-b -ojsonpath='{.status.loadBalancer.ingress[0].ip}'`
if [[ "$endpoint" != "" ]]; then
break
fi
done
if [[ "$endpoint" == "" ]]; then
echo "Unable to get external IP for service cloud-trace-demo-a"
exit 1
fi
echo "Passing external IP for the service b ${endpoint} to the service c"
sed "s/{{ endpoint }}/${endpoint}/g" app/demo-service-c.yaml.template > app/demo-service-c.yaml
kubectl apply -f app/demo-service-c.yaml
rm app/demo-service-c.yaml
echo "Successfully deployed all services"