-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Beats DRA pipeline #39126
Merged
Merged
Beats DRA pipeline #39126
Changes from 26 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
e2eccd1
Packaging pipieline resource
pazone cbaba3e
Revetred agentbeat pipeline deletion
pazone 7dc47b3
Cleanup
pazone ed599da
Test auditbeat packaging pipeline
pazone 881fd97
Fix steps keys
pazone 75b4db9
Fix steps keys
pazone 720e129
Fix env vars
pazone 75e445b
Fix env vars
pazone 5790718
Fix env vars
pazone fefe674
Unified artifacts dir
pazone 3e312b6
Implemented DRA steps
pazone 20b724b
Test filebeat
pazone 1065e14
Test matrix
pazone f35efd3
Aligned artifacts directories
pazone af251f7
Aligned artifacts directories
pazone 660decd
Aligned artifacts directories
pazone cd8a604
Aligned artifacts directories
pazone 7fd5c7a
Debug
pazone 0d1da08
Debug
pazone 5671e37
Package all beats
pazone e583f3f
Test DRA snapshot
pazone 1377e5b
Test DRA snapshot
pazone 0be23b8
Rename artifacts
pazone a48c62d
fix dashboards artifacts
pazone 5c036c1
Cleanup
pazone 28ba430
Merge branch 'main' into ci_packaging_pipieline
pazone 29d2028
cleanup
pazone b6860b7
Merged
pazone be94e62
No need to install msi tools
pazone dd3ecb5
Apply suggestions from code review
pazone 3e47581
Extraced platforms variables
pazone e850d1d
Cleanup
pazone 21793d9
Added RUN_SNAPSHOT condition
pazone cc37121
Cleanup
pazone 15a04ca
Boolean dry-run
pazone d13c0c5
Boolean dry-run
pazone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
### Beats Packaging pipeline | ||
[Buildkite packaging pipeline](https://buildkite.com/elastic/beats-packaging-pipeline) is used to build and publish the packages for the Beats. The pipeline is triggered by a commit to the `main` or release branches. | ||
The pipeline definition is located in the `.buildkite/packaging.pipeline.yml` | ||
|
||
### Triggers | ||
Staging packaging DRA is triggered for the `main` and release branches. | ||
Snapshot can be triggered for any branch by the `/package` comment in the PR. The release-manager dry-run will be used for PR builds. | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Pipeline steps | ||
|
||
#### Beats dashboards | ||
|
||
Generates `build/distributions/dependencies.csv` and adds it to the `beats-dashboards` artifact. The `dependencies.csv` is required by the release-manager configuration | ||
|
||
#### Packaging snapshot/staging | ||
|
||
- Builds the Beats packages for all supported platforms and architectures (`mage package, mage ironbank`) | ||
- Copies artifacts `build/distributions/<beat>/` directory and adds it as an artifact. Where `<beat>` is the name of the beat | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- x-pack artifacts a also copied to `build/distributions/<beat>/` directory, where `<beat>` is the name of the beat. For example, `auditbeat`, not `x-pack/auditbeat` | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### DRA publish | ||
Downloads the artifacts from the `packaging snapshot/staging` step and publishes them to the Elastic DRA registry. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json | ||
# TODO: Pre-cache beats-dev/golang-crossbuild container image | ||
|
||
env: | ||
ASDF_MAGE_VERSION: 1.15.0 | ||
AWS_ARM_INSTANCE_TYPE: "m6g.xlarge" | ||
AWS_IMAGE_UBUNTU_ARM_64: "platform-ingest-beats-ubuntu-2204-aarch64" | ||
GCP_DEFAULT_MACHINE_TYPE: "c2d-highcpu-8" | ||
IMAGE_UBUNTU_X86_64: "family/platform-ingest-beats-ubuntu-2204" | ||
|
||
steps: | ||
- group: Beats dashboards | ||
key: dashboards | ||
steps: | ||
- label: Snapshot dashboards | ||
key: dashboards-snapshot | ||
# TODO: container with go and make | ||
agents: | ||
provider: gcp | ||
image: "${IMAGE_UBUNTU_X86_64}" | ||
machineType: "${GCP_HI_PERF_MACHINE_TYPE}" | ||
commands: | ||
- make build/distributions/dependencies.csv | ||
- make beats-dashboards | ||
env: | ||
SNAPSHOT: true | ||
artifact_paths: | ||
- build/distributions/**/* | ||
|
||
- label: Staging dashboards | ||
if: "build.branch =~ /\\d+\\.\\d+/ || build.branch == 'main'" | ||
key: dashboards-staging | ||
# TODO: container with go and make | ||
agents: | ||
provider: gcp | ||
image: "${IMAGE_UBUNTU_X86_64}" | ||
machineType: "${GCP_HI_PERF_MACHINE_TYPE}" | ||
commands: | ||
- make build/distributions/dependencies.csv | ||
- make beats-dashboards | ||
artifact_paths: | ||
- build/distributions/**/* | ||
|
||
- group: Packaging snapshot | ||
key: packaging-snapshot | ||
steps: | ||
# x86 | ||
- label: ":ubuntu: {{matrix}}/Packaging Linux Snapshot" | ||
env: | ||
PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64" | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SNAPSHOT: true | ||
command: ".buildkite/scripts/packaging/package-dra.sh {{matrix}}" | ||
agents: | ||
provider: gcp | ||
image: "${IMAGE_UBUNTU_X86_64}" | ||
machineType: "${GCP_HI_PERF_MACHINE_TYPE}" | ||
artifact_paths: | ||
- build/distributions/**/* | ||
matrix: | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- auditbeat | ||
- filebeat | ||
- heartbeat | ||
- metricbeat | ||
- packetbeat | ||
- winlogbeat | ||
- x-pack/auditbeat | ||
- x-pack/dockerlogbeat | ||
- x-pack/filebeat | ||
- x-pack/functionbeat | ||
- x-pack/heartbeat | ||
- x-pack/metricbeat | ||
- x-pack/packetbeat | ||
- x-pack/winlogbeat | ||
|
||
## ARM | ||
- label: ":linux: {{matrix}}/Packaging Linux arm64 Snapshot" | ||
env: | ||
PLATFORMS: "linux/arm64" | ||
PACKAGES: "docker" | ||
SNAPSHOT: true | ||
command: ".buildkite/scripts/packaging/package-dra.sh {{matrix}}" | ||
agents: | ||
provider: "aws" | ||
imagePrefix: "${AWS_IMAGE_UBUNTU_ARM_64}" | ||
instanceType: "${AWS_ARM_INSTANCE_TYPE}" | ||
artifact_paths: | ||
- build/distributions/**/* | ||
matrix: | ||
- auditbeat | ||
- filebeat | ||
- heartbeat | ||
- metricbeat | ||
- packetbeat | ||
- x-pack/auditbeat | ||
- x-pack/dockerlogbeat | ||
- x-pack/filebeat | ||
- x-pack/heartbeat | ||
- x-pack/metricbeat | ||
- x-pack/packetbeat | ||
|
||
## Osquerybeat and agentbeat require msitools to be installed | ||
## Agentbeat needs more CPUs because it builds many other beats | ||
## TODO: pre-install msitools to the VM and delete this exclusion | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- label: ":ubuntu: {{matrix}}/Packaging Linux Snapshot" | ||
env: | ||
PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64" | ||
SNAPSHOT: true | ||
command: | | ||
.buildkite/scripts/install-msitools.sh | ||
.buildkite/scripts/packaging/package-dra.sh {{matrix}} | ||
agents: | ||
provider: gcp | ||
image: "${IMAGE_UBUNTU_X86_64}" | ||
machineType: "c2-standard-16" | ||
artifact_paths: | ||
- build/distributions/**/* | ||
matrix: | ||
- x-pack/agentbeat | ||
- x-pack/osquerybeat | ||
|
||
- group: Packaging staging | ||
|
||
key: packaging-staging | ||
## Only for release and main | ||
if: "build.branch =~ /\\d+\\.\\d+/ || build.branch == 'main'" | ||
steps: | ||
# x86 | ||
- label: ":ubuntu: {{matrix}}/Packaging Linux Staging" | ||
env: | ||
PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64" | ||
SNAPSHOT: false | ||
command: ".buildkite/scripts/packaging/package-dra.sh {{matrix}}" | ||
agents: | ||
provider: gcp | ||
image: "${IMAGE_UBUNTU_X86_64}" | ||
machineType: "${GCP_HI_PERF_MACHINE_TYPE}" | ||
artifact_paths: | ||
- build/distributions/**/* | ||
matrix: | ||
- auditbeat | ||
- filebeat | ||
- heartbeat | ||
- metricbeat | ||
- packetbeat | ||
- winlogbeat | ||
- x-pack/auditbeat | ||
- x-pack/dockerlogbeat | ||
- x-pack/filebeat | ||
- x-pack/functionbeat | ||
- x-pack/heartbeat | ||
- x-pack/metricbeat | ||
- x-pack/packetbeat | ||
- x-pack/winlogbeat | ||
|
||
## ARM | ||
- label: ":linux: {{matrix}}/Packaging Linux arm64 Staging" | ||
env: | ||
PLATFORMS: "linux/arm64" | ||
PACKAGES: "docker" | ||
SNAPSHOT: false | ||
command: ".buildkite/scripts/packaging/package-dra.sh {{matrix}}" | ||
agents: | ||
provider: "aws" | ||
imagePrefix: "${AWS_IMAGE_UBUNTU_ARM_64}" | ||
instanceType: "${AWS_ARM_INSTANCE_TYPE}" | ||
artifact_paths: | ||
- build/distributions/** | ||
matrix: | ||
- auditbeat | ||
- filebeat | ||
- heartbeat | ||
- metricbeat | ||
- packetbeat | ||
- x-pack/auditbeat | ||
- x-pack/dockerlogbeat | ||
- x-pack/filebeat | ||
- x-pack/heartbeat | ||
- x-pack/metricbeat | ||
- x-pack/packetbeat | ||
|
||
## Osquerybeat and agentbeat require msitools to be installed | ||
## TODO: pre-install msitools to the VM and delete this exclusion | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- label: ":ubuntu: {{matrix}}/Packaging Linux Staging" | ||
env: | ||
PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64" | ||
SNAPSHOT: false | ||
command: ".buildkite/scripts/packaging/package-dra.sh {{matrix}}" | ||
agents: | ||
provider: gcp | ||
image: "${IMAGE_UBUNTU_X86_64}" | ||
machineType: "${GCP_HI_PERF_MACHINE_TYPE}" | ||
artifact_paths: | ||
- build/distributions/** | ||
matrix: | ||
- x-pack/agentbeat | ||
- x-pack/osquerybeat | ||
|
||
- group: DRA publish | ||
key: dra | ||
steps: | ||
- label: DRA Snapshot | ||
key: dra-snapshot | ||
env: | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
DRA_WORKFLOW: snapshot | ||
depends_on: | ||
- packaging-snapshot | ||
- dashboards-snapshot | ||
command: | | ||
buildkite-agent artifact download "build/**/*" . | ||
.buildkite/scripts/packaging/prepare-release-manager.sh | ||
.buildkite/scripts/dra.sh | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
agents: | ||
provider: "gcp" | ||
|
||
- label: DRA Staging | ||
## Only for release and main | ||
if: "build.branch =~ /\\d+\\.\\d+/ || build.branch == 'main'" | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
key: dra-staging | ||
env: | ||
DRA_WORKFLOW: staging | ||
depends_on: | ||
- packaging-staging | ||
- dashboards-staging | ||
command: | | ||
buildkite-agent artifact download "build/**" . | ||
.buildkite/scripts/packaging/prepare-release-manager.sh | ||
.buildkite/scripts/dra.sh | ||
agents: | ||
provider: "gcp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
set -uo pipefail | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
DRY_RUN="" | ||
BRANCH="${BUILDKITE_BRANCH}" | ||
|
||
if [[ "${BUILDKITE_PULL_REQUEST:="false"}" != "false" || "${BUILDKITE_BRANCH}" == "ci_packaging_pipieline" ]]; then | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
BRANCH=main | ||
DRY_RUN="--dry-run" | ||
echo "+++ Running in PR and setting branch main and --dry-run" | ||
fi | ||
|
||
BEAT_VERSION=$(make get-version) | ||
|
||
CI_DRA_ROLE_PATH="kv/ci-shared/release/dra-role" | ||
|
||
# TODO use common function | ||
retry() { | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
local retries=$1 | ||
shift | ||
local count=0 | ||
until "$@"; do | ||
exit=$? | ||
wait=$((2 ** count)) | ||
count=$((count + 1)) | ||
if [ $count -lt "$retries" ]; then | ||
>&2 echo "Retry $count/$retries exited $exit, retrying in $wait seconds..." | ||
sleep $wait | ||
else | ||
>&2 echo "Retry $count/$retries exited $exit, no more retries left." | ||
return $exit | ||
fi | ||
done | ||
return 0 | ||
} | ||
|
||
function release_manager_login { | ||
DRA_CREDS_SECRET=$(retry 5 vault kv get -field=data -format=json ${CI_DRA_ROLE_PATH}) | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
VAULT_ADDR_SECRET=$(echo ${DRA_CREDS_SECRET} | jq -r '.vault_addr') | ||
VAULT_ROLE_ID_SECRET=$(echo ${DRA_CREDS_SECRET} | jq -r '.role_id') | ||
VAULT_SECRET=$(echo ${DRA_CREDS_SECRET} | jq -r '.secret_id') | ||
export VAULT_ADDR_SECRET VAULT_ROLE_ID_SECRET VAULT_SECRET | ||
} | ||
|
||
release_manager_login | ||
|
||
echo "+++ Changing permissions for the BK API commands" | ||
sudo chown -R :1000 build/distributions/ | ||
|
||
echo "+++ :hammer_and_pick: Publishing $BRANCH $DRA_WORKFLOW DRA artifacts..." | ||
docker run --rm \ | ||
--name release-manager \ | ||
-e VAULT_ADDR="${VAULT_ADDR_SECRET}" \ | ||
-e VAULT_ROLE_ID="${VAULT_ROLE_ID_SECRET}" \ | ||
-e VAULT_SECRET_ID="${VAULT_SECRET}" \ | ||
--mount type=bind,readonly=false,src="${PWD}",target=/artifacts \ | ||
docker.elastic.co/infra/release-manager:latest \ | ||
cli collect \ | ||
--project "beats" \ | ||
--branch "${BRANCH}" \ | ||
--commit "${BUILDKITE_COMMIT}" \ | ||
--workflow "${DRA_WORKFLOW}" \ | ||
--version "${BEAT_VERSION}" \ | ||
--artifact-set "main" \ | ||
${DRY_RUN} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
BEAT_DIR=$1 | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if [ -z "$BEAT_DIR" ]; then | ||
echo "Error: Beat directory must be specified." | ||
exit 1 | ||
fi | ||
|
||
echo "Packaging : $BEAT_DIR" | ||
pazone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
WORKSPACE=$(pwd) | ||
BEAT_NAME_SLUG=$(echo "$BEAT_DIR" | sed 's/x-pack\///g') | ||
|
||
cd $BEAT_DIR | ||
mage package | ||
mage ironbank | ||
|
||
mkdir -p $WORKSPACE/build/distributions/$BEAT_NAME_SLUG | ||
cp build/distributions/* $WORKSPACE/build/distributions/$BEAT_NAME_SLUG/ | ||
cd $WORKSPACE |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sections in
triggers
said about PRs but that's not reflected here.