feat: add staging namespace module for validation pipeline #218
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!218
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "213-staging-namespace-and-network-policies"
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 the
stagingKubernetes namespace as a new Terraform module with default-deny network policy, root orchestrator wiring, and output exposure. This is the pal-e-platform foundation for the dev-staging-prod validation pipeline.Changes
terraform/modules/staging/main.tf— New module creating thestagingnamespace withenvironment=staginglabelterraform/modules/staging/outputs.tf— Exposesstaging_namespacefor downstream consumersterraform/modules/staging/variables.tf— Empty (namespace is self-contained; ArgoCD deploys workloads)terraform/modules/staging/versions.tf— Kubernetes provider requirementterraform/main.tf— Wiresmodule.staginginto the root orchestratorterraform/network-policies.tf— Addsnetpol_stagingdefault-deny policy allowing ingress from tailscale, staging (intra-ns), monitoring, argocd, and woodpeckerterraform/outputs.tf— Exposesstaging_namespaceat root levelscripts/woodpecker-update-tag-step.yaml— DocumentsOVERLAY_ENVtiers (prod/staging) and adds commented staging deploy step templatetofu plan Output
Cannot run
tofu planfrom worktree (no backend access).tofu validateandtofu fmt -checkboth pass clean. Expected plan output:No existing resources modified or destroyed.
Test Plan
tofu validatepassestofu fmt -recursive -checkpasses (no formatting drift)scripts/test-update-kustomize-tag.shpasses (7/7)tofu apply: verifykubectl get ns stagingexists with correct labelskubectl get networkpolicy -n stagingshows default-deny-ingressReview Checklist
tofu fmt -recursivecleantofu validatepassesRelated Notes
Related
QA Review
Module Structure
terraform/modules/staging/follows the exact 4-file convention (main.tf, outputs.tf, variables.tf, versions.tf) established by all other modules. Clean.Root Orchestrator Wiring
module.stagingplaced after ops, before moved blocks. No dependencies needed since staging is independent of other modules. Correct.Network Policy
field_manager { force_conflicts = true }matches every other netpol in the file.Output
staging_namespaceexposed at root level for downstream consumers (pal-e-services, pal-e-deployments). Matches pattern of other namespace outputs.Woodpecker Template
OVERLAY_ENVtier documentation is helpful for downstream adoption.Validation
tofu validatepassestofu fmt -recursive -checkcleanNits
None.
VERDICT: APPROVE
PR #218 Review
DOMAIN REVIEW
Tech stack: Terraform/OpenTofu (Kubernetes provider), k8s NetworkPolicy, Woodpecker CI YAML template.
Module structure: The new
terraform/modules/staging/module follows the established four-file convention (main.tf,outputs.tf,variables.tf,versions.tf). The root orchestrator wiring interraform/main.tfplaces the module correctly betweenopsand themoved{}blocks section. The network policy interraform/network-policies.tffollows the identicalkubernetes_manifestpattern used by all other namespace policies (field_manager, default-deny-ingress, namespaceSelector matchLabels). The rootterraform/outputs.tfexposes the namespace consistently with other outputs.Network policy analysis: The staging netpol allows ingress from tailscale (external access), staging (intra-namespace), monitoring (metrics scraping), argocd (deployment sync), and woodpecker (CI pipeline). This is a reasonable initial allowlist for a pre-prod namespace. Notably missing but likely intentional: no postgres/database ingress (staging services will need their own DB access rules once workloads are deployed -- this is correctly deferred as downstream scope).
Woodpecker template: The
woodpecker-update-tag-step.yamlchanges are documentation-only. The commented staging step template is correct and consistent with the prod step pattern. TheOVERLAY_ENVvariable is already supported byscripts/update-kustomize-tag.sh(line 30:OVERLAY_ENV="${OVERLAY_ENV:-prod}"), so the template will work when uncommented.versions.tf discrepancy: The staging module's
versions.tfdeclaressource = "hashicorp/kubernetes"but omits theversionconstraint. Every other module in the codebase pinsversion = "~> 2.36". Compare:terraform/modules/staging/versions.tf: no version pinterraform/modules/keycloak/versions.tf:version = "~> 2.36"terraform/modules/ops/versions.tf:version = "~> 2.36"terraform/modules/database/versions.tf:version = "~> 2.36"This is inconsistent but non-blocking since the root module's lock file governs the actual version used. Still, it breaks the established pattern.
BLOCKERS
None. This is a clean, minimal infrastructure PR:
tofu validate)NITS
Missing version constraint in
versions.tf: Addversion = "~> 2.36"to the kubernetes provider interraform/modules/staging/versions.tfto match all other modules. Currently the only module without a version pin.Staging step placement note: The
woodpecker-update-tag-step.yamlcomment says "Add this step BEFORE the prod update-kustomize-tag step" but the commented template appears AFTER the prod step in the file. When someone copy-pastes this into a real.woodpecker.yaml, the comment instruction and the file order send mixed signals. Consider reordering the blocks (staging first, prod second) to match the intended execution order, or adjust the comment to say "Copy this step and place it before the prod step in your .woodpecker.yaml."SOP COMPLIANCE
213-staging-namespace-and-network-policiesreferences issue #213Closes #213present, discovered scope itemized for downstream repostofu fmtandtofu validatereported as passingtofu planoutput: not included (documented as "Cannot run from worktree"). PR conventions require plan output for Terraform changes, but the worktree limitation is a known constraint. The expected plan output (2 new resources, 0 modified/destroyed) is documented.PROCESS OBSERVATIONS
kubernetes_namespace_v1.staging,kubernetes_manifest.netpol_staging), zero modifications to existing infrastructure. No state migration needed (new module, nomoved{}blocks).VERDICT: APPROVED