feat(chart): scheduled backup & defrag CronJobs - #138
Open
Jakob3xD wants to merge 5 commits into
Open
Conversation
Add opt-in backup/defrag value blocks and a rendered validations.yaml enforcing them. Also move the self-signed/cert-manager mutual-exclusion check out of _helpers.tpl (dead: Helm never executes underscore-partial top-level) into validations.yaml so it actually fires. Co-authored-by: Claude <noreply@anthropic.com>
Opt-in scheduled etcd snapshot: etcdctl snapshot into an emptyDir, then rclone upload to S3/MinIO (retention: none/count/age). Adds shared _helpers.tpl partials (cert volumes with cert-manager branching, non-root security contexts, endpointsCSV, pinned images). Backup pods use distinguishing labels so etcd Services never route to them. Co-authored-by: Claude <noreply@anthropic.com>
Opt-in scheduled etcd defragmentation via ahrtr/etcd-defrag against all members (--cluster), non-root and restricted-PSA compliant. Default rule is relative-fragmentation based (dbSizeInUse/dbSize <= 0.55 || dbQuotaUsage > 0.8), which scales with DB size unlike the absolute threshold in scripts/defrag.sh. Co-authored-by: Claude <noreply@anthropic.com>
Regenerate README via helm-docs for the new backup/defrag values, add artifacthub.io/changes entries, and point docs/backup.md + docs/defragmentation.md at the chart-managed CronJobs (scripts remain for ad-hoc use). Co-authored-by: Claude <noreply@anthropic.com>
The upload shell already treats the bucket folder as optional (${VAR:+/${VAR}}); requiring the secret key contradicted that and caused CreateContainerConfigError when the key was omitted. Final-review finding.
Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds two opt-in chart-managed CronJobs, closing the gap between the README roadmap (which lists Scheduled snapshots and Scheduled defragmentation as delivered) and the current reality where both ship only as
scripts/:backup.enabled— scheduledetcdctl snapshot saveinto anemptyDir, then upload to S3/MinIO via rclone. Retention is configurable:none(bucket lifecycle),count(keep N newest), orage(--min-age).defrag.enabled— scheduled defragmentation of all members via etcd-defrag (--cluster).Both default to
false→ no behavior change for existing installs (default render produces zero new objects). Refs #137.Design decisions
mc—mcis AGPL-3.0 and MinIO's client tooling is in maintenance mode; rclone is MIT, tiny, actively released, and configured entirely via env vars. The existingbackup-storage-secretcontract (storage-url,storage-access-key,storage-secret-key,storage-bucket-name,storage-bucket-folder) is unchanged.dbSizeInUse / dbSize <= 0.55 || dbQuotaUsage > 0.8. This scales with DB size, unlike the absolute> 200MiBthreshold inscripts/defrag.shwhich over-triggers on larger databases. Fully configurable viadefrag.rule.runAsNonRoot,runAsUser/Group/fsGroup: 1000,seccompProfile: RuntimeDefault,readOnlyRootFilesystem: true,capabilities.drop: [ALL],automountServiceAccountToken: false, secretdefaultMode: 0440. Verified that neither etcd-defrag noretcdctl snapshot saveneeds root here (the upstreamrunAsUser: 0example is for hostNetwork + host-path certs, which does not apply to secret-volume certs).clusterDomainandreplicas(no hardcodedcluster.local); pinned image tags (rclone1.74.4, etcd-defragv0.41.0), never:latest.app.kubernetes.io/name+instance) — otherwise the client/headless Services would route etcd client traffic to a backup/defrag pod.Incidental fix
Moved the
selfSignedCertificates/certManagermutual-exclusion guard out of_helpers.tplinto a renderedtemplates/validations.yaml. Helm does not execute top-level content of underscore-prefixed partials, so that guard was dead code — setting both flags true produced a broken render instead of the intended clear error. It now fires. The new backup-config validation lives in the same file.Testing
Verified with
helm lint+ ahelm templatematrix: default (0 objects), each retention mode, cert-manager vs self-signed cert branching, customclusterDomain, andreplicas=5endpoint scaling. helm-docs README regenerated (no CI drift).Not yet verified on a live cluster (no cluster access from the authoring environment) — reviewers/maintainers may want to confirm:
etcdutl snapshot statuspasses;readOnlyRootFilesystem: truedoesn't break rclone/etcdctl (a/tmpemptyDir is already provisioned for rclone as a precaution);retention.mode=count|ageprunes correctly (requires bucket delete permission).The
scripts/schedule.shandscripts/defrag.shhelpers are retained for ad-hoc use;docs/backup.mdanddocs/defragmentation.mdnow point at the chart values as the recommended path.🤖 Implemented with Claude Code.