-
Notifications
You must be signed in to change notification settings - Fork 452
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·74 lines (61 loc) · 2.51 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·74 lines (61 loc) · 2.51 KB
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
#!/usr/bin/env bash
# Script assumptions:
# - Cluster has already been created & configured using the create.sh script
# - Go 1.9 is installed
function checkEnv() {
if [ -z ${PROJECT_ID+x} ] ||
[ -z ${CLUSTER_NAME+x} ] ||
[ -z ${MASTER_ZONE+x} ] ||
[ -z ${CONFIGMAP+x} ]; then
echo "You must either pass an argument which is a config file, or set all the required environment variables" >&2
exit 1
fi
}
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ $# -eq 1 ]; then
source $1
else
checkEnv
fi
# if IMAGE_TAG is unset, we'll create one using the git HEAD hash, with an
# optional "-dirty" suffix if any objects have been modified.
GIT_HASH=$(git rev-parse HEAD)
GIT_DIRTY=$(git diff --quiet || echo '-dirty')
export IMAGE_TAG=${IMAGE_TAG:-${GIT_HASH}${GIT_DIRTY}}
# Connect to gcloud
gcloud --quiet config set project ${PROJECT_ID}
gcloud --quiet config set container/cluster ${CLUSTER_NAME}
gcloud --quiet config set compute/zone ${MASTER_ZONE}
gcloud --quiet container clusters get-credentials ${CLUSTER_NAME}
# Configure Docker to use gcloud credentials with Google Container Registry
gcloud auth configure-docker
# Get Trillian
go get github.com/google/trillian/...
cd $GOPATH/src/github.com/google/trillian
images="log_server log_signer"
echo "Building and pushing docker images: ${images}"
for thing in ${images}; do
echo " - ${thing}"
docker build --quiet -f examples/deployment/docker/${thing}/Dockerfile -t gcr.io/$PROJECT_ID/${thing}:$IMAGE_TAG .
docker push gcr.io/${PROJECT_ID}/${thing}:${IMAGE_TAG}
gcloud --quiet container images add-tag gcr.io/${PROJECT_ID}/${thing}:${IMAGE_TAG} gcr.io/${PROJECT_ID}/${thing}:latest
done
if [[ "${NAMESPACE}" != "default" ]]; then
# Create the namespace if it doesn't already exist.
kubectl create namespace "${NAMESPACE}" --dry-run -o=yaml | kubectl apply -f -
# Enable Istio sidecar injection.
kubectl label namespace "${NAMESPACE}" istio-injection=enabled
fi
echo "Updating jobs..."
# Prepare configmap:
kubectl delete --namespace="${NAMESPACE}" configmap deploy-config || true
envsubst < ${CONFIGMAP} | kubectl create --namespace="${NAMESPACE}" -f -
# Launch with kubernetes
kubeconfigs="trillian-log-deployment.yaml trillian-log-service.yaml trillian-log-signer-deployment.yaml trillian-log-signer-service.yaml"
for thing in ${kubeconfigs}; do
echo ${thing}
envsubst < ${DIR}/${thing} | kubectl apply --namespace="${NAMESPACE}" -f -
done
kubectl get all --namespace="${NAMESPACE}"
kubectl get services --namespace="${NAMESPACE}"