database: mirror admin-app-db-url into westside-admin namespace #310
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
ldraney/pal-e-platform!310
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "135-cross-ns-secret-mirror"
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
Adds a second
kubernetes_secret_v1in thewestside-adminnamespace that mirrors theadmin-app-db-urlsecret created inbasketball-apiby PR #304. Both secrets deriveDATABASE_URLfrom a singlelocal.admin_app_database_urlexpression backed byvar.admin_app_db_password, so a Salt-pillar password rotation propagates atomically to both namespaces in onemake tofu-apply.Decision per scope review on
forgejo_admin/pal-e-deployments#135(Lucas-approved 2026-04-25): option 4 (terraform mirror beside the source). Rejected cluster-wide replicators (kubernetes-replicator, ESO) and SOPS duplication.Changes
terraform/modules/database/main.tfDATABASE_URLvalue intolocal.admin_app_database_urlso the source secret and the mirror reference the same expressiondata "kubernetes_namespace_v1" "westside_admin"so apply fails fast if the deployments overlay has not yet created the namespacekubernetes_secret_v1.admin_app_db_url_westside_admin-- same secret name (admin-app-db-url), same key (DATABASE_URL), in thewestside-adminnamespace, labeledmirror-of: basketball-api/admin-app-db-urlterraform/modules/database/outputs.tfadmin_app_db_url_secret_nameandadmin_app_db_url_namespacesoutputs for debugging and operator visibilitytofu plan Output
tofu planwas not run locally because the operator-sidek3s.tfvars(with the Salt-pillar-derivedadmin_app_db_password) is not in this worktree. CI will plan against the live state.tofu validatepasses clean.Apply order
pal-e-deploymentsoverlay (already createswestside-adminnamespace -- merged in #134)pal-e-platformmake tofu-apply(this PR -- creates the mirror)pal-e-deploymentsPR (rewires the deployment'sDATABASE_URLto the new mirror) can merge in any order; ArgoCD will reconcile once the mirror exists.Test Plan
make tofu-apply:kubectl get secret admin-app-db-url -n westside-admin -o jsonpath='{.data.DATABASE_URL}' | base64 -dmatches the same query against-n basketball-apiadmin_app_db_passwordin Salt pillar,make tofu-apply, confirm both secrets show new value, thenkubectl rollout restart deployment/westside-admin -n westside-adminReview Checklist
fmtclean,validatecleanadmin_app_db_urlon basketball-api) unchanged in shape -- only the value expression was extracted into a localadmin-app-db-url) so no consumer-side renaming is requiredRelated Notes
review-135-2026-04-25(Lucas-approved option 4)feedback_tofu_lock_false,feedback_discovered_scope_always_trackedRelated
forgejo_admin/pal-e-deploymentsbranch135-drop-database-url-sops(drops SOPS placeholder + rewiressecretKeyRef)🤖 Generated with Claude Code
PR #310 Review
DOMAIN REVIEW (Terraform / k8s secrets)
Single source of truth: Verified.
local.admin_app_database_urlis defined once (main.tf:291-293) and referenced by BOTHkubernetes_secret_v1.admin_app_db_url(line 259) andkubernetes_secret_v1.admin_app_db_url_westside_admin(line 314). Avar.admin_app_db_passwordrotation propagates atomically to both namespaces in a singletofu apply. No string duplication.Source secret unchanged in shape: The basketball-api secret's metadata, labels, name, key, and
depends_onare identical to PR #304's resource. The only delta is thedatavalue being read from alocalinstead of an inline expression — semantically equivalent, no resource recreation expected (Terraform should show a no-op or in-place update on the data block).Namespace dependency soundness:
data "kubernetes_namespace_v1" "westside_admin"is referenced viametadata[0].namein the mirror's namespace field — implicit dependency is correct. Apply will fail fast with the standard kubernetes provider "namespaces 'westside-admin' not found" error if the deployments overlay hasn't created the ns. Acceptable gate; the PR body documents the apply ordering.No replicator / ESO / cluster-wide controllers: Confirmed. Pure native
kubernetes_secret_v1× 2.No source modification at deployment level: Confirmed (this PR doesn't touch deployments; sibling PR #136 handles the secretKeyRef rewire).
Labels: Mirror carries
mirror-of: basketball-api/admin-app-db-urlplus the standardmanaged-by,story,archlabels. Good operator visibility.Outputs:
admin_app_db_url_secret_nameandadmin_app_db_url_namespacesare well-scoped diagnostic outputs; the namespaces list will surface drift if either resource ever moves.Tofu hygiene: Diff is
tofu fmt-clean (alignment is consistent with the rest of the file). PR body assertstofu validatepasses; no syntax red flags on read.CI / meta-fix integration test (#309): Pipeline #456 (push event, branch
135-cross-ns-secret-mirror) returnedstatus: success. Nounterminated quoted stringregression. The #309 Woodpecker shell-escape fix is verified general against this terraform-touching diff. No PR-event pipeline is configured for this repo (push is the integration signal). Note: the curated step list returned onlyclone— full plan-step output not surfaced here, but the overall pipeline status is success and matches the Forgejo combined commit status.BLOCKERS
None.
NITS
admin_app_db_url_westside_adminbelow" in a follow-up. Non-blocking.outputs.tfadmin_app_db_url_namespacesorder is positional (basketball-api first, westside-admin second). Operators reading the output won't know which is which without reading the resource defs. Amapkeyed by namespace label (e.g.{ source = ..., mirror = ... }) would be slightly more self-documenting. Non-blocking.make tofu-applyruns and the post-apply kubectl base64 comparison is done, the boxes should be ticked or the verification noted in a comment. (Validation-pipeline concern, not a code concern.)SOP COMPLIANCE
135-cross-ns-secret-mirror— matches{issue-number}-{kebab-case}conventionforgejo_admin/pal-e-deployments#135,story:admin-row-crud,arch:postgres,arch:k8s-deploy.env/ credentials in diff (password sourced fromvar.admin_app_db_passwordSalt pillar)review-135-2026-04-25referencedtofu fmt/tofu validatereported clean (caveat:tofu plandeferred to CI per missing localk3s.tfvars— acceptable)PROCESS OBSERVATIONS
kubectl rollout restart.VERDICT: APPROVED