-
Notifications
You must be signed in to change notification settings - Fork 51
/
manual-deploy.sh
executable file
·47 lines (39 loc) · 1.46 KB
/
manual-deploy.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
#!/bin/bash
# Clone app
rm -rf _temp-cat-service
git clone https://github.com/booternetes-III-springonetour-july-2021/cat-service _temp-cat-service
cd _temp-cat-service
# Build an publish image
./mvnw spring-boot:build-image \
-DskipTests \
-Dspring-boot.build-image.imageName=gcr.io/pgtm-jlong/cat-service:0.0.1-SNAPSHOT
docker push gcr.io/pgtm-jlong/cat-service:0.0.1-SNAPSHOT
docker tag gcr.io/pgtm-jlong/cat-service:0.0.1-SNAPSHOT gcr.io/pgtm-jlong/cat-service:latest
docker push gcr.io/pgtm-jlong/cat-service:latest
# Create config manifest
kubectl create configmap cat-service-config \
--from-file=src/main/resources/application.properties \
-o yaml --dry-run=client > ../manifests/base/config/configmap.yaml
cd ..
# Deploy to Kubernetes (dev namespace)
kubectl create ns dev
kustomize build --load-restrictor LoadRestrictionsNone manifests/overlays/dev/ | kubectl apply -f -
# Deploy to Kubernetes (prod namespace)
kubectl create ns prod
kustomize build --load-restrictor LoadRestrictionsNone manifests/overlays/prod/ | kubectl apply -f -
# Test the app
echo -e "\nTesting dev-cat-service"
kubectl port-forward service/dev-cat-service 8080:8080 -n dev >/dev/null 2>&1 &
k_pid=$!
sleep 5
http :8080/actuator/health
http :8080/cats/Toby
kill $k_pid
sleep 3
echo -e "\nTesting prod-cat-service"
kubectl port-forward service/prod-cat-service 8080:8080 -n prod >/dev/null 2>&1 &
k_pid=$!
sleep 5
http :8080/actuator/health
http :8080/cats/Toby
kill $k_pid