Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[artifacts] Deploy Cloud image #129650

Merged
merged 53 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7a26474
[artifacts] Publish release artifacts
jbudz Apr 5, 2022
0b35909
cleanup
jbudz Apr 5, 2022
e996758
[artifacts] Test cloud image
jbudz Apr 6, 2022
b941a5a
tmp skip unrelated steps
jbudz Apr 6, 2022
ba3bdac
build cloud artifact
jbudz Apr 6, 2022
5a1de47
fix tag
jbudz Apr 6, 2022
e812256
add missing artifacts
jbudz Apr 6, 2022
63bf201
enable rm
jbudz Apr 6, 2022
8e9c670
fix syntax
jbudz Apr 6, 2022
4baf37a
fix tag
jbudz Apr 6, 2022
148c9de
fix artifact
jbudz Apr 6, 2022
7729686
fix variable
jbudz Apr 7, 2022
f19df7b
source utils
jbudz Apr 7, 2022
04f99e9
fix path
jbudz Apr 7, 2022
24e45c6
fix version
jbudz Apr 7, 2022
57031a1
skip steps
jbudz Apr 7, 2022
56b6fdd
re-add pipeline steps
jbudz Apr 7, 2022
8df0b23
set permissions
jbudz Apr 7, 2022
a6228f5
Update .buildkite/scripts/steps/artifacts/publish.sh
jbudz Apr 7, 2022
eb271e4
Revert "Update .buildkite/scripts/steps/artifacts/publish.sh"
jbudz Apr 7, 2022
9b39eac
export
jbudz Apr 7, 2022
c84c795
Merge branch 'main' into artifacts/release
jbudz Apr 11, 2022
482625d
support version qualifier
jbudz Apr 11, 2022
8fe3099
setup env
jbudz Apr 11, 2022
9cde7a4
cleanup
jbudz Apr 11, 2022
25165df
consistency
jbudz Apr 11, 2022
b70d19d
\n
jbudz Apr 11, 2022
87035b4
comment
jbudz Apr 11, 2022
6183eef
unneccessary fallback
jbudz Apr 11, 2022
0b9c997
+x
jbudz Apr 11, 2022
2466e7d
hoist env args
jbudz Apr 11, 2022
cf99ad7
source
jbudz Apr 11, 2022
37448ca
link to artifacts
jbudz Apr 11, 2022
82cc0f9
fix artifacts summary
jbudz Apr 11, 2022
338de07
relax docker glob
jbudz Apr 11, 2022
c988f4d
\n
jbudz Apr 11, 2022
33250f8
fix summary
jbudz Apr 11, 2022
cfb6442
fix variable
jbudz Apr 11, 2022
d748f07
Merge branch 'main' into artifacts/cloud-testing
jbudz Apr 12, 2022
9fd8233
rm es docker image
jbudz Apr 12, 2022
a634d44
setup cloud env
jbudz Apr 12, 2022
8ff4fe8
rename deployment
jbudz Apr 12, 2022
3cf9db6
exclude skipCloud
jbudz Apr 12, 2022
4c5996e
only run on snapshot builds
jbudz Apr 12, 2022
477f6df
update step name
jbudz Apr 12, 2022
fcfa52c
TEST_BROWSER_HEADLESS=1
jbudz Apr 12, 2022
7cedcce
cleanup
jbudz Apr 12, 2022
62deac4
newline
jbudz Apr 12, 2022
f691823
Merge branch 'artifacts/release' into artifacts/cloud-testing
jbudz Apr 12, 2022
f47e6b4
consistency
jbudz Apr 12, 2022
76cd664
Merge branch 'main' into artifacts/cloud-testing
jbudz Apr 12, 2022
5a3a3c6
pass deployment id
jbudz Apr 12, 2022
8935c94
Merge branch 'main' into artifacts/cloud-testing
jbudz Apr 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .buildkite/pipelines/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,40 @@ steps:
- wait

- command: TEST_PACKAGE=deb .buildkite/scripts/steps/package_testing/test.sh
label: Package testing for deb
label: Artifact Testing
agents:
queue: n2-4-virt
timeout_in_minutes: 20
timeout_in_minutes: 30

- command: TEST_PACKAGE=rpm .buildkite/scripts/steps/package_testing/test.sh
label: Package testing for rpm
label: Artifact Testing
agents:
queue: n2-4-virt
timeout_in_minutes: 20
timeout_in_minutes: 30

- command: TEST_PACKAGE=docker .buildkite/scripts/steps/package_testing/test.sh
label: Package testing for docker
label: Artifact Testing
agents:
queue: n2-4-virt
timeout_in_minutes: 20
timeout_in_minutes: 30

- command: .buildkite/scripts/steps/artifacts/docker_context.sh
label: 'Docker Build Context'
label: 'Docker Context Verification'
agents:
queue: n2-2
timeout_in_minutes: 20
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
label: 'Publish Kibana Artifacts'
agents:
queue: n2-2
timeout_in_minutes: 30
44 changes: 7 additions & 37 deletions .buildkite/scripts/steps/artifacts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,14 @@ set -euo pipefail

.buildkite/scripts/bootstrap.sh

if [[ "${RELEASE_BUILD:-}" == "true" ]]; then
VERSION="$(jq -r '.version' package.json)"
RELEASE_ARG="--release"
else
VERSION="$(jq -r '.version' package.json)-SNAPSHOT"
RELEASE_ARG=""
fi
source .buildkite/scripts/steps/artifacts/env.sh

echo "--- Build Kibana Distribution"
node scripts/build "$RELEASE_ARG" --all-platforms --debug --docker-cross-compile --skip-docker-cloud

echo "--- Build dependencies report"
node scripts/licenses_csv_report "--csv=target/dependencies-$VERSION.csv"

# Release verification
if [[ "${RELEASE_BUILD:-}" == "true" ]]; then
echo "--- Build and push Kibana Cloud Distribution"
# This doesn't meet the requirements for a release image, implementation TBD
# Beats artifacts will need to match a specific commit sha that matches other stack iamges
# For now this is a placeholder step that will allow us to run automated Cloud tests
# against a best guess approximation of a release image
echo "$KIBANA_DOCKER_PASSWORD" | docker login -u "$KIBANA_DOCKER_USERNAME" --password-stdin docker.elastic.co
trap 'docker logout docker.elastic.co' EXIT

node scripts/build \
"$RELEASE_ARG" \
--skip-initialize \
--skip-generic-folders \
--skip-platform-folders \
--skip-archives \
--docker-images \
--docker-tag-qualifier="$GIT_COMMIT" \
--docker-push \
--skip-docker-ubi \
--skip-docker-ubuntu \
--skip-docker-contexts
fi
echo "--- Build Kibana artifacts"
node scripts/build --all-platforms --debug --docker-cross-compile $(echo "$BUILD_ARGS")

echo "--- Build and upload dependencies report"
node scripts/licenses_csv_report "--csv=target/dependencies-$FULL_VERSION.csv"
cd target
sha512sum "dependencies-$FULL_VERSION.csv" > "dependencies-$FULL_VERSION.csv.sha512.txt"
buildkite-agent artifact upload "*"
cd -
cd -
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"
12 changes: 3 additions & 9 deletions .buildkite/scripts/steps/artifacts/docker_context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,19 @@ set -euo pipefail

.buildkite/scripts/bootstrap.sh

if [[ "${RELEASE_BUILD:-}" == "true" ]]; then
VERSION="$(jq -r '.version' package.json)"
RELEASE_ARG="--release"
else
VERSION="$(jq -r '.version' package.json)-SNAPSHOT"
RELEASE_ARG=""
fi
source .buildkite/scripts/steps/artifacts/env.sh

echo "--- Create contexts"
mkdir -p target
node scripts/build "$RELEASE_ARG" --skip-initialize --skip-generic-folders --skip-platform-folders --skip-archives --docker-context-use-local-artifact
node scripts/build --skip-initialize --skip-generic-folders --skip-platform-folders --skip-archives --docker-context-use-local-artifact $(echo "$BUILD_ARGS")

echo "--- Setup default context"
DOCKER_BUILD_FOLDER=$(mktemp -d)

tar -xf target/kibana-[0-9]*-docker-build-context.tar.gz -C "$DOCKER_BUILD_FOLDER"
cd $DOCKER_BUILD_FOLDER

buildkite-agent artifact download "kibana-$VERSION-linux-x86_64.tar.gz" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
buildkite-agent artifact download "kibana-$FULL_VERSION-linux-x86_64.tar.gz" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"

echo "--- Build context"
docker build .
34 changes: 34 additions & 0 deletions .buildkite/scripts/steps/artifacts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -euo pipefail

RELEASE_BUILD="${RELEASE_BUILD:="false"}"
VERSION_QUALIFIER="${VERSION_QUALIFIER:=""}"

BASE_VERSION="$(jq -r '.version' package.json)"

if [[ "$VERSION_QUALIFIER" == "" ]]; then
QUALIFIER_VERSION="$BASE_VERSION"
else
QUALIFIER_VERSION="$BASE_VERSION-$VERSION_QUALIFIER"
fi

if [[ "$RELEASE_BUILD" == "true" ]]; then
FULL_VERSION="$QUALIFIER_VERSION"

# Beats artifacts will need to match a specific commit sha that matches other stack images
# for release builds. For now we are skipping Cloud builds until there's a pointer.
BUILD_ARGS="--release --skip-docker-cloud --version-qualifier=$VERSION_QUALIFIER"
WORKFLOW="staging"
else
FULL_VERSION="$QUALIFIER_VERSION-SNAPSHOT"
BUILD_ARGS="--version-qualifier=$VERSION_QUALIFIER"
WORKFLOW="snapshot"
fi

export VERSION_QUALIFIER
export BASE_VERSION
export QUALIFIER_VERSION
export FULL_VERSION
export BUILD_ARGS
export WORKFLOW
80 changes: 80 additions & 0 deletions .buildkite/scripts/steps/artifacts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash

set -euo pipefail

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

echo "--- Download and verify artifacts"
function download {
buildkite-agent artifact download "$1" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
buildkite-agent artifact download "$1.sha512.txt" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
sha512sum -c "$1.sha512.txt"
rm "$1.sha512.txt"
}

mkdir -p target
cd target

download "kibana-$FULL_VERSION-docker-image.tar.gz"
download "kibana-$FULL_VERSION-docker-image-aarch64.tar.gz"
download "kibana-ubi8-$FULL_VERSION-docker-image.tar.gz"

download "kibana-$FULL_VERSION-arm64.deb"
download "kibana-$FULL_VERSION-amd64.deb"
download "kibana-$FULL_VERSION-x86_64.rpm"
download "kibana-$FULL_VERSION-aarch64.rpm"

download "kibana-$FULL_VERSION-docker-build-context.tar.gz"
download "kibana-ironbank-$FULL_VERSION-docker-build-context.tar.gz"
download "kibana-ubi8-$FULL_VERSION-docker-build-context.tar.gz"

download "kibana-$FULL_VERSION-linux-aarch64.tar.gz"
download "kibana-$FULL_VERSION-linux-x86_64.tar.gz"

download "kibana-$FULL_VERSION-darwin-x86_64.tar.gz"
download "kibana-$FULL_VERSION-darwin-aarch64.tar.gz"

download "kibana-$FULL_VERSION-windows-x86_64.zip"

download "dependencies-$FULL_VERSION.csv"

cd -

echo "--- Set artifact permissions"
chmod -R a+r target/*
chmod -R a+w target

echo "--- Pull latest Release Manager CLI"
echo "$KIBANA_DOCKER_PASSWORD" | docker login -u "$KIBANA_DOCKER_USERNAME" --password-stdin docker.elastic.co
trap 'docker logout docker.elastic.co' EXIT
docker pull docker.elastic.co/infra/release-manager:latest

echo "--- Publish artifacts"
export VAULT_ROLE_ID="$(retry 5 15 gcloud secrets versions access latest --secret=kibana-buildkite-vault-role-id)"
export VAULT_SECRET_ID="$(retry 5 15 gcloud secrets versions access latest --secret=kibana-buildkite-vault-secret-id)"
export VAULT_ADDR="https://secrets.elastic.co:8200"
docker run --rm \
--name release-manager \
-e VAULT_ADDR \
-e VAULT_ROLE_ID \
-e VAULT_SECRET_ID \
--mount type=bind,readonly=false,src="$PWD/target",target=/artifacts/target \
docker.elastic.co/infra/release-manager:latest \
cli collect \
--project kibana \
--branch "$KIBANA_BASE_BRANCH" \
--commit "$GIT_COMMIT" \
--workflow "$WORKFLOW" \
--version "$BASE_VERSION" \
--qualifier "$VERSION_QUALIFIER" \
--artifact-set main

ARTIFACTS_SUBDOMAIN="artifacts-$WORKFLOW"
ARTIFACTS_SUMMARY=$(curl -s "https://$ARTIFACTS_SUBDOMAIN.elastic.co/kibana/latest/$FULL_VERSION.json" | jq -re '.summary_url')

cat << EOF | buildkite-agent annotate --style "info" --context artifacts-summary
### Artifacts Summary

$ARTIFACTS_SUMMARY
EOF
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/package_testing/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ elif [[ "$TEST_PACKAGE" == "rpm" ]]; then
buildkite-agent artifact download 'kibana-*.rpm' . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
KIBANA_IP_ADDRESS="192.168.56.6"
elif [[ "$TEST_PACKAGE" == "docker" ]]; then
buildkite-agent artifact download "kibana-$KIBANA_PKG_VERSION-SNAPSHOT-docker-image.tar.gz" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
buildkite-agent artifact download "kibana-$KIBANA_PKG_VERSION*-docker-image.tar.gz" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
KIBANA_IP_ADDRESS="192.168.56.7"
fi
cd ..
Expand Down