Skip to content

CICD-419 · Self-service namespace provisioning ​

Encyclopedia · Platform engineering and internal developer platforms · All snippets

Previous · CICD-418 · Next · CICD-420

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites platform sandbox, scoped identities and reviewed service catalog or provisioning policy.
  • Platforms kubernetes, local-lab.
  • Parameters TEAM_NAMESPACE.

2. Copy the snippet ​

bash
[[ "${TEAM_NAMESPACE:?}" =~ ^team-[a-z0-9-]+$ ]]
kubectl create namespace "$TEAM_NAMESPACE" --dry-run=client -o yaml | kubectl apply -f -
kubectl -n "$TEAM_NAMESPACE" apply -f platform/baseline/

3. How it works ​

Client dry run renders a candidate object locally so it can be reviewed or piped into a separate apply.

4. Verify the result ​

Baseline must include quota, network policy and narrowly scoped RBAC. Prefer reconciliation controlling the namespace lifecycle.

Watch for. Use an independently reviewed target, owner and scoped write identity. Confirm the resulting state separately.

Validation syntax-validated (Bash parse). Status definitions.