-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanup_love
executable file
·44 lines (31 loc) · 1.26 KB
/
cleanup_love
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
#!/usr/bin/env python3
import argparse
import helpers as hp
APIS = ["deployment", "job", "hpa"]
CMD_DELETE_ALL = "kubectl delete {api} -n love --all"
def main(opts):
hp.acknowledge_deletion()
if opts.db or opts.all:
APIS.append("statefulset")
if opts.svc or opts.all:
APIS.append("svc")
if opts.pvc or opts.all:
APIS.append("pvc")
for api in APIS:
command = CMD_DELETE_ALL.format(api=api)
output = hp.run_cmd(command)
print(output)
if __name__ == '__main__':
description = ["This program cleans up LOVE deployments and jobs."]
description.append("Services and PersistentVolumeClaims can optionally be cleaned.")
parser = argparse.ArgumentParser(
description=" ".join(description),
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
extras = parser.add_argument_group("extras")
extras.add_argument("--svc", action="store_true", help="Delete all services")
extras.add_argument("--pvc", action="store_true", help="Delete all persistent volume claims")
extras.add_argument("--db", action="store_true", help="Delete the database")
parser.add_argument("--all", action="store_true", help="Delete all APIs")
args = parser.parse_args()
main(args)