-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdeploy-bookinfo.sh
More file actions
executable file
·164 lines (135 loc) · 5.67 KB
/
deploy-bookinfo.sh
File metadata and controls
executable file
·164 lines (135 loc) · 5.67 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
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
#!/bin/bash
SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $SCRIPTDIR/.bluemixrc
#################################################################################
# Pull Dockerhub images
#################################################################################
echo "Looking up Bluemix registry images"
BLUEMIX_IMAGES=$(cf ic images --format "{{.Repository}}:{{.Tag}}")
REQUIRED_IMAGES=(
${PRODUCTPAGE_IMAGE}
${DETAILS_IMAGE}
${RATINGS_IMAGE}
${REVIEWS_V1_IMAGE}
${REVIEWS_V2_IMAGE}
${REVIEWS_V3_IMAGE}
${GATEWAY_IMAGE}
)
for image in ${REQUIRED_IMAGES[@]}; do
echo $BLUEMIX_IMAGES | grep $image > /dev/null
if [ $? -ne 0 ]; then
echo "Pulling ${DOCKERHUB_NAMESPACE}/$image from Dockerhub"
cf ic cpi ${DOCKERHUB_NAMESPACE}/$image ${BLUEMIX_REGISTRY_HOST}/${BLUEMIX_REGISTRY_NAMESPACE}/$image
fi
done
#################################################################################
# Fetch registry credentials
#################################################################################
if [ "$ENABLE_SERVICEDISCOVERY" = true ]; then
SDKEY=$(cf service-key sd sdkey | tail -n +3)
REGISTRY_URL=$(echo "$SDKEY" | jq -r '.url')
REGISTRY_TOKEN=$(echo "$SDKEY" | jq -r '.auth_token')
else
# TODO: Use local registry credentials
echo "Not not implemented"
exit 1
fi
#################################################################################
# Start the productpage microservice instances
#################################################################################
echo "Starting bookinfo productpage microservice (v1)"
cf ic group create --name bookinfo_productpage \
--publish 9080 --memory 256 --auto \
--min 1 --max 2 --desired 1 \
--env CONTROLLER_URL=$CONTROLLER_URL \
--env TENANT_ID=$CONTROLLER_TENANT_ID \
--env TENANT_TOKEN=$CONTROLLER_TENANT_TOKEN \
--env SERVICE=productpage \
--env SERVICE_VERSION=v1 \
--env ENDPOINT_PORT=9080 \
--env LOG=false \
${BLUEMIX_REGISTRY_HOST}/${BLUEMIX_REGISTRY_NAMESPACE}/${PRODUCTPAGE_IMAGE}:v1
#################################################################################
# Start the details microservice instances
#################################################################################
echo "Starting bookinfo details microservice (v1)"
cf ic group create --name bookinfo_details \
--publish 9080 --memory 256 --auto \
--min 1 --max 2 --desired 1 \
--env REGISTRY_URL=$REGISTRY_URL \
--env REGISTRY_TOKEN=$REGISTRY_TOKEN \
--env SERVICE=details \
--env SERVICE_VERSION=v1 \
--env ENDPOINT_PORT=9080 \
${BLUEMIX_REGISTRY_HOST}/${BLUEMIX_REGISTRY_NAMESPACE}/${DETAILS_IMAGE}
#################################################################################
# Start the ratings microservice instances
#################################################################################
echo "Starting bookinfo ratings microservice (v1)"
cf ic group create --name bookinfo_ratings \
--publish 9080 --memory 256 --auto \
--min 1 --max 2 --desired 1 \
--env REGISTRY_URL=$REGISTRY_URL \
--env REGISTRY_TOKEN=$REGISTRY_TOKEN \
--env SERVICE=ratings \
--env SERVICE_VERSION=v1 \
--env ENDPOINT_PORT=9080 \
${BLUEMIX_REGISTRY_HOST}/${BLUEMIX_REGISTRY_NAMESPACE}/${RATINGS_IMAGE}
#################################################################################
# Start the reviews microservice instances
#################################################################################
echo "Starting bookinfo reviews microservice (v1)"
cf ic group create --name bookinfo_reviews1 \
--publish 9080 --memory 256 --auto \
--min 1 --max 2 --desired 1 \
--env CONTROLLER_URL=$CONTROLLER_URL \
--env TENANT_ID=$CONTROLLER_TENANT_ID \
--env TENANT_TOKEN=$CONTROLLER_TENANT_TOKEN \
--env SERVICE=reviews \
--env SERVICE_VERSION=v1 \
--env ENDPOINT_PORT=9080 \
--env LOG=false \
${BLUEMIX_REGISTRY_HOST}/${BLUEMIX_REGISTRY_NAMESPACE}/${REVIEWS_V1_IMAGE}
echo "Starting bookinfo reviews microservice (v2)"
cf ic group create --name bookinfo_reviews2 \
--publish 9080 --memory 256 --auto \
--min 1 --max 2 --desired 1 \
--env CONTROLLER_URL=$CONTROLLER_URL \
--env TENANT_ID=$CONTROLLER_TENANT_ID \
--env TENANT_TOKEN=$CONTROLLER_TENANT_TOKEN \
--env SERVICE=reviews \
--env SERVICE_VERSION=v2 \
--env ENDPOINT_PORT=9080 \
--env LOG=false \
${BLUEMIX_REGISTRY_HOST}/${BLUEMIX_REGISTRY_NAMESPACE}/${REVIEWS_V2_IMAGE}
echo "Starting bookinfo reviews microservice (v3)"
cf ic group create --name bookinfo_reviews3 \
--publish 9080 --memory 256 --auto \
--min 1 --max 2 --desired 1 \
--env CONTROLLER_URL=$CONTROLLER_URL \
--env TENANT_ID=$CONTROLLER_TENANT_ID \
--env TENANT_TOKEN=$CONTROLLER_TENANT_TOKEN \
--env SERVICE=reviews \
--env SERVICE_VERSION=v3 \
--env ENDPOINT_PORT=9080 \
--env LOG=false \
${BLUEMIX_REGISTRY_HOST}/${BLUEMIX_REGISTRY_NAMESPACE}/${REVIEWS_V3_IMAGE}
#################################################################################
# Start the gateway
#################################################################################
echo "Starting bookinfo gateway"
cf ic group create --name bookinfo_gateway \
--publish 6379 --memory 256 --auto \
--min 1 --max 2 --desired 1 \
--env CONTROLLER_URL=$CONTROLLER_URL \
--env TENANT_ID=$CONTROLLER_TENANT_ID \
--env TENANT_TOKEN=$CONTROLLER_TENANT_TOKEN \
--env SERVICE=gateway \
--env SERVICE_VERSION=v1 \
--env LOG=false \
--env REGISTER=false \
${BLUEMIX_REGISTRY_HOST}/${BLUEMIX_REGISTRY_NAMESPACE}/$GATEWAY_IMAGE
echo "Waiting for gateway to start..."
sleep 15s
echo "Mapping route to gateway: $BOOKINFO_URL"
cf ic route map --hostname $BOOKINFO_HOSTNAME --domain $ROUTES_DOMAIN bookinfo_gateway