Lesson 09 of 11 · Run it as a product
Day 2: keeping golden paths healthy
Creating a service takes minutes; keeping 300 of them current takes design. Learn why templates must stay thin, how shared and versioned building blocks plus automated update PRs carry fixes to every existing service, how to deprecate safely, and how to extend the scaffolder with your own actions.
The day-2 problem
A template runs once. The repository it creates is then owned by the team and drifts: someone edits the probes, someone pins an old base image. A year later you need to change something for every service (a security context, a CI scan, an observability sidecar), and there are 300 slightly different copies.
If every class photocopies the school rules and pins its own copy on the wall, changing a rule means visiting every classroom, and some copies have been doodled on. If every class instead has a sign saying "see the rules on the main noticeboard", you change the rule once.
Keep templates thin; put logic in shared building blocks
| Concern | Copied into the repo (avoid) | Referenced and versioned (prefer) |
|---|---|---|
| Kubernetes manifests | Full Deployment, Service, PDB | A Kustomize base or library Helm chart owned by the platform; the repo holds a few overrides |
| CI pipeline | 200 lines of pipeline YAML | include a versioned CI component / reusable workflow |
| Dockerfile | Hand-written per service | Shared base images, rebuilt centrally |
| Policies | Comments asking teams to comply | Admission policy enforcing it for everyone |
| Dashboards and alerts | JSON copied per service | Generated from labels by the platform |
The skeleton then contains little more than a kustomization.yaml pointing at platform/bases//web?ref=v1.4.0, a CI file including platform/ci/build@v2, the app code, docs and catalog-info.yaml.
Carry changes to existing services
- Release a new version of the building block (
v1.5.0) with release notes. - Renovate (or a similar bot) opens a pull request in every repository bumping the reference. Teams review and merge; CI runs their tests against the new version.
- Roll out by ring: merged changes deploy through the same GitOps rings as code changes.
- Track adoption with a scorecard ("on base ≥ v1.5") and a simple query across repositories.
- Enforce only what must be enforced (for example a security setting) with admission policy and a deadline, after the PRs have had time to land.
Version and deprecate templates
- Templates live in Git with versions; breaking changes create a new template (
golden-service-v2) instead of silently changing the old one. - Mark old templates deprecated in the catalog (tag, description) and hide them from Create after a date.
- Publish release notes for building blocks and templates, like any product.
- Keep an escape hatch: teams that need something unusual can override a base, but then own that part, and a scorecard shows it.
Extend the scaffolder with custom actions
When a template needs to call an internal system (create an on-call schedule, register a service in an API gateway, request a DNS name), write a custom action in a backend module:
// a backend module registering a scaffolder action (TypeScript, abbreviated)
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';
import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';
const createOnCall = createTemplateAction({
id: 'example:oncall:create',
description: 'Creates an on-call schedule for the owning team',
// input schema: service name, owner group …
async handler(ctx) { /* call the on-call API, write ctx.output('scheduleUrl', …) */ },
});
export const oncallModule = createBackendModule({
pluginId: 'scaffolder', moduleId: 'oncall',
register(env) {
env.registerInit({
deps: { scaffolder: scaffolderActionsExtensionPoint },
async init({ scaffolder }) { scaffolder.addActions(createOnCall); },
});
},
});
Register the module with backend.add(...); the action appears in /create/actions and templates can use it as a step. Keep actions idempotent (a re-run must not create duplicates) and give them clear error messages, because developers see them.
Try it
Move the lab template's deploy/ manifests into a shared Kustomize base in a platform/bases repository, tagged v1.0.0, and make the skeleton reference it. Create two services. Then change the probe settings in the base, tag v1.1.0, and update one service's reference: only that service changes, ring by ring. That is the day-2 workflow in miniature.
Recap
- Templates run once; existing services change only through what they reference.
- Keep templates thin; put manifests, CI and images in shared, versioned building blocks.
- Carry fixes with automated update PRs, ring rollouts, adoption scorecards and, where needed, policy with a deadline.
- Version and deprecate templates openly; extend them with idempotent custom actions.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.