ci: add kubernetes helm chart and gcp deployment (#1854)

* ci: add kubernetes helm chart and gcp deployment

* use official or parity's docker images only
This commit is contained in:
gabriel klawitter
2019-02-27 12:37:10 +01:00
committed by GitHub
parent 5282615416
commit f5c32f71f4
11 changed files with 425 additions and 37 deletions
+91 -29
View File
@@ -7,7 +7,7 @@ stages:
- test
- build
- publish
- label
- deploy
image: parity/rust:nightly
@@ -20,11 +20,7 @@ variables:
cache:
key: "${CI_JOB_NAME}"
paths:
- ${CARGO_HOME}
- ./target
cache: {}
.collect_artifacts: &collect_artifacts
artifacts:
@@ -36,14 +32,21 @@ cache:
.kubernetes_build: &kubernetes_build
tags:
- kubernetes-parity-build
environment:
name: parity-build
#### stage: merge-test
check:merge:conflict:
stage: merge-test
image: parity/tools:latest
cache: {}
tags:
- linux-docker
<<: *kubernetes_build
only:
- /^[0-9]+$/
variables:
@@ -62,8 +65,7 @@ check:runtime:
stage: test
image: parity/tools:latest
cache: {}
tags:
- linux-docker
<<: *kubernetes_build
only:
- /^[0-9]+$/
variables:
@@ -77,25 +79,29 @@ check:runtime:
test:rust:stable: &test
stage: test
cache:
key: "${CI_JOB_NAME}-test"
paths:
- ${CARGO_HOME}
- ./target
variables:
RUST_TOOLCHAIN: stable
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: -Cdebug-assertions=y
TARGET: native
tags:
- linux-docker
only:
- tags
- master
- schedules
- web
- /^pr-[0-9]+$/
- /^[0-9]+$/
tags:
- linux-docker
before_script:
- test -d ${CARGO_HOME} -a -d ./target &&
- test -d ${CARGO_HOME} -a -d ./target &&
echo "build cache size:" &&
du -hs ${CARGO_HOME} ./target
du -h --max-depth=2 ${CARGO_HOME} ./target
- ./scripts/build.sh
script:
- time cargo test --all --release --verbose --locked
@@ -115,6 +121,11 @@ test:rust:stable: &test
build:rust:linux:release: &build
stage: build
cache:
key: "${CI_JOB_NAME}-build"
paths:
- ${CARGO_HOME}
- ./target
<<: *collect_artifacts
<<: *build_only
tags:
@@ -126,15 +137,17 @@ build:rust:linux:release: &build
- mkdir -p ./artifacts
- mv ./target/release/substrate ./artifacts/.
- echo -n "Substrate version = "
- if [ "${CI_COMMIT_TAG}" ]; then
- if [ "${CI_COMMIT_TAG}" ]; then
echo "${CI_COMMIT_TAG}" | tee ./artifacts/VERSION;
else
else
./artifacts/substrate --version |
sed -n -r 's/^substrate ([0-9.]+.*-[0-9a-f]{7,13})-.*$/\1/p' |
tee ./artifacts/VERSION;
fi
- sha256sum ./artifacts/substrate | tee ./artifacts/substrate.sha256
- echo "\n# building node-template\n"
- ./scripts/node-template-release.sh ./artifacts/substrate-node-template.tar.gz
- cp -r scripts/docker/* ./artifacts
@@ -167,16 +180,20 @@ build:rust:doc:release: &build
- build:rust:linux:release
cache: {}
<<: *build_only
<<: *kubernetes_build
publish:docker:release:
<<: *publish_build
tags:
- shell
image: docker:stable
services:
- docker:dind
variables:
DOCKER_HOST: tcp://localhost:2375
DOCKER_DRIVER: overlay2
GIT_STRATEGY: none
DOCKERFILE: scripts/docker/Dockerfile
# DOCKERFILE: scripts/docker/Dockerfile
CONTAINER_IMAGE: parity/substrate
script:
- VERSION="$(cat ./artifacts/VERSION)"
@@ -184,7 +201,8 @@ publish:docker:release:
|| ( echo "no docker credentials provided"; exit 1 )
- docker login -u "$Docker_Hub_User_Parity" -p "$Docker_Hub_Pass_Parity"
- docker info
- docker build --tag $CONTAINER_IMAGE:$VERSION --tag $CONTAINER_IMAGE:latest -f $DOCKERFILE ./artifacts/
- cd ./artifacts
- docker build --tag $CONTAINER_IMAGE:$VERSION --tag $CONTAINER_IMAGE:latest .
- docker push $CONTAINER_IMAGE:$VERSION
- docker push $CONTAINER_IMAGE:latest
after_script:
@@ -213,8 +231,6 @@ publish:s3:release:
after_script:
- aws s3 ls s3://${BUCKET}/${PREFIX}/latest/
--recursive --human-readable --summarize
tags:
- linux-docker
@@ -223,11 +239,8 @@ publish:s3:doc:
dependencies:
- build:rust:doc:release
cache: {}
only:
- master
- tags
- web
- publish-rustdoc
<<: *build_only
<<: *kubernetes_build
variables:
GIT_STRATEGY: none
BUCKET: "releases.parity.io"
@@ -242,10 +255,59 @@ publish:s3:doc:
after_script:
- aws s3 ls s3://${BUCKET}/${PREFIX}/
--human-readable --summarize
.deploy:template: &deploy
stage: deploy
when: manual
cache: {}
retry: 1
image: parity/kubectl-helm:$HELM_VERSION
<<: *build_only
# variables:
# DEPLOY_TAG: "latest"
tags:
- linux-docker
- kubernetes-parity-build
before_script:
- test -z "${DEPLOY_TAG}" &&
test -f ./target/release/VERSION &&
DEPLOY_TAG="$(cat ./target/release/VERSION)"
- test "${DEPLOY_TAG}" || ( echo "Neither DEPLOY_TAG nor VERSION information available"; exit 1 )
script:
- echo "Substrate version = ${DEPLOY_TAG}"
# or use helm to render the template
- helm template
--values ./scripts/kubernetes/values.yaml
--set image.tag=${DEPLOY_TAG}
--set validator.keys=${VALIDATOR_KEYS}
./scripts/kubernetes | kubectl apply -f - --dry-run=false
- echo "# substrate namespace"
- kubectl -n substrate get all
- echo "# substrate's nodes' external ip addresses:"
- kubectl get nodes -l node=substrate
-o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{range @.status.addresses[?(@.type=="ExternalIP")]}{.address}{"\n"}{end}'
- echo "# substrate' nodes"
- kubectl -n substrate get pods
-o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}'
# have environment:url eventually point to the logs
deploy:ew3:
<<: *deploy
environment:
name: parity-prod-ew3
deploy:ue1:
<<: *deploy
environment:
name: parity-prod-ue1