Skip to content

Add job to clean up GCP network resources

What does this MR do?

Adds a script to clean up dangling GCP network resources related to review apps:

  • firewall rules
  • forwarding rules
  • target pools
  • health checks

Adds a job to run the clean up script that:

  1. runs on scheduled pipelines
  2. runs manually on MR pipelines

Screenshots

Example job: https://gitlab.com/gitlab-org/gitlab/-/jobs/490425163

Output of script:

$ gcp_cleanup

** Inspecting forwarding rule a00ab062f5fca11ea8ae742010af001c **
Queuing forwarding rule, firewall rule, target pool and health check for a00ab062f5fca11ea8ae742010af001c to be cleaned up

** Deleting firewall rules: **
k8s-a00ab062f5fca11ea8ae742010af001c-http-hc k8s-fw-a00ab062f5fca11ea8ae742010af001c
Deleted [https://www.googleapis.com/compute/v1/projects/gitlab-review-apps/global/firewalls/k8s-a00ab062f5fca11ea8ae742010af001c-http-hc].
Deleted [https://www.googleapis.com/compute/v1/projects/gitlab-review-apps/global/firewalls/k8s-fw-a00ab062f5fca11ea8ae742010af001c].

** Deleting forwarding rules: **
a00ab062f5fca11ea8ae742010af001c
Deleted [https://www.googleapis.com/compute/v1/projects/gitlab-review-apps/regions/us-central1/forwardingRules/a00ab062f5fca11ea8ae742010af001c].

** Deleting target pools: **
a00ab062f5fca11ea8ae742010af001c
Deleted [https://www.googleapis.com/compute/v1/projects/gitlab-review-apps/regions/us-central1/targetPools/a00ab062f5fca11ea8ae742010af001c].

** Deleting http health checks: **
a00ab062f5fca11ea8ae742010af001c
Deleted [https://www.googleapis.com/compute/v1/projects/gitlab-review-apps/global/httpHealthChecks/a00ab062f5fca11ea8ae742010af001c].

Does this MR meet the acceptance criteria?

Conformity

TODO before merging:

  • Add GCP_REGION to CI environment - us-central1

#211579 (closed)

Edited by Albert Salim

Merge request reports