Skip to content

Commit

Permalink
[artifacts] Deploy Cloud image (#129650) (#130189)
Browse files Browse the repository at this point in the history
* [artifacts] Publish release artifacts

This adds the publish step to the release pipeline, which uses the
release-manager CLI to upload a list Kibana artifacts.

* cleanup

* [artifacts] Test cloud image

* tmp skip unrelated steps

* build cloud artifact

* fix tag

* add missing artifacts

* enable rm

* fix syntax

* fix tag

* fix artifact

* fix variable

* source utils

* fix path

* fix version

* skip steps

* re-add pipeline steps

* set permissions

* Update .buildkite/scripts/steps/artifacts/publish.sh

Co-authored-by: Chris <[email protected]>

* Revert "Update .buildkite/scripts/steps/artifacts/publish.sh"

This reverts commit a6228f5.

* export

* support version qualifier

* setup env

* cleanup

* consistency

* \n

* comment

* unneccessary fallback

* +x

* hoist env args

* source

* link to artifacts

* fix artifacts summary

* relax docker glob

* \n

* fix summary

* fix variable

* rm es docker image

* setup cloud env

* rename deployment

* exclude skipCloud

* only run on snapshot builds

* update step name

* TEST_BROWSER_HEADLESS=1

* cleanup

* newline

* consistency

* pass deployment id

Co-authored-by: Chris <[email protected]>
(cherry picked from commit 482ae8a)

Co-authored-by: Jonathan Budzenski <[email protected]>
  • Loading branch information
kibanamachine and jbudz authored Apr 13, 2022
1 parent c403510 commit de9c565
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .buildkite/pipelines/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ steps:
queue: n2-2
timeout_in_minutes: 30

- command: .buildkite/scripts/steps/artifacts/cloud.sh
label: 'Cloud Deployment'
agents:
queue: n2-2
timeout_in_minutes: 30
if: "build.env('RELEASE_BUILD') == null || build.env('RELEASE_BUILD') == '' || build.env('RELEASE_BUILD') == 'false'"

- wait

- command: .buildkite/scripts/steps/artifacts/publish.sh
Expand Down
81 changes: 81 additions & 0 deletions .buildkite/scripts/steps/artifacts/cloud.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

set -euo pipefail

.buildkite/scripts/bootstrap.sh

source .buildkite/scripts/steps/artifacts/env.sh

echo "--- Publish Cloud image"
mkdir -p target
cd target

buildkite-agent artifact download "kibana-cloud-$FULL_VERSION-docker-image.tar.gz" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
docker load --input kibana-cloud-$FULL_VERSION-docker-image.tar.gz

TAG="$FULL_VERSION-$GIT_COMMIT"
KIBANA_BASE_IMAGE="docker.elastic.co/kibana-ci/kibana-cloud:$FULL_VERSION"
KIBANA_TEST_IMAGE="docker.elastic.co/kibana-ci/kibana-cloud:$TAG"

docker tag "$KIBANA_BASE_IMAGE" "$KIBANA_TEST_IMAGE"

echo "$KIBANA_DOCKER_PASSWORD" | docker login -u "$KIBANA_DOCKER_USERNAME" --password-stdin docker.elastic.co
trap 'docker logout docker.elastic.co' EXIT

docker push "$KIBANA_TEST_IMAGE"
docker logout docker.elastic.co

cd -

echo "--- Create deployment"
CLOUD_DEPLOYMENT_NAME="kibana-artifacts-$TAG"

LOGS=$(mktemp --suffix ".json")
DEPLOYMENT_SPEC=$(mktemp --suffix ".json")

jq '
.name = "'$CLOUD_DEPLOYMENT_NAME'" |
.resources.kibana[0].plan.kibana.docker_image = "'$KIBANA_TEST_IMAGE'" |
.resources.kibana[0].plan.kibana.version = "'$FULL_VERSION'" |
.resources.elasticsearch[0].plan.elasticsearch.version = "'$FULL_VERSION'" |
.resources.enterprise_search[0].plan.enterprise_search.version = "'$FULL_VERSION'" |
.resources.integrations_server[0].plan.integrations_server.version = "'$FULL_VERSION'"
' .buildkite/scripts/steps/cloud/deploy.json > "$DEPLOYMENT_SPEC"

ecctl deployment create --track --output json --file "$DEPLOYMENT_SPEC" &> "$LOGS"
CLOUD_DEPLOYMENT_USERNAME=$(jq --slurp '.[]|select(.resources).resources[] | select(.credentials).credentials.username' "$LOGS")
CLOUD_DEPLOYMENT_PASSWORD=$(jq --slurp '.[]|select(.resources).resources[] | select(.credentials).credentials.password' "$LOGS")
CLOUD_DEPLOYMENT_ID=$(jq -r --slurp '.[0].id' "$LOGS")
CLOUD_DEPLOYMENT_STATUS_MESSAGES=$(jq --slurp '[.[]|select(.resources == null)]' "$LOGS")

CLOUD_DEPLOYMENT_KIBANA_URL=$(ecctl deployment show "$CLOUD_DEPLOYMENT_ID" | jq -r '.resources.kibana[0].info.metadata.aliased_url')
CLOUD_DEPLOYMENT_ELASTICSEARCH_URL=$(ecctl deployment show "$CLOUD_DEPLOYMENT_ID" | jq -r '.resources.elasticsearch[0].info.metadata.aliased_url')

# NOTE: disabled pending log sanitization
# echo "--- Setup FTR"
# export TEST_KIBANA_PROTOCOL=$(node -e "console.log(new URL('$CLOUD_DEPLOYMENT_KIBANA_URL').protocol)")
# export TEST_KIBANA_HOSTNAME=$(node -e "console.log(new URL('$CLOUD_DEPLOYMENT_KIBANA_URL').hostname)")
# export TEST_KIBANA_PORT=$(node -e "console.log(new URL('$CLOUD_DEPLOYMENT_KIBANA_URL').port)")
# export TEST_KIBANA_USERNAME=$CLOUD_DEPLOYMENT_USERNAME"
# export TEST_KIBANA_PASS=$CLOUD_DEPLOYMENT_PASSWORD"

# export TEST_ES_PROTOCOL=$(node -e "console.log(new URL('$CLOUD_DEPLOYMENT_KIBANA_URL').protocol)")
# export TEST_ES_HOSTNAME==$(node -e "console.log(new URL('$CLOUD_DEPLOYMENT_KIBANA_URL').hostname)")
# export TEST_ES_PORT=$(node -e "console.log(new URL('$CLOUD_DEPLOYMENT_KIBANA_URL').port)")
# export TEST_ES_USER="$CLOUD_DEPLOYMENT_USERNAME"
# export TEST_ES_PASS="$CLOUD_DEPLOYMENT_PASSWORD"

# export TEST_BROWSER_HEADLESS=1

# Error: attempted to use the "es" service to fetch Elasticsearch version info but the request failed: ConnectionError: self signed certificate in certificate chain
# export NODE_TLS_REJECT_UNAUTHORIZED=0

# echo "--- Run default functional tests"
# node --no-warnings scripts/functional_test_runner.js --include-tag=cloud -exclude-tag=skipCloud

# echo "--- Run x-pack functional tests"
# cd x-pack
# node --no-warnings scripts/functional_test_runner.js --include-tag=cloud -exclude-tag=skipCloud

echo "--- Shutdown deployment"
ecctl deployment shutdown "$CLOUD_DEPLOYMENT_ID" --force --track --output json &> "$LOGS"

0 comments on commit de9c565

Please sign in to comment.