-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-gcp.sh
executable file
·52 lines (43 loc) · 1.24 KB
/
deploy-gcp.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
#!/bin/bash -eu
if [ "$(uname)" == 'Darwin' ]; then
SED_I=(sed -i '.bak')
else
SED_I=(sed -i)
fi
if [ "`git rev-parse --abbrev-ref HEAD`" == 'release' ]; then
echo "Start deploy to [Production]"
TAG=`git describe --tags`
NGINX_SERVICE_TYPE='NodePort'
else
echo "Start deploy to [Staging]"
TAG="`git rev-parse --short HEAD`-stg"
NGINX_SERVICE_TYPE='LoadBalancer'
fi
echo '------------------------------'
echo "Tag: $TAG"
echo '------------------------------'
#
# Build docker images and push to GCR
#
./web/deploy-docker-image.sh $TAG
./nginx/deploy-docker-image.sh $TAG
#
# Apply k8s configurations
#
# mongo
kubectl apply -f ./mongo/mongo-volumeclaim.yaml
kubectl apply -f ./mongo/mongo-replicaset.yaml
kubectl apply -f ./mongo/mongo-service.yaml
# web
${SED_I[@]} "s/{{TAG}}/$TAG/" ./web/web-deployment.yaml
kubectl apply -f ./web/web-deployment.yaml
kubectl apply -f ./web/web-service.yaml
# nginx
${SED_I[@]} "s/{{TAG}}/$TAG/" ./nginx/nginx-deployment.yaml
${SED_I[@]} "s/{{TYPE}}/$NGINX_SERVICE_TYPE/" ./nginx/nginx-service.yaml
kubectl apply -f ./nginx/nginx-deployment.yaml
kubectl apply -f ./nginx/nginx-service.yaml
# ingress
if [ "$NGINX_SERVICE_TYPE" == 'NodePort' ]; then
kubectl apply -f ./nginx/ingress.yaml
fi