mirror of
https://github.com/google/nomulus.git
synced 2025-04-29 19:47:51 +02:00
Add a GCB job to delete stopped GAE versions (#1128)
This commit is contained in:
parent
11f7bb8f6e
commit
93289e1997
3 changed files with 56 additions and 3 deletions
52
release/cloudbuild-delete.yaml
Normal file
52
release/cloudbuild-delete.yaml
Normal file
|
@ -0,0 +1,52 @@
|
|||
# To run the build locally, install cloud-build-local first.
|
||||
# Then run:
|
||||
# cloud-build-local --config=cloudbuild-delete.yaml --dryrun=false \
|
||||
# --substitutions=TAG_NAME=[TAG],_ENV=[ENV] ..
|
||||
#
|
||||
# This will delete all stopped GAE versions (save 3) as there is a limit on how
|
||||
# many versions can exist in a project.
|
||||
#
|
||||
# To manually trigger a build on GCB, run:
|
||||
# gcloud builds submit --config=cloudbuild-delete.yaml \
|
||||
# --substitutions=TAG_NAME=[TAG],_ENV=[ENV] ..
|
||||
#
|
||||
# To trigger a build automatically, follow the instructions below and add a trigger:
|
||||
# https://cloud.google.com/cloud-build/docs/running-builds/automate-builds
|
||||
#
|
||||
# Note: to work around issue in Spinnaker's 'Deployment Manifest' stage,
|
||||
# variable references must avoid the ${var} format. Valid formats include
|
||||
# $var or ${"${var}"}. This file uses the former. Since TAG_NAME and _ENV are
|
||||
# expanded in the copies sent to Spinnaker, we preserve the brackets around
|
||||
# them for safe pattern matching during release.
|
||||
# See https://github.com/spinnaker/spinnaker/issues/3028 for more information.
|
||||
steps:
|
||||
# Deploy the GAE config files.
|
||||
# First authorize the gcloud tool to use the credential json file, then
|
||||
# download and unzip the tarball that contains the relevant config files
|
||||
- name: 'gcr.io/$PROJECT_ID/builder:latest'
|
||||
entrypoint: /bin/bash
|
||||
args:
|
||||
- -c
|
||||
- |
|
||||
if [ ${_ENV} == production ]
|
||||
then
|
||||
project_id="domain-registry"
|
||||
else
|
||||
project_id="domain-registry-${_ENV}"
|
||||
fi
|
||||
|
||||
for service in default pubapi backend tools
|
||||
do
|
||||
for version in $(gcloud app versions list \
|
||||
--filter="SERVICE:$service AND SERVING_STATUS:STOPPED" \
|
||||
--sort-by=LAST_DEPLOYED --format="value(VERSION.ID)" \
|
||||
--project=$project_id | head -n -3)
|
||||
do
|
||||
gcloud app versions delete $version --service=$service \
|
||||
--project=$project_id --quiet;
|
||||
done
|
||||
done
|
||||
|
||||
timeout: 3600s
|
||||
options:
|
||||
machineType: 'N1_HIGHCPU_8'
|
|
@ -3,8 +3,7 @@
|
|||
# cloud-build-local --config=cloudbuild-deploy.yaml --dryrun=false \
|
||||
# --substitutions=TAG_NAME=[TAG],_ENV=[ENV] ..
|
||||
#
|
||||
# This will deploy Beam pipelines to GCS for the PROJECT_ID defined in gcloud
|
||||
# tool.
|
||||
# This will deploy the GAE config files and save the deployed tags in GCS.
|
||||
#
|
||||
# To manually trigger a build on GCB, run:
|
||||
# gcloud builds submit --config=cloudbuild-deploy.yaml \
|
||||
|
@ -15,7 +14,7 @@
|
|||
#
|
||||
# Note: to work around issue in Spinnaker's 'Deployment Manifest' stage,
|
||||
# variable references must avoid the ${var} format. Valid formats include
|
||||
# $var or ${"${var}"}. This file use the former. Since TAG_NAME and _ENV are
|
||||
# $var or ${"${var}"}. This file uses the former. Since TAG_NAME and _ENV are
|
||||
# expanded in the copies sent to Spinnaker, we preserve the brackets around
|
||||
# them for safe pattern matching during release.
|
||||
# See https://github.com/spinnaker/spinnaker/issues/3028 for more information.
|
||||
|
|
|
@ -97,6 +97,8 @@ steps:
|
|||
for environment in alpha crash sandbox production; do
|
||||
sed s/'$${_ENV}'/${environment}/g release/cloudbuild-deploy.yaml \
|
||||
> release/cloudbuild-deploy-${environment}.yaml
|
||||
sed s/'$${_ENV}'/${environment}/g release/cloudbuild-delete.yaml \
|
||||
> release/cloudbuild-delete-${environment}.yaml
|
||||
done
|
||||
# Build the schema_deployer image and upload it to GCR.
|
||||
- name: 'gcr.io/cloud-builders/docker'
|
||||
|
|
Loading…
Add table
Reference in a new issue