-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathcleanup-gcp.yml
62 lines (58 loc) · 1.65 KB
/
cleanup-gcp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
resources:
- name: git-kubo-ci
type: git
source:
uri: https://github.com/cloudfoundry-incubator/kubo-ci
branch: master
- name: hourly
type: time
source:
interval: 1h
jobs:
- name: clean-gcp-disks
plan:
- get: git-kubo-ci
- task: cleanup-disks
file: git-kubo-ci/tasks/cleanup-gcp-disks.yml
params:
GCP_SERVICE_ACCOUNT: ((gcp-service-account))
- name: clean-gcp-lbs
plan:
- get: git-kubo-ci
- task: cleanup-lbs
file: git-kubo-ci/tasks/cleanup-gcp-lbs.yml
params:
GCP_SERVICE_ACCOUNT: ((gcp-service-account))
- name: check-for-old-bbl-envs
plan:
- get: hourly
trigger: true
- task: check-for-old-bbl-envs
config:
platform: linux
params:
GCP_SERVICE_ACCOUNT: ((gcp-service-account))
image_resource:
type: docker-image
source: {repository: google/cloud-sdk}
run:
path: /bin/bash
args:
- -eux
- -c
- |
export GOOGLE_APPLICATION_CREDENTIALS="$(mktemp)"
set +x
echo "$GCP_SERVICE_ACCOUNT" > "$GOOGLE_APPLICATION_CREDENTIALS"
set -x
gcloud auth activate-service-account --key-file "$GOOGLE_APPLICATION_CREDENTIALS" --project cf-pcf-kubo
if [[ "$(gcloud compute instances list \
--filter="labels.director~'bbl-env' AND creationTimestamp<-P14d" \
--format="table(name,creationTimestamp.date(%Y-%m-%d):sort=1,networkInterfaces[0].network.scope())" \
| wc -l | awk '{print $1}')" == "0" ]]; then
exit 0;
else
echo "There were old BBL resources";
exit 1;
fi