mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 22:57:32 +00:00
feat(helm): render extra Kubernetes objects from an extraObjects list
The chart had no way to ship objects of the operator's own next to TREK, so a backup CronJob, a ConfigMap for it or any other helper had to live in a second release or be applied by hand (discussion #3194). extraObjects takes a list, empty by default so nothing renders, and renders each item through tpl: a map as YAML, a string as written, so names such as {{ .Release.Name }} resolve in both forms. The values comment, the chart README and the Helm wiki page say that braces are evaluated in both forms, that a backup job must mount the data volume read only, and that it should copy TREK's own backup archives rather than the live travel.db. Those archives carry the encryption key unless ENCRYPTION_KEY comes from the environment, so their destination needs the same protection as the volume. CI renders a variant with a CronJob in the map form and a ConfigMap in the string form, checks it with kubeconform -strict, and fails when a {{ is left unrendered.
This commit is contained in:
@@ -1224,6 +1224,14 @@ jobs:
|
||||
--set service.port=8080 \
|
||||
--set-json 'httpRoute={"enabled":true,"parentRefs":[{"name":"gateway","namespace":"gateway-system","sectionName":"https"}],"hostnames":["trek.example.com"],"paths":["/","/api"],"annotations":{"example.com/note":"custom route"},"timeouts":{"request":"0s","backendRequest":"0s"}}' \
|
||||
> "$out/http-route-variants.yaml"
|
||||
helm template trek charts/trek \
|
||||
--set-json 'extraObjects=[{"apiVersion":"batch/v1","kind":"CronJob","metadata":{"name":"{{ include \"trek.fullname\" . }}-backup-copy"},"spec":{"schedule":"0 3 * * *","jobTemplate":{"spec":{"template":{"spec":{"restartPolicy":"OnFailure","containers":[{"name":"copy","image":"busybox:1.36","command":["ls","/data/backups"],"volumeMounts":[{"name":"data","mountPath":"/data","readOnly":true}]}],"volumes":[{"name":"data","persistentVolumeClaim":{"claimName":"{{ include \"trek.fullname\" . }}-data","readOnly":true}}]}}}}}},"apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: {{ .Release.Name }}-notes\ndata:\n release: {{ .Release.Name | quote }}\n"]' \
|
||||
> "$out/extra-objects.yaml"
|
||||
# kubeconform accepts a name that still reads {{ ... }}, so check that both forms went through tpl.
|
||||
if grep -n '{{' "$out/extra-objects.yaml"; then
|
||||
echo "::error::extraObjects left a template unrendered"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check the manifests against the Kubernetes schemas
|
||||
# The pinned Gateway API schema adds HTTPRoute validation without skipping unknown resources.
|
||||
|
||||
Reference in New Issue
Block a user