-
Notifications
You must be signed in to change notification settings - Fork 13
/
helm-deploy-dev-direct.sh
executable file
·77 lines (62 loc) · 1.9 KB
/
helm-deploy-dev-direct.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
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
#!/usr/bin/env bash
##
## Deploy prime directly from workstation
##
DEPENDENCIES="./gradlew docker grep tr awk gcloud helm"
for DEP in ${DEPENDENCIES}; do
if [[ -z "$(which ${DEP})" ]] ; then
echo "$0 ERROR: Missing dependency $DEP"
exit 1
fi
done
# On error fail.
set -e
# Check that the script ss run from project root
# (figure that out by looking for itself :-)
if [[ ! -f prime/script/helm-deploy-dev-direct.sh ]] ; then
(>&2 echo "Run this script from project root dir (ostelco-core)")
exit 1
fi
#
# Use the kubectl context containing the dev-cluster
#
K8S_CONTEXT="$(kubectl config get-contexts --output name | grep pi-ostelco-dev)"
kubectl config use-context ${K8S_CONTEXT}
#
# Get the GCP project id by asking gcloud
#
GCP_PROJECT_ID="$(gcloud config get-value project -q)"
#
# Get the version, sha and tag tat we'll use to
# identify the docker image we're about to deploy.
#
PRIME_VERSION="$(./gradlew prime:properties -q | grep "version:" | awk '{print $2}' | tr -d '[:space:]')"
SHORT_SHA="$(git log -1 --pretty=format:%h)"
TAG="${PRIME_VERSION}-${SHORT_SHA}-dev"
#
# Report what the variables we're using are
#
echo GCP_PROJECT_ID=${GCP_PROJECT_ID}
echo PRIME_VERSION=${PRIME_VERSION}
echo SHORT_SHA=${SHORT_SHA}
echo TAG=${TAG}
#
# Build the prime subproject
#
./gradlew prime:clean prime:build
#
# Build tag and push the docker image
#
docker build -t eu.gcr.io/${GCP_PROJECT_ID}/prime:${TAG} prime
docker push eu.gcr.io/${GCP_PROJECT_ID}/prime:${TAG}
HELM_RELEASE_NAME="prime-direct"
HELM_CHART="ostelco/prime"
HELM_CHART_VERSION="1.0.1"
HELM_VALUES_FILE="prime/infra/prime-direct-values.yaml"
#
# Then deploy using helm.
#
echo "Deploying prime-direct to GKE"
helm repo add ostelco https://storage.googleapis.com/pi-ostelco-helm-charts-repo/
helm repo update
helm upgrade ${HELM_RELEASE_NAME} ${HELM_CHART} --version ${HELM_CHART_VERSION} --install -f ${HELM_VALUES_FILE} --set prime.tag=${TAG}