Add TF state backup CronJob to MinIO #36
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-platform#36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lineage
plan-pal-e-platform→ Phase 6 (CI Pipeline Hardening) → Phase 6.1 (State Backup CronJob)Repo
forgejo_admin/pal-e-platformUser Story
As the platform operator
I want Terraform state secrets automatically backed up daily to MinIO
So that I can recover from state corruption or loss in minutes instead of hours (MTTR)
Context
Both Terraform repos (pal-e-platform, pal-e-services) use a Kubernetes backend for state, stored as secrets in the
tofu-statenamespace. There are currently no backups of these secrets. If state is corrupted during a bad apply, recovery means manual state reconstruction.This is the safety net that makes CI-driven
tofu apply(Phase 6.4) safe to deploy. Backup first, automate second.Key technical facts:
tofu-statenamespacetfstate-default-pal-e-platformandtfstate-default-pal-e-servicestfstatekey, base64-encodedminionamespace, S3 API athttp://minio.minio.svc.cluster.local:9000minio_iam_user.cnpgandminio_iam_policy.cnpg_walinterraform/main.tfminio_s3_bucket.postgres_walinterraform/main.tfFile Targets
Files to modify:
terraform/main.tf— add: MinIO bucket (tf-state-backups), MinIO IAM user + policy, k8s Secret for MinIO creds intofu-statenamespace, CronJob resource, ServiceAccount + RBAC for reading state secretsFiles NOT to touch:
terraform/variables.tf— no new variables needed (MinIO creds come from IAM user resource outputs)salt/— host-level config, not relevant.woodpecker.yaml— separate issueAcceptance Criteria
tf-state-backupscreated viaminio_s3_bucketresourcetf-backupwith policy allowingGetObject,PutObject,DeleteObject,ListBucketontf-state-backupstofu-statenamespace with MinIO access credentialstofu-statenamespace with RBAC to read secrets (tfstate-default-pal-e-platform,tfstate-default-pal-e-services)tofu-statenamespace that:0 2 * * *)tfstatekey, uploads tos3://tf-state-backups/{secret-name}-{date}.jsonbitnami/minio-clientoralpinewithcurl)tofu validatepassestofu fmtappliedTest Expectations
tofu planshows expected new resources (bucket, IAM, Secret, ServiceAccount, Role, RoleBinding, CronJob)kubectl create job --from=cronjob/<name> test-backup -n tofu-statemc lsConstraints
main.tffor MinIO resources (seeminio_s3_bucket.postgres_wal,minio_iam_user.cnpg,minio_iam_policy.cnpg_wal)kubernetes_cron_job_v1resource (not manifest)depends_onchains# --- TF State Backup ---)Checklist
Closes #36in bodytofu planoutput included in PR descriptiontofu fmtandtofu validatepassRelated
project-pal-e-platform— projectphase-pal-e-platform-ci-6-1-state-backup— phase note in pal-e-docs