...
1#!/usr/bin/env bash
2#set -o pipefail
3#set -o errexit
4#set -o nounset
5#set -o xtrace
6
7function checkEnv() {
8 if [ -z ${PROJECT_ID+x} ] ||
9 [ -z ${CLUSTER_NAME+x} ] ||
10 [ -z ${MASTER_ZONE+x} ]; then
11 echo "You must either pass an argument which is a config file, or set all the required environment variables"
12 exit 1
13 fi
14}
15
16set -e
17
18DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
19if [ $# -eq 1 ]; then
20 source $1
21else
22 checkEnv
23fi
24
25export IMAGE_TAG=${IMAGE_TAG:-$(git rev-parse HEAD)}
26
27gcloud --quiet config set project ${PROJECT_ID}
28gcloud --quiet config set container/cluster ${CLUSTER_NAME}
29gcloud --quiet config set compute/zone ${MASTER_ZONE}
30gcloud --quiet container clusters get-credentials ${CLUSTER_NAME}
31
32configmaps=$(kubectl get configmaps)
33if [[ ! "${configmaps}" =~ "ctfe-configmap" ]]; then
34 echo "Missing ctfe config map."
35 echo
36 echo "Ensure you have a PEM file containing all the roots your log should accept."
37 echo "and a working CTFE configuration file, then create a CTFE configmap by"
38 echo "running the following command:"
39 echo " kubectl create configmap ctfe-configmap \\"
40 echo " --from-file=roots=path/to/all-roots.pem \\"
41 echo " --from-file=ctfe-config-file=path/to/ct_server.cfg \\"
42 echo " --from-literal=cloud-project=${PROJECT_ID}"
43 echo
44 echo "Once you've created the configmap, re-run this script"
45 exit 1
46fi
47
48
49echo "Building docker images.."
50cd $GOPATH/src/github.com/google/certificate-transparency-go
51docker build --quiet -f trillian/examples/deployment/docker/ctfe/Dockerfile -t gcr.io/${PROJECT_ID}/ctfe:${IMAGE_TAG} .
52
53echo "Pushing docker image..."
54gcloud docker -- push gcr.io/${PROJECT_ID}/ctfe:${IMAGE_TAG}
55
56echo "Tagging docker image..."
57gcloud --quiet container images add-tag gcr.io/${PROJECT_ID}/ctfe:${IMAGE_TAG} gcr.io/${PROJECT_ID}/ctfe:latest
58
59echo "Updating jobs..."
60envsubst < trillian/examples/deployment/kubernetes/ctfe-deployment.yaml | kubectl apply -f -
61envsubst < trillian/examples/deployment/kubernetes/ctfe-service.yaml | kubectl apply -f -
62envsubst < trillian/examples/deployment/kubernetes/ctfe-ingress.yaml | kubectl apply -f -
63
64echo "CTFE is available at:"
65kubectl get ingress
View as plain text