From 9c489b98cf205db40a4248428f167ce473337f09 Mon Sep 17 00:00:00 2001 From: Robin Bourianes Date: Thu, 22 Aug 2024 09:25:39 +0200 Subject: [PATCH] feat(kargo): new template to generate a cronjob to inspect volumes --- CHANGELOG.md | 1 + .../templates/_volume-inspector-cronjob.yaml | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 charts/kargo/templates/_volume-inspector-cronjob.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e3efe76..2c2933f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added + - Added a new template in the `kargo` chart to generate a suspended cronjob allowing to inspect volumes: `kargo.volume-inspector-cronjob`. - Added new `trakkar` chart to deploy [traccar](https://www.traccar.org/) <-> kano gateway. ### Changed diff --git a/charts/kargo/templates/_volume-inspector-cronjob.yaml b/charts/kargo/templates/_volume-inspector-cronjob.yaml new file mode 100644 index 00000000..f3d1914e --- /dev/null +++ b/charts/kargo/templates/_volume-inspector-cronjob.yaml @@ -0,0 +1,43 @@ +{{/* +Builds a suspended cronjob to inspect k8s volumes. +@param .context The caller's context +@param .args The parameters for the inspector. The template expects the following: + - name The name to give to the cronjob + - volumeMounts The list of volumeMounts for the container + - volumes The list of volumes to back volumeMounts + - image An object defining the image to pull, cf. kargo.images.image template +*/}} +{{- define "kargo.volume-inspector-cronjob" -}} +apiVersion: {{ .context.Capabilities.APIVersions.Has "batch/v1" | ternary "batch/v1" "batch/v1beta1" }} +kind: CronJob +metadata: + name: {{ .args.name }} + namespace: {{ .context.Release.Namespace | quote }} +spec: + suspend: true + schedule: "0 0 * * *" + concurrencyPolicy: Forbid + jobTemplate: + spec: + ttlSecondsAfterFinished: 3600 + template: + spec: + {{- include "kargo.images.pullSecrets" (dict "images" (list .args.image) "context" .context) | indent 10 }} + containers: + - name: {{ .args.name }} + image: {{ include "kargo.images.image" ( dict "imageRoot" .args.image "global" .context ) }} + command: + - /bin/sh + args: + - -c + - while true; do sleep 30; done + {{- if .args.volumeMounts }} + volumeMounts: + {{- include "kargo.tplvalues.render" ( dict "value" .args.volumeMounts "context" .context ) | nindent 14 }} + {{- end }} + restartPolicy: Never + {{- if .args.volumes }} + volumes: + {{- include "kargo.tplvalues.render" ( dict "value" .args.volumes "context" .context ) | nindent 10 }} + {{- end }} +{{- end -}}