Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helm/blueapi/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application

# This is the chart version. This version number is incremented by the release process.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.12.7
version: 1.12.9

# This is the version number of the application being deployed. This version number is incremented by the release process.
# Versions are not expected to follow Semantic Versioning. They should reflect the version the application is using.
Expand Down
27 changes: 26 additions & 1 deletion helm/blueapi/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ data:
init_config.yaml: |-
scratch:
{{- toYaml .Values.worker.scratch | nindent 6 }}

---
{{- end }}

---
apiVersion: v1
kind: ConfigMap
metadata:
name : {{include "blueapi.fullname" . }}-pvc-stamper-script
data:
time-stamper.sh: |
#!/bin/sh
# Get PVCs belonging to this blueapi release
ALL_PVC=$(kubectl get pvc -n {{ .Release.Namespace }} \
-o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | \
grep "^{{ .Release.Name }}-scratch-")
# Get all PVCs currently mounted by running pods
MOUNTED_PVCS=$(kubectl get pods -n {{ .Release.Namespace }} \
-o=jsonpath='{.items[*].spec.volumes[*].persistentVolumeClaim.claimName}' | tr ' ' '\n' | sort -u)
NOW=$(date +%s)
#loop through all the pvcs annotating ones thare are mounted or lack a last-used stamp
for pvc in $ALL_PVC; do
ANNOTATION=$(kubectl get pvc "$pvc" -n {{ .Release.Namespace }} -o=jsonpath='{.metadata.annotations.last-used}')
if [ -z "$ANNOTATION" ]; then
kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW"
elif echo "$MOUNTED_PVCS" | grep -qx "$pvc"; then
kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW"
fi
done
33 changes: 13 additions & 20 deletions helm/blueapi/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ spec:
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
schedule: "*/5 * * * *"

jobTemplate:
spec:
# amount of attempts of labeling a pvc
Expand All @@ -52,28 +53,20 @@ spec:
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}

volumes:
- name : {{include "blueapi.fullname" . }}-pvc-stamper-script
configMap:
name: {{include "blueapi.fullname" . }}-pvc-stamper-script
defaultMode: 0500


containers:
- name: last-used-stamper
volumeMounts:
- name: {{include "blueapi.fullname" . }}-pvc-stamper-script
mountPath: /scripts
image: bitnami/kubectl:latest
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- |
# Get PVCs belonging to this blueapi release
ALL_PVC=$(kubectl get pvc -n {{ .Release.Namespace }} \
-o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | \
grep "^{{ .Release.Name }}-scratch-")
# Get all PVCs currently mounted by running pods
MOUNTED_PVCS=$(kubectl get pods -n {{ .Release.Namespace }} \
-o=jsonpath='{.items[*].spec.volumes[*].persistentVolumeClaim.claimName}' | tr ' ' '\n' | sort -u)
NOW=$(date +%s)
for pvc in $ALL_PVC; do
ANNOTATION=$(kubectl get pvc "$pvc" -n {{ .Release.Namespace }} -o=jsonpath='{.metadata.annotations.last-used}')
if [ -z "$ANNOTATION" ]; then
kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW"
elif echo "$MOUNTED_PVCS" | grep -qx "$pvc"; then
kubectl annotate --overwrite pvc "$pvc" -n {{ .Release.Namespace }} last-used="$NOW"
fi
done
command: ["/scripts/time-stamper.sh"]
restartPolicy: OnFailure
Loading