Backup all helm stacks
Recently we implemented CI/CD
using linktohack/helm-stack: Ultimate Helm chart to deploy all kinds of stack and I find the need for a way to export and backup all the values
and manifests
of our applications .
This Makefile
allows me to make snapshot
and make template
in a CronJob
to back up all of our stack. It comes with an extra target template-latest
to generate the latest manifest of the stack, but can be of course adapted to generate whatever version of the manifest (1.25
, 1.22
, 1.18
etc.).
snapshot:
helm ls -A -o json \
| jq -r '.[] | "echo \(.namespace)/\(.name) && mkdir -p values/\(.namespace) && helm -n \(.namespace) get values \(.name) | sed /USER-SUPPLIED/d > values/\(.namespace)/\(.name)-\(.chart).yaml"' \
| sort \
| sh -
template:
helm ls -A -o json \
| jq -r '.[] | "echo \(.namespace)/\(.name) && mkdir -p values/\(.namespace) && helm -n \(.namespace) get manifest \(.name) > values/\(.namespace)/\(.name)-\(.chart).spec.yaml"' \
| sort \
| sh -
template-latest:
helm ls -A -o json \
| jq -r '.[] | select (.chart | startswith("stack-")) | "echo \(.namespace)/\(.name) && mkdir -p values/\(.namespace) && helm -n \(.namespace) template \(.name) link/stack -f values/\(.namespace)/\(.name).yaml > values/\(.namespace)/\(.name)-latest.spec.yaml"' \
| sort \
| sh -
Read other posts