-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy
executable file
·151 lines (122 loc) · 3.16 KB
/
deploy
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
#!/bin/bash
# exit when any command fails
set -e
function create_minikube {
minikube start \
--driver=kvm2 \
--disk-size='50000mb' \
--cpus='4' \
--memory='16384mb' \
--kubernetes-version='1.16.8'
minikube addons enable metrics-server
}
function start_dashboard {
echo "starting dashboard"
cd dashboard
skaffold run
cd ..
}
function start_customer_v1 {
echo "starting customer-v1"
cd customer-v1
skaffold run
cd ..
}
function start_casa_account_v1 {
echo "starting casa-account-v1"
cd casa-account-v1
skaffold run
cd ..
}
function start_casa_account_v2 {
echo "starting casa-account-v2"
cd casa-account-v2
skaffold run
cd ..
}
function start_load_generator {
echo "starting load-generator"
cd load-generator
skaffold run
cd ..
}
function start_ext_cust_svc {
echo "starting ext-cust-svc"
cd ext-cust-svc
skaffold run
cd ..
}
if [ "$1" = "--minikube" ]; then
create_minikube
echo
echo now manually install istio to minikube, e.g.
echo
echo istioctl manifest apply \\
echo --set profile=demo \\
echo --set values.global.mtls.auto=true \\
echo --set values.global.mtls.enabled=true \\
echo --set values.global.proxy.accessLogFile=""
echo
echo
echo wait a while for istio to finish install and stabalizes.
echo if you use istio 1.4.x, please run the below command to enable
echo port 31400 on the istio-gateway for gRPC traffic
echo
echo
echo kubectl patch svc istio-ingressgateway -n istio-system \\
echo --type=\'json\' \\
echo --patch \'[{\"op\":\"add\",\"path\":\"/spec/ports/0\", \"value\":{\"name\":\"tcp\", \"port\":31400,\"targetPort\":31400, \"protocol\":\"TCP\"}}]\'
echo
echo
echo then rerun this script without --minikube flag to install demo application
exit 0
fi
source common.sh
get_ingress_addr
[ -z "$CTX" ] && exit 1
if [ "$CTX" = "gke1" ]; then
APP_ENV=gke
else
APP_ENV=local
fi
# create namespace for deploying the demo app
APP_NAMESPACE=$(kubectl apply -f istio/envs/${APP_ENV}/namespace.yaml -o name | cut -d '/' -f 2)
if [ -z "$APP_NAMESPACE" ]; then
echo unable to create namespace using env $APP_ENV
exit 1
fi
if [ "$ISTIO" = "0" ]; then
# remove namespace label if Istio is not installed
# otherwise pods will not be run
kubectl label namespace $APP_NAMESPACE istio-injection-
fi
# creating secret for cassandra database
kustomize build . | kubectl apply -n $APP_NAMESPACE -f -
# starting services
start_dashboard
start_customer_v1
start_casa_account_v1
start_casa_account_v2
start_ext_cust_svc
for job in $(jobs -p)
do
wait $job || let "FAIL+=1"
done
if [ "$FAIL" == "0" ]; then
echo $FAIL jobs failed. some features may not work correctly
fi
echo the application services should be ready by now
if [ "$1" == "--load" ]; then
start_load_generator &
fi
kubectl config set-context $CTX --namespace $APP_NAMESPACE
kubectl get pods
# nothing more to do if Istio is not installed
[ "$ISTIO" = "0" ] && exit 1
cd istio
./apply
cd ..
echo
echo sending a test request to endpoint
sleep 3
./ping