Lesson 3 of 9 · 25m
Templates, Paved Roads, and Guardrails That Scale
Turn golden paths into maintained repository templates, policy-as-code guardrails, and composable building blocks instead of snowflake bootstrap scripts.
The first template is easy. The fiftieth divergence of that template is where platform teams earn their pay. A template system has to do three jobs at once: initialize a service quickly, encode organizational guardrails, and remain upgradeable after the original author forgets the service exists. Copying files is only the visible tenth of the problem.
Separate bootstrap, configuration, and policy
New developers often merge these layers into one script. Resist that:
bootstrap initial repository and service skeleton
configuration service-specific choices such as name, owner, resources
policy non-negotiable controls enforced by the platform
runtime controllers, pipelines, and controllers applying those choicesA repository template can create files, but policy decides whether a deployment is allowed. Configuration declares intent, but controllers reconcile it. Keeping these layers distinct prevents template forks from weakening controls.
A real service scaffold has sharp edges removed
A minimal scaffold for a production HTTP service usually includes:
service repo skeleton
app/ application source
deploy/ platform manifests or Helm values
.github/workflows/ build, test, scan, deploy workflow
catalog-info.yaml ownership and system metadata
Dockerfile reproducible build
Makefile or justfile common local commands
README.md operational quickstart
tests/ smoke and contract test locationsDo not worship the file list. Worship the operational outcome: after creation, make test, docker build, and the first deployment should either work or fail with an explanation a new hire can act on.
Encode policy close to enforcement
Policy-as-code is most useful where the decision is made. Kubernetes admission policy, CI checks, source-control rules, and cloud guardrails each catch different classes of mistakes:
package platform.deploy
deny[msg] {
input.kind == "Deployment"
some c
c := input.spec.template.spec.containers[c]
not c.resources.limits.memory
msg := sprintf("container %s has no memory limit", [c.name])
}This is not about making policy clever. It is about making failure immediate and precise. "Denied by policy POL-042" sends people hunting through a wiki; "container api has no memory limit" sends them toward the fix.
CI is part of the template, not an afterthought
A paved-road pipeline should expose a small interface:
# .github/workflows/service.yml
name: service
on:
push:
branches: [main]
pull_request:
jobs:
service:
uses: platform-org/service-pipeline/.github/workflows/reusable.yml@v7
with:
service-name: payments-api
environment: production
secrets: inheritThe reusable workflow can enforce scanning, artifact signing, provenance, deployment sequencing, and rollback behavior. Teams see a clean interface; the platform retains one place to improve the machinery.
Composition beats the mega-template
Avoid template-java-service-final-v2-FINAL. Compose capabilities: observability, database access, messaging, feature flags, preview environments. Each capability should have a small contract and independent versioning. A team using three supported capabilities should not inherit ten irrelevant ones.
Field notes
- Every template input becomes an API you must support; ask only for information the platform cannot infer.
- Templates that generate generated files need idempotent regeneration rules, or drift becomes unreviewable.
- Policy exceptions expire. Permanent exceptions are how temporary risk becomes architecture.
- If a control matters, test it in CI and enforcement. A policy document without a failing test is a wish.
Was this lesson helpful?