File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /bin/sh
22# Get all PVCs by running pods
33ALL_PVCS=$( kubectl get pvc -n $RELEASE_NAMESPACE -o=jsonpath=' {.items[*].metadata.name}' | tr ' ' ' \n' | sort -u)
4- Now =$( date +%s)
4+ NOW =$( date +%s)
55# loop through all pvcs.
66for pvc in $ALL_PVCS ; do
77 # check if pvc has last-used annotation
8- if get $ pvc last-used -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.last-used}'
8+ if kubectl get pvc $pvc -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.last-used}'
99 then
1010 # get last used annotation and check if it is more than three months ago (2628000 seconds)
11- LAST_USED=$( get $ pvc last-used -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.last-used}' )
12- if [ $(( NOW - LAST_USED)) -gt 2628000 ]; then
11+ LAST_USED=$( kubectl get pvc $pvc -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.last-used}' )
12+ if [ $(( $ NOW - LAST_USED)) -gt 2628000 ]; then
1313 # checking if the pvc is protected, if it is protected skip deletion
14- if [ get $pvc protected -n $RELEASE_NAMESPACE -o= jsonpath= ' {.metadata.annotations.protected}' = " true" ]; then
14+ if [ " $( kubectl get pvc $pvc -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.protected}' ) " = " true" ]; then
1515 echo " PVC $pvc is protected, skipping deletion"
1616 continue
1717 fi
Original file line number Diff line number Diff line change 7777 command : ["/scripts/time-stamper.sh"]
7878 restartPolicy : OnFailure
7979{{- end }}
80-
8180{{- if .Values.pvcautodeletion.enabled }}
81+ ---
8282apiVersion : v1
8383kind : ServiceAccount
8484metadata :
You can’t perform that action at this time.
0 commit comments