Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Commit

Permalink
Test against fresh builds (#1420)
Browse files Browse the repository at this point in the history
* load docker-image into kind

* Set build tags

* docker parallel build

* uncomment docker build

* Use kustomize in deploy scripts

* Install kustomize
  • Loading branch information
gdbelvin committed Jan 2, 2020
1 parent 2fbe72e commit e5421fb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -40,6 +40,7 @@ jobs:
- name: "kubernetes test"
install:
- curl -LO "https://storage.googleapis.com/kubernetes-release/release/v1.16.3/bin/linux/amd64/kubectl" && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash && sudo mv kustomize /usr/local/bin/
- go get sigs.k8s.io/kind@v0.6.1
- kind create cluster --config deploy/kubernetes/kind-config.yaml
- kubectl cluster-info --context kind-kind
Expand All @@ -49,6 +50,7 @@ jobs:
if: branch = master AND type != pull_request
install:
- curl -LO "https://storage.googleapis.com/kubernetes-release/release/v1.16.3/bin/linux/amd64/kubectl" && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash && sudo mv kustomize /usr/local/bin/
- openssl aes-256-cbc -K $encrypted_555d9b2948d2_key -iv $encrypted_555d9b2948d2_iv
-in client_secrets.json.enc -d | gcloud auth activate-service-account --key-file /dev/stdin
script: ./scripts/deploy.sh
Expand Down
16 changes: 7 additions & 9 deletions scripts/deploy.sh
Expand Up @@ -45,8 +45,7 @@ if ! kubectl get secret kt-secrets; then
fi

echo "Building docker images..."
docker-compose build

docker-compose build --parallel

echo "Pushing docker images..."
docker-compose push
Expand All @@ -59,11 +58,10 @@ gcloud --quiet container images add-tag gcr.io/${PROJECT_NAME_CI}/keytransparenc


echo "Updating jobs..."
cd deploy/kubernetes/base
kustomize edit set image gcr.io/${PROJECT_NAME_CI}/prometheus:${TRAVIS_COMMIT}
kustomize edit set image gcr.io/${PROJECT_NAME_CI}/keytransparency-monitor:${TRAVIS_COMMIT}
kustomize edit set image gcr.io/${PROJECT_NAME_CI}/keytransparency-sequencer:${TRAVIS_COMMIT}
kustomize edit set image gcr.io/${PROJECT_NAME_CI}/keytransparency-server:${TRAVIS_COMMIT}
cd -
kubectl apply -k deploy/kubernetes/overlays/gke
kubectl set image deploy/prometheus prometheus=gcr.io/${PROJECT_NAME_CI}/prometheus:${TRAVIS_COMMIT}
kubectl set image deploy/log-server log-server=gcr.io/${PROJECT_NAME_CI}/log-server:${TRAVIS_COMMIT}
kubectl set image deploy/log-signer log-signer=gcr.io/${PROJECT_NAME_CI}/log-signer:${TRAVIS_COMMIT}
kubectl set image deploy/map-server map-server=gcr.io/${PROJECT_NAME_CI}/map-server:${TRAVIS_COMMIT}
kubectl set image deploy/server server=gcr.io/${PROJECT_NAME_CI}/keytransparency-server:${TRAVIS_COMMIT}
kubectl set image deploy/sequencer sequencer=gcr.io/${PROJECT_NAME_CI}/keytransparency-sequencer:${TRAVIS_COMMIT}
kubectl set image deploy/monitor monitor=gcr.io/${PROJECT_NAME_CI}/keytransparency-monitor:${TRAVIS_COMMIT}
1 change: 1 addition & 0 deletions scripts/docker-compose_test.sh
Expand Up @@ -6,6 +6,7 @@ if [ ! -f genfiles/server.key ]; then
./scripts/prepare_server.sh -f
fi

docker-compose build --parallel
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
trap "docker-compose down" INT EXIT

Expand Down
14 changes: 13 additions & 1 deletion scripts/kubernetes_test.sh
Expand Up @@ -7,6 +7,19 @@ set -o pipefail
# kind create cluster --config deploy/kubernetes/kind-config.yaml
# kubectl cluster-info --context kind-kind

# Build docker images and make them available inside of the k8 cluster
export TRAVIS_COMMIT=${TRAVIS_COMMIT:-$(git rev-parse HEAD)}
docker-compose build --parallel
kind load docker-image gcr.io/key-transparency/keytransparency-monitor:${TRAVIS_COMMIT}
kind load docker-image gcr.io/key-transparency/keytransparency-sequencer:${TRAVIS_COMMIT}
kind load docker-image gcr.io/key-transparency/keytransparency-server:${TRAVIS_COMMIT}

cd deploy/kubernetes/base
kustomize edit set image gcr.io/key-transparency/keytransparency-monitor:${TRAVIS_COMMIT}
kustomize edit set image gcr.io/key-transparency/keytransparency-sequencer:${TRAVIS_COMMIT}
kustomize edit set image gcr.io/key-transparency/keytransparency-server:${TRAVIS_COMMIT}
cd -

# kubectl exits with 1 if kt-secret does not exist
if ! kubectl get secret kt-secrets; then
echo "Generating keys..."
Expand All @@ -18,7 +31,6 @@ fi
# Hack to wait for the default service account's creation. https://github.com/kubernetes/kubernetes/issues/66689
n=0; until ((n >= 60)); do kubectl -n default get serviceaccount default -o name && break; n=$((n + 1)); sleep 1; done; ((n < 60))


kubectl apply -k deploy/kubernetes/overlays/local
trap "kubectl delete -k deploy/kubernetes/overlays/local" INT EXIT
TIMEOUT=2m
Expand Down

0 comments on commit e5421fb

Please sign in to comment.