Skip to content

Commit

Permalink
Merge branch 'main' into discover-help
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 14, 2022
2 parents 317870f + 4c31b15 commit 2c71219
Show file tree
Hide file tree
Showing 6,200 changed files with 548,607 additions and 477,870 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 2 additions & 1 deletion .backportrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"repoName": "kibana",
"targetBranchChoices": [
"main",
"8.1",
"8.0",
"7.17",
"7.16",
Expand Down Expand Up @@ -37,7 +38,7 @@
"backport"
],
"branchLabelMapping": {
"^v8.1.0$": "main",
"^v8.2.0$": "main",
"^v(\\d+).(\\d+).\\d+$": "$1.$2"
},
"autoMerge": true,
Expand Down
2 changes: 1 addition & 1 deletion .bazeliskversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.1
1.11.0
2 changes: 0 additions & 2 deletions .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ build --experimental_inprocess_symlink_creation

# Incompatible flags to run with
build --incompatible_no_implicit_file_export
build --incompatible_restrict_string_escapes
query --incompatible_no_implicit_file_export
query --incompatible_restrict_string_escapes

# Log configs
## different from default
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.1
5.0.0
7 changes: 7 additions & 0 deletions .buildkite/pipelines/pull_request/deploy_cloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
steps:
- command: .buildkite/scripts/steps/cloud/build_and_deploy.sh
label: 'Build and Deploy to Cloud'
agents:
queue: n2-2
depends_on: build
timeout_in_minutes: 30
4 changes: 4 additions & 0 deletions .buildkite/pipelines/purge_cloud_deployments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- command: .buildkite/scripts/steps/cloud/purge.sh
label: Purge old cloud deployments
timeout_in_minutes: 10
24 changes: 0 additions & 24 deletions .buildkite/scripts/build_kibana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,6 @@ else
node scripts/build
fi

if [[ "${GITHUB_PR_LABELS:-}" == *"ci:deploy-cloud"* ]]; then
echo "--- Build and push Kibana Cloud Distribution"

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 \
--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

CLOUD_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" docker.elastic.co/kibana-ci/kibana-cloud)
cat << EOF | buildkite-agent annotate --style "info" --context cloud-image
Cloud image: $CLOUD_IMAGE
EOF
fi

echo "--- Archive Kibana Distribution"
linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')"
installDir="$KIBANA_DIR/install/kibana"
Expand Down
5 changes: 4 additions & 1 deletion .buildkite/scripts/lifecycle/pre_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export KIBANA_DOCKER_USERNAME
KIBANA_DOCKER_PASSWORD="$(retry 5 5 vault read -field=password secret/kibana-issues/dev/container-registry)"
export KIBANA_DOCKER_PASSWORD

EC_API_KEY="$(retry 5 5 vault read -field=pr_deploy_api_key secret/kibana-issues/dev/kibana-ci-cloud-deploy)"
export EC_API_KEY

SYNTHETICS_SERVICE_USERNAME="$(retry 5 5 vault read -field=username secret/kibana-issues/dev/kibana-ci-synthetics-credentials)"
export SYNTHETICS_SERVICE_USERNAME

Expand All @@ -107,7 +110,7 @@ export SYNTHETICS_REMOTE_KIBANA_USERNAME
SYNTHETICS_REMOTE_KIBANA_PASSWORD="$(retry 5 5 vault read -field=password secret/kibana-issues/dev/kibana-ci-synthetics-remote-credentials)"
export SYNTHETICS_REMOTE_KIBANA_PASSWORD

SYNTHETICS_REMOTE_KIBANA_URL="$(retry 5 5 vault read -field=url secret/kibana-issues/dev/kibana-ci-synthetics-remote-credentials)"
SYNTHETICS_REMOTE_KIBANA_URL=${SYNTHETICS_REMOTE_KIBANA_URL-"$(retry 5 5 vault read -field=url secret/kibana-issues/dev/kibana-ci-synthetics-remote-credentials)"}
export SYNTHETICS_REMOTE_KIBANA_URL

# Setup Failed Test Reporter Elasticsearch credentials
Expand Down
4 changes: 4 additions & 0 deletions .buildkite/scripts/pipelines/pull_request/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ const uploadPipeline = (pipelineContent) => {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/uptime.yml'));
}

if (process.env.GITHUB_PR_LABELS.includes('ci:deploy-cloud')) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/deploy_cloud.yml'));
}

pipeline.push(getPipeline('.buildkite/pipelines/pull_request/post_build.yml'));

uploadPipeline(pipeline.join('\n'));
Expand Down
80 changes: 80 additions & 0 deletions .buildkite/scripts/steps/cloud/build_and_deploy.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

.buildkite/scripts/bootstrap.sh

export KBN_NP_PLUGINS_BUILT=true

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

echo "--- Download kibana distribution"

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

echo "--- Build and push Kibana Cloud Distribution"

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 \
--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

CLOUD_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" docker.elastic.co/kibana-ci/kibana-cloud)
CLOUD_DEPLOYMENT_NAME="kibana-pr-$BUILDKITE_PULL_REQUEST"

jq '
.resources.kibana[0].plan.kibana.docker_image = "'$CLOUD_IMAGE'" |
.name = "'$CLOUD_DEPLOYMENT_NAME'" |
.resources.kibana[0].plan.kibana.version = "'$VERSION'" |
.resources.elasticsearch[0].plan.elasticsearch.version = "'$VERSION'"
' .buildkite/scripts/steps/cloud/deploy.json > /tmp/deploy.json

CLOUD_DEPLOYMENT_ID=$(ecctl deployment list --output json | jq -r '.deployments[] | select(.name == "'$CLOUD_DEPLOYMENT_NAME'") | .id')
JSON_FILE=$(mktemp --suffix ".json")
if [ -z "${CLOUD_DEPLOYMENT_ID}" ]; then
ecctl deployment create --track --output json --file /tmp/deploy.json &> "$JSON_FILE"
CLOUD_DEPLOYMENT_USERNAME=$(jq --slurp '.[]|select(.resources).resources[] | select(.credentials).credentials.username' "$JSON_FILE")
CLOUD_DEPLOYMENT_PASSWORD=$(jq --slurp '.[]|select(.resources).resources[] | select(.credentials).credentials.password' "$JSON_FILE")
CLOUD_DEPLOYMENT_ID=$(jq -r --slurp '.[0].id' "$JSON_FILE")
CLOUD_DEPLOYMENT_STATUS_MESSAGES=$(jq --slurp '[.[]|select(.resources == null)]' "$JSON_FILE")

# Refresh vault token
VAULT_ROLE_ID="$(retry 5 15 gcloud secrets versions access latest --secret=kibana-buildkite-vault-role-id)"
VAULT_SECRET_ID="$(retry 5 15 gcloud secrets versions access latest --secret=kibana-buildkite-vault-secret-id)"
VAULT_TOKEN=$(retry 5 30 vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID")
retry 5 30 vault login -no-print "$VAULT_TOKEN"

retry 5 5 vault write "secret/kibana-issues/dev/cloud-deploy/$CLOUD_DEPLOYMENT_NAME" username="$CLOUD_DEPLOYMENT_USERNAME" password="$CLOUD_DEPLOYMENT_PASSWORD"
else
ecctl deployment update "$CLOUD_DEPLOYMENT_ID" --track --output json --file /tmp/deploy.json &> "$JSON_FILE"
fi

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')

cat << EOF | buildkite-agent annotate --style "info" --context cloud
### Cloud Deployment
Kibana: $CLOUD_DEPLOYMENT_KIBANA_URL
Elasticsearch: $CLOUD_DEPLOYMENT_ELASTICSEARCH_URL
Credentials: \`vault read secret/kibana-issues/dev/cloud-deploy/$CLOUD_DEPLOYMENT_NAME\`
Image: $CLOUD_IMAGE
EOF

buildkite-agent meta-data set pr_comment:deploy_cloud:head "* [Cloud Deployment](${CLOUD_DEPLOYMENT_KIBANA_URL})"
163 changes: 163 additions & 0 deletions .buildkite/scripts/steps/cloud/deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{
"resources": {
"elasticsearch": [
{
"region": "gcp-us-west2",
"settings": {
"dedicated_masters_threshold": 6
},
"plan": {
"autoscaling_enabled": false,
"cluster_topology": [
{
"zone_count": 2,
"instance_configuration_id": "gcp.coordinating.1",
"node_roles": ["ingest", "remote_cluster_client"],
"id": "coordinating",
"size": {
"resource": "memory",
"value": 0
},
"elasticsearch": {
"enabled_built_in_plugins": []
}
},
{
"zone_count": 1,
"elasticsearch": {
"node_attributes": {
"data": "hot"
},
"enabled_built_in_plugins": []
},
"instance_configuration_id": "gcp.data.highio.1",
"node_roles": [
"master",
"ingest",
"transform",
"data_hot",
"remote_cluster_client",
"data_content"
],
"id": "hot_content",
"size": {
"value": 1024,
"resource": "memory"
}
},
{
"zone_count": 2,
"elasticsearch": {
"node_attributes": {
"data": "warm"
},
"enabled_built_in_plugins": []
},
"instance_configuration_id": "gcp.data.highstorage.1",
"node_roles": ["data_warm", "remote_cluster_client"],
"id": "warm",
"size": {
"resource": "memory",
"value": 0
}
},
{
"zone_count": 1,
"elasticsearch": {
"node_attributes": {
"data": "cold"
},
"enabled_built_in_plugins": []
},
"instance_configuration_id": "gcp.data.highstorage.1",
"node_roles": ["data_cold", "remote_cluster_client"],
"id": "cold",
"size": {
"resource": "memory",
"value": 0
}
},
{
"zone_count": 1,
"elasticsearch": {
"node_attributes": {
"data": "frozen"
},
"enabled_built_in_plugins": []
},
"instance_configuration_id": "gcp.es.datafrozen.n1.64x10x95",
"node_roles": ["data_frozen"],
"id": "frozen",
"size": {
"resource": "memory",
"value": 0
}
},
{
"zone_count": 3,
"instance_configuration_id": "gcp.master.1",
"node_roles": ["master", "remote_cluster_client"],
"id": "master",
"size": {
"resource": "memory",
"value": 0
},
"elasticsearch": {
"enabled_built_in_plugins": []
}
},
{
"zone_count": 1,
"instance_configuration_id": "gcp.ml.1",
"node_roles": ["ml", "remote_cluster_client"],
"id": "ml",
"size": {
"resource": "memory",
"value": 0
},
"elasticsearch": {
"enabled_built_in_plugins": []
}
}
],
"elasticsearch": {
"version": null
},
"deployment_template": {
"id": "gcp-io-optimized-v2"
}
},
"ref_id": "main-elasticsearch"
}
],
"enterprise_search": [],
"kibana": [
{
"elasticsearch_cluster_ref_id": "main-elasticsearch",
"region": "gcp-us-west2",
"plan": {
"cluster_topology": [
{
"instance_configuration_id": "gcp.kibana.1",
"zone_count": 1,
"size": {
"resource": "memory",
"value": 1024
}
}
],
"kibana": {
"version": null,
"docker_image": null
}
},
"ref_id": "main-kibana"
}
],
"apm": []
},
"name": null,
"metadata": {
"system_owned": false
}
}
Loading

0 comments on commit 2c71219

Please sign in to comment.