File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,27 +35,14 @@ data:
3535 ---
3636{{- end }}
3737
38+ ---
39+ {{- if .Values.timeStampCron.enabled }}
3840apiVersion : v1
3941kind : ConfigMap
4042metadata :
4143 name : {{include "blueapi.fullname" . }}-pvc-stamper-script
4244data :
43- time-stamper.sh : |
44- #!/bin/sh
45- # Get PVCs belonging to this blueapi release
46- ALL_PVC=$(kubectl get pvc -n {{ .Release.Namespace }} \
47- -o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | \
48- grep "^{{ .Release.Name }}-scratch-")
49- # Get all PVCs currently mounted by running pods
50- MOUNTED_PVCS=$(kubectl get pods -n {{ .Release.Namespace }} \
51- -o=jsonpath='{.items[*].spec.volumes[*].persistentVolumeClaim.claimName}' | tr ' ' '\n' | sort -u)
52- NOW=$(date +%s)
53- #loop through all the pvcs annotating ones thare are mounted or lack a last-used stamp
54- for pvc in $ALL_PVC; do
55- ANNOTATION=$(kubectl get pvc "$pvc" -n {{ .Release.Namespace }} -o=jsonpath='{.metadata.annotations.last-used}')
56- if [ -z "$ANNOTATION" ]; then
57- kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW"
58- elif echo "$MOUNTED_PVCS" | grep -qx "$pvc"; then
59- kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW"
60- fi
61- done
45+ {{- $files := .Files }}
46+ time-stamper.sh : |-
47+ {{ $files.Get "files/scripts/time-stamper.sh" | indent 4 }}
48+ {{- end }}
You can’t perform that action at this time.
0 commit comments