feat: migrate Woodpecker CI from SQLite to Postgres (CNPG) #59
No reviewers
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!59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "28-woodpecker-sqlite-to-postgres"
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?
Summary
Migrates Woodpecker CI from its default SQLite database to a CNPG-managed Postgres cluster. This resolves the known log streaming bug caused by SQLite limitations in the Kubernetes backend, and brings Woodpecker's data layer in line with the rest of the platform's Postgres infrastructure.
Changes
terraform/variables.tf-- Addedwoodpecker_db_passwordvariable (sensitive)terraform/k3s.tfvars.example-- Addedwoodpecker_db_passwordplaceholderterraform/main.tf-- Added 3 new resources:kubernetes_secret_v1.woodpecker_cnpg_s3_creds-- S3 creds in woodpecker namespace for WAL archivingkubernetes_secret_v1.woodpecker_db_credentials-- DB user/pass secret for CNPG bootstrapkubernetes_manifest.woodpecker_postgres-- CNPG Cluster CR (1 instance, 2Gi storage, WAL to MinIO, PodMonitor)terraform/main.tf-- Updated Woodpecker Helm release:WOODPECKER_DATABASE_DRIVER=postgresandWOODPECKER_DATABASE_DATASOURCEenv varskubernetes_manifest.woodpecker_postgrestodepends_on.woodpecker.yaml-- AddedTF_VAR_woodpecker_db_passwordsecret to bothplanandapplyCI stepsTest Plan
tofu fmt -checkandtofu validateon this PRtofu planoutput posted as PR comment by CIwoodpecker-dbpod is Running in woodpecker namespaceReview Checklist
tf_var_woodpecker_db_passwordsecret to Woodpecker CI for this repowoodpecker_db_passwordto localk3s.tfvarsRelated
plan-pal-e-platformReview-Fix Loop -- Pass 1
Result: PASS -- no issues found.
Reviewed all 4 changed files (124 additions, 5 deletions):
k3s.tfvarsis gitignored; only the.examplefile has a placeholder. Password variable issensitive = true. Datasource uses interpolation, not hardcoded values.s3://postgres-wal/woodpecker/), same MinIO IAM user, same compression and storage class settings.woodpecker_postgresdepends on CNPG operator + both secrets. Woodpecker Helm release depends on Forgejo + the new CNPG cluster.TF_VAR_woodpecker_db_passwordadded to bothplanandapplysteps, consistent placement.tofu fmt -checkpasses clean.No fixes needed. PR is ready for human review.
Review — Pass (with pre-merge checklist)
Files changed: 4 (+124 / -5)
Code Review
All changes are correct and well-structured:
CNPG Cluster CR — Follows the existing pal-e-postgres pattern. Correct image (17.4-1), storage (2Gi local-path), backup to
s3://postgres-wal/woodpecker/with gzip compression, 7d retention, PodMonitor enabled.depends_onchain is correct: CNPG operator → secrets → Cluster → Helm release.S3 creds duplication — Necessary because CNPG looks for the secret in its own namespace. Reuses the shared
minio_iam_user.cnpgIAM user which already haspostgres-walbucket access.DB credentials secret — Uses
kubernetes.io/basic-authtype as required by CNPG bootstrap.Helm values update —
WOODPECKER_DATABASE_DRIVER=postgresand datasource URL withsslmode=disable(fine for in-cluster). Env block alignment is cosmetic. No lines were lost —SKIP_VERIFYwas already removed in PR #56.CI pipeline — Secret wired in both plan and apply steps. Variable definition is sensitive.
No secrets committed —
k3s.tfvars.examplehas placeholder, not real password.Risk Assessment
HIGH — Woodpecker downtime is expected. All SQLite data will be lost:
Pre-Merge Checklist
woodpecker_db_password = "kM3L4AhLNiuMhIY7tMQ"to localk3s.tfvarstf_var_woodpecker_db_passwordCI secret in Woodpecker for this repoPost-Merge Verification
kubectl get cluster -n woodpeckershows healthykubectl logs woodpecker-server-0 -n woodpeckershows postgres driver