File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,24 +6,21 @@ NOW=$(date +%s)
66# loop through all pvcs.
77for pvc in $BLUEAPI_PVCS ; do
88 # check if pvc has last-used annotation
9- if kubectl get pvc $pvc -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.last-used}'
10- then
119 # get last used annotation
12- LAST_USED=$( kubectl get pvc $pvc -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.last-used}' )
10+ LAST_USED=$( kubectl get pvc " $pvc " -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.last-used}' )
1311 # checking if its not null
1412 if [ -n " $LAST_USED " ]; then
1513 # check if last_used is older than 3 months
1614 if [ $(( $NOW - LAST_USED)) -gt 7884000 ]; then
1715 # checking if the pvc is protected, if it is protected skip deletion
18- if [ " $( kubectl get pvc $pvc -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.protected}' ) " = " true" ]; then
19- echo " PVC $pvc is protected, skipping deletion"
16+ if [ " $( kubectl get pvc " $pvc " -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.protected}' ) " = " true" ]; then
17+ echo " PVC $pvc is protected, skipping deletion"
2018 continue
2119 fi
2220 # PVC has not been used for more than three months, delete it
2321 kubectl delete pvc " $pvc " -n $RELEASE_NAMESPACE
2422 fi
25- fi
26- else
27- echo " PVC $pvc does not have last-used annotation, skipping deletion"
23+ else
24+ echo " $pvc has no last-used annotation"
2825 fi
2926done
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ metadata:
3737 namespace : {{ .Release.Namespace }}
3838spec :
3939 concurrencyPolicy : Forbid
40- successfulJobsHistoryLimit : 3
40+ successfulJobsHistoryLimit : 1
4141 failedJobsHistoryLimit : 1
4242 schedule : " */5 * * * *"
4343
@@ -122,13 +122,13 @@ metadata:
122122 namespace : {{ .Release.Namespace }}
123123spec :
124124 concurrencyPolicy : Forbid
125- successfulJobsHistoryLimit : 3
125+ successfulJobsHistoryLimit : 1
126126 failedJobsHistoryLimit : 1
127127 schedule : " @weekly"
128128
129129 jobTemplate :
130130 spec :
131- # amount of attempts of labeling a pvc
131+ # amount of attempts for pvc deletion
132132 backoffLimit : 3
133133 # job stops after 300 seconds
134134 activeDeadlineSeconds : 300
You can’t perform that action at this time.
0 commit comments