forked from google/keytransparency
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·70 lines (57 loc) · 3.94 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
#set -o pipefail
#set -o errexit
#set -o nounset
#set -o xtrace
set -eufx
################################################################################
# Following assumptions are made by this script: #
# * gcloud, docker, and docker-compose is installed #
# * it is called from $GOPATH/src/github.com/google/keytransparency #
# * there is a project called key-transparency on gce which has has gke #
# enabled and a cluster configured; gcloud is already set to this #
# project via: #
# # see gcloud help auth and authenticate, then: #
# gcloud config set project key-transparency #
# gcloud container clusters get-credentials <your-cluster-name> #
# gcloud config set compute/zone <your-compute-zone> #
# #
# See the project's .travis.yml file for a working example. #
# #
################################################################################
export PROJECT_NAME_CI=key-transparency
export CLOUDSDK_COMPUTE_ZONE=us-central1-a
export CLUSTER_NAME_CI=ci-cluster
gcloud --quiet config set project ${PROJECT_NAME_CI}
gcloud --quiet config set compute/zone ${CLOUDSDK_COMPUTE_ZONE}
gcloud --quiet config set container/cluster ${CLUSTER_NAME_CI}
gcloud --quiet container clusters get-credentials ${CLUSTER_NAME_CI}
gcloud --quiet auth configure-docker
echo "Generating keys..."
./scripts/prepare_server.sh -f
# kubectl exits with 1 if kt-secret does not exist
kubectl get secret kt-secrets
if [ $? -ne 0 ]; then
kubectl create secret generic kt-secrets --from-file=genfiles/server.crt --from-file=genfiles/server.key
fi
echo "Building docker images..."
docker-compose build
echo "Pushing docker images..."
docker-compose push
echo "Tagging docker images..."
gcloud --quiet container images add-tag us.gcr.io/${PROJECT_NAME_CI}/prometheus:${TRAVIS_COMMIT} us.gcr.io/${PROJECT_NAME_CI}/prometheus:latest
gcloud --quiet container images add-tag us.gcr.io/${PROJECT_NAME_CI}/log-server:${TRAVIS_COMMIT} us.gcr.io/${PROJECT_NAME_CI}/log-server:latest
gcloud --quiet container images add-tag us.gcr.io/${PROJECT_NAME_CI}/log-signer:${TRAVIS_COMMIT} us.gcr.io/${PROJECT_NAME_CI}/log-signer:latest
gcloud --quiet container images add-tag us.gcr.io/${PROJECT_NAME_CI}/map-server:${TRAVIS_COMMIT} us.gcr.io/${PROJECT_NAME_CI}/map-server:latest
gcloud --quiet container images add-tag us.gcr.io/${PROJECT_NAME_CI}/keytransparency-server:${TRAVIS_COMMIT} us.gcr.io/${PROJECT_NAME_CI}/keytransparency-server:latest
gcloud --quiet container images add-tag us.gcr.io/${PROJECT_NAME_CI}/keytransparency-sequencer:${TRAVIS_COMMIT} us.gcr.io/${PROJECT_NAME_CI}/keytransparency-sequencer:latest
gcloud --quiet container images add-tag us.gcr.io/${PROJECT_NAME_CI}/keytransparency-monitor:${TRAVIS_COMMIT} us.gcr.io/${PROJECT_NAME_CI}/keytransparency-monitor:latest
echo "Updating jobs..."
kubectl apply -f deploy/kubernetes/.
kubectl set image deploy/prometheus prometheus=us.gcr.io/${PROJECT_NAME_CI}/prometheus:${TRAVIS_COMMIT}
kubectl set image deploy/log-server log-server=us.gcr.io/${PROJECT_NAME_CI}/log-server:${TRAVIS_COMMIT}
kubectl set image deploy/log-signer log-signer=us.gcr.io/${PROJECT_NAME_CI}/log-signer:${TRAVIS_COMMIT}
kubectl set image deploy/map-server map-server=us.gcr.io/${PROJECT_NAME_CI}/map-server:${TRAVIS_COMMIT}
kubectl set image deploy/server server=us.gcr.io/${PROJECT_NAME_CI}/keytransparency-server:${TRAVIS_COMMIT}
kubectl set image deploy/sequencer sequencer=us.gcr.io/${PROJECT_NAME_CI}/keytransparency-sequencer:${TRAVIS_COMMIT}
kubectl set image deploy/monitor monitor=us.gcr.io/${PROJECT_NAME_CI}/keytransparency-monitor:${TRAVIS_COMMIT}