Build an Internal Developer Platform — Backstage, Golden Paths & Crossplane›05 · Software templates

Lesson 05 of 11 · The golden path

Software templates

Write a golden-path software template that collects a few inputs, renders a skeleton repository with manifests and docs, publishes it to Git and registers it in the catalog. Every snippet here comes from a template tested end to end, including two bugs found on the way.

Advanced
Key wordssoftware templatesscaffoldertemplate.yamlparametersJSON Schemaui:fieldOwnerPickerskeletonfetch:templatepublishcatalog:registerstepsoutputsNunjucks

Anatomy of a template

A template is a catalog entity of kind Template with three parts: parameters (a form, described with JSON Schema), steps (actions run in order) and output (links shown at the end).

A template is a recipe card: the form asks how many people and which flavour, the steps say what to do in order, and at the end you get the cake, plus a note telling you where it is.

Parameters: a short, validated form

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: golden-service
  title: Golden path - HTTP microservice
  description: New service with manifests, probes, limits, docs and GitOps deployment.
  tags: [ recommended, kubernetes, gitops ]
spec:
  owner: group:platform
  type: service
  parameters:
  - title: Service details
    required: [ name, owner ]
    properties:
      name:
        title: Name
        type: string
        pattern: '^[a-z][a-z0-9-]{2,30}$'
        ui:help: Lowercase, digits and dashes. Becomes the repo and namespace name.
      owner:
        title: Owner team
        type: string
        ui:field: OwnerPicker
        ui:options:
          catalogFilter: { kind: Group }
      tier:
        title: Tier
        type: string
        enum: [ tier-1, tier-2, tier-3 ]
        default: tier-3
      replicas:
        title: Replicas
        type: integer
        default: 2
        minimum: 1
        maximum: 5

Keep it short: every question you ask is a decision the developer must make. Pick defaults; validate patterns; use pickers (OwnerPicker, EntityPicker) that read from the catalog.

Steps: render, publish, register

  steps:
  - id: fetch
    name: Render skeleton
    action: fetch:template
    input:
      url: ./skeleton
      values:
        name: ${{ parameters.name }}
        owner: ${{ parameters.owner }}
        tier: ${{ parameters.tier }}
        replicas: ${{ parameters.replicas }}
  - id: publish
    name: Create repository
    action: publish:gitea
    input:
      repoUrl: localhost:3300?owner=golden&repo=${{ parameters.name }}
      defaultBranch: main
  - id: register
    name: Register in catalog
    action: catalog:register
    input:
      # the publish step's repoContentsUrl had no branch: build the URL explicitly
      catalogInfoUrl: http://localhost:3300/golden/${{ parameters.name }}/src/branch/main/catalog-info.yaml
  output:
    links:
    - title: Repository
      url: ${{ steps['publish'].output.remoteUrl }}
    - title: Open in catalog
      icon: catalog
      entityRef: ${{ steps['register'].output.entityRef }}

publish:github, publish:gitlab, publish:bitbucketServer and others work the same way; the repoUrl host must match an entry under integrations in the app config.

The skeleton: everything the golden path promises

skeleton/
  catalog-info.yaml        owner, tags, annotations (techdocs, kubernetes-id, argocd app)
  mkdocs.yml, docs/        TechDocs
  deploy/                  Kubernetes manifests → this folder is the GitOps convention
    kustomization.yaml
    deployment.yaml        probes, requests/limits, securityContext, replicas from the form
    service.yaml
  (src/, Dockerfile, CI file in a real template)

Inside skeleton files, values appear as ${{ values.name }}; filters such as ${{ values.description | dump }} quote strings safely for YAML.

# skeleton/deploy/deployment.yaml (excerpt)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ${{ values.name }}
spec:
  replicas: ${{ values.replicas }}
  selector:
    matchLabels:
      app: ${{ values.name }}
  template:
    metadata:
      labels:
        app: ${{ values.name }}
        tier: ${{ values.tier }}
    spec:
      securityContext: { runAsNonRoot: true, runAsUser: 1000 }
      containers:
      - name: app
        image: ghcr.io/stefanprodan/podinfo:6.7.0
        ports: [ { containerPort: 9898 } ]
        readinessProbe: { httpGet: { path: /readyz, port: 9898 } }
        livenessProbe: { httpGet: { path: /healthz, port: 9898 } }
        resources:
          requests: { cpu: 50m, memory: 64Mi }
          limits: { memory: 128Mi }

Found while testing

runAsNonRoot: true on its own failed with an image whose user is a name rather than a number: the kubelet cannot prove a named user is non-root. Adding runAsUser: 1000 fixed it. Test every template against your real policies before publishing it.

Developing templates safely

  • Use the template editor (/create/edit) to load a local template and dry-run it.
  • Read real step outputs in the task log (/create/tasks) instead of guessing URL formats.
  • Keep templates in Git, reviewed like code, registered through a catalog location.
  • Never edit a template in a way that silently changes existing services: they don't change when the template does (lesson 9).

Try it

Put the template and skeleton in a Gitea repo, register template.yaml as a location, and run it from Create with the name tenant-api. Check: a repository in golden/, a catalog entity owned by the chosen group, docs rendered. Then try the name Tenant_API and see the form reject it.

Recap

  • Templates have parameters (validated form), steps (actions) and outputs (links).
  • The usual chain: fetch:template → publish:* → catalog:register.
  • The skeleton carries everything the golden path promises: manifests with probes and limits, docs, catalog file, the deploy/ convention.
  • Validate input, read real step outputs, test against real policies, and version templates in Git.

This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.