-
Notifications
You must be signed in to change notification settings - Fork 3
/
docClean.py
46 lines (43 loc) · 2.01 KB
/
docClean.py
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
from constructs import Construct, Node
from imports import k8s
class DocCronjob(Construct):
def __init__(self, scope: Construct, id: str):
super().__init__(scope, id)
app_name = 'doc-clean'
label = {'app': app_name}
k8s.KubeCronJobV1Beta1(
self, "DocCronjob",
metadata=k8s.ObjectMeta(name=app_name, labels=label),
spec=k8s.CronJobSpec(
job_template=k8s.JobTemplateSpec(
metadata=k8s.ObjectMeta(name=app_name),
spec=k8s.JobSpec(
template=k8s.PodTemplateSpec(
metadata=k8s.ObjectMeta(name=app_name),
spec=k8s.PodSpec(
containers=[
k8s.Container(
name=app_name,
image="busybox",
volume_mounts=[k8s.VolumeMount(mount_path='/opt/Documents', name='efs')],
args=['/bin/sh', '-c',
'find /opt/Documents/Viewer/cache -type d -mtime +6 -exec rm -r {} \;; find /opt/Documents/Viewer -type f -mtime +6 -exec rm {} \;'
]
),
],
restart_policy='OnFailure',
volumes=[
k8s.Volume(
name='efs',
persistent_volume_claim=k8s.PersistentVolumeClaimVolumeSource(
claim_name='efs-pvc'
)
)
]
)
)
)
),
schedule='0 1 * * SAT'
)
)