File tree Expand file tree Collapse file tree
helm/blueapi/files/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /bin/sh
2- # Get PVCs belonging to this blueapi release
3- ALL_PVC=$( kubectl get pvc -n $RELEASE_NAMESPACE \
4- -o jsonpath=' {.items[*].metadata.name}' | tr ' ' ' \n' | \
5- grep " ^$RELEASE_NAME -scratch-" )
62# Get all PVCs currently mounted by running pods
73MOUNTED_PVCS=$( kubectl get pods -n $RELEASE_NAMESPACE \
84 -o=jsonpath=' {.items[*].spec.volumes[*].persistentVolumeClaim.claimName}' | tr ' ' ' \n' | sort -u)
95NOW=$( date +%s)
10- # loop through all the pvcs annotating ones thare are mounted or lack a last-used stamp
11- for pvc in $ALL_PVC ; do
12- # Checks if Annotation for last-used is empty
13- ANNOTATION=$( kubectl get pvc " $pvc " -n $RELEASE_NAMESPACE -o=jsonpath=' {.metadata.annotations.last-used}' )
14- # -z checks if ANNOTATION is empty, if its empty or mounted to updates last-used else it ignores it
15- if [ -z " $ANNOTATION " ]; then
6+ # loop through all the pvcs annotating ones thare are mounted
7+ for pvc in $MOUNTED_PVCS ; do
168 kubectl annotate --overwrite pvc " $pvc " -n $RELEASE_NAMESPACE last-used=" $NOW "
17- elif echo " $MOUNTED_PVCS " | grep -qx " $pvc " ; then
18- kubectl annotate --overwrite pvc " $pvc " -n $RELEASE_NAMESPACE last-used=" $NOW "
19- fi
209done
You can’t perform that action at this time.
0 commit comments