mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[cft] Add pipeline to shutdown deployment (#136659)
* [cft] Add pipeline to shutdown deployment * 755 * save file
This commit is contained in:
parent
7a54e0c675
commit
1410bc4aa5
7 changed files with 59 additions and 6 deletions
13
.buildkite/pipelines/purge_cloud_deployment.yml
Normal file
13
.buildkite/pipelines/purge_cloud_deployment.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
steps:
|
||||
- block: "Purge deployment"
|
||||
prompt: "Fill out the details to shutdown a PR deployment"
|
||||
fields:
|
||||
- text: "Pull Request Number"
|
||||
key: "kibana-pull-request"
|
||||
if: "build.env('KIBANA_PULL_REQUEST') == null || build.env('KIBANA_PULL_REQUEST') == ''"
|
||||
|
||||
- command: .buildkite/scripts/steps/cloud/purge_deployment.sh
|
||||
label: Purge a cloud deployment
|
||||
timeout_in_minutes: 10
|
||||
agents:
|
||||
queue: kibana-default
|
|
@ -1,5 +1,5 @@
|
|||
steps:
|
||||
- command: .buildkite/scripts/steps/cloud/purge.sh
|
||||
- command: .buildkite/scripts/steps/cloud/purge_deployments.sh
|
||||
label: Purge old cloud deployments
|
||||
timeout_in_minutes: 10
|
||||
agents:
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ts-node .buildkite/scripts/steps/cloud/purge.ts
|
5
.buildkite/scripts/steps/cloud/purge_deployment.sh
Executable file
5
.buildkite/scripts/steps/cloud/purge_deployment.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ts-node .buildkite/scripts/steps/cloud/purge_deployment.ts
|
35
.buildkite/scripts/steps/cloud/purge_deployment.ts
Normal file
35
.buildkite/scripts/steps/cloud/purge_deployment.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
const deploymentsListJson = execSync('ecctl deployment list --output json').toString();
|
||||
const { deployments } = JSON.parse(deploymentsListJson);
|
||||
|
||||
const prNumber = parseInt(
|
||||
process.env.KIBANA_PULL_REQUEST ||
|
||||
execSync('buildkite-agent meta-data get kibana-pull-request').toString(),
|
||||
10
|
||||
);
|
||||
const deploymentName = `kibana-pr-${prNumber}`;
|
||||
const deployment = deployments.find((d: any) => d.name === deploymentName);
|
||||
|
||||
if (!prNumber || !deployment) {
|
||||
console.error(`${deploymentName} not found`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Scheduling deployment for deletion: ${deployment.name} / ${deployment.id}`);
|
||||
try {
|
||||
execSync(`ecctl deployment shutdown --force '${deployment.id}'`, { stdio: 'inherit' });
|
||||
execSync(`vault delete secret/kibana-issues/dev/cloud-deploy/${deployment.name}`, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
} catch (ex) {
|
||||
console.error(ex.toString());
|
||||
}
|
5
.buildkite/scripts/steps/cloud/purge_deployments.sh
Executable file
5
.buildkite/scripts/steps/cloud/purge_deployments.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ts-node .buildkite/scripts/steps/cloud/purge_deployments.ts
|
Loading…
Add table
Add a link
Reference in a new issue