How To: Write one deployment base for many spokes with parameter sets
A hub-and-spoke platform repeats the same deployment for every spoke: the same workspace, the
same environments, the same properties, with only a name, a subscription and a code changed.
Copying the deployment per spoke works until the copies drift. This guide writes the deployment
once, as a base that reads its values with ${param:<role>.<key>}, and gives each spoke one
parameter set and one short leaf.
The solution below is complete: two hubs, two spokes and one customer project. Every file is shown
with its path. strata finds documents by kind and meta.name, never by folder, so the layout is
one that reads well, not one strata requires. A test builds this exact solution from this page and
validates it, so what you see here works.
The layout
strata.yaml
platform/ shared documents: providers, workspaces, shared environments
provider.yaml
workspace-spoke.yaml
workspace-customer.yaml
environment-solution.yaml
tenants/
acme.yaml
initech.yaml
stacks/ one base per stack, with its defaults
spoke/deployment.yaml
spoke/defaults.yaml
customer/deployment.yaml
hubs/
hub01/hub.yaml the hub's parameter set and environment
hub01/environment.yaml
hub01/acme-001/spoke.yaml the spoke's parameter set
hub01/acme-001/deploy-spoke.yaml
hub01/acme-001/acmep01/customer.yaml
hub01/acme-001/acmep01/deploy-customer.yaml
hub02/hub.yaml
hub02/environment.yaml
hub02/initech-001/spoke.yaml
hub02/initech-001/deploy-spoke.yaml
Everything about one spoke lives in its folder, and everything every spoke shares lives in
stacks/.
2. One parameter set per hub, spoke and customer project
A parameter set is plain values. It does not say what it is for: the deployment that names it
gives it a role (hub, spoke, customer), and bases read ${param:<role>.<key>}. So the
spoke’s code and the customer’s code never collide: one is spoke.code, the other
customer.code.
# hubs/hub01/hub.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: parameterset
meta:
name: hub-hub01
spec:
values:
name: hub01
# hubs/hub02/hub.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: parameterset
meta:
name: hub-hub02
spec:
values:
name: hub02
region: westus2 # overrides the stack default below
# hubs/hub01/acme-001/spoke.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: parameterset
meta:
name: spoke-acme-001
spec:
values:
name: acme-001
tenant: acme
code: acme
seq: "001" # quoted: 001 unquoted is the number 1
subscription_id: 00000000-0000-0000-0000-000000000001
# hubs/hub02/initech-001/spoke.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: parameterset
meta:
name: spoke-initech-001
spec:
values:
name: initech-001
tenant: initech
code: initech
seq: "001"
subscription_id: 00000000-0000-0000-0000-000000000002
# hubs/hub01/acme-001/acmep01/customer.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: parameterset
meta:
name: customer-acmep01
spec:
values:
code: acmep01
project: p01
A parameter set holds no ${...} tokens and no secrets: it is plain text in git. Keep
${secret:} in the document that needs the secret.
3. One base per stack
The spoke base is the whole spoke deployment, written once. Its own params names a set of
defaults for the hub role, like a chart’s values.yaml: a hub’s own set overrides them key by
key.
# stacks/spoke/defaults.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: parameterset
meta:
name: hub-defaults
spec:
values:
region: westeurope
# stacks/spoke/deployment.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: deployment
meta:
name: spoke_deployment_base
params: { hub: hub-defaults }
name_rule: spoke-${param:spoke.name}
spec:
partial: true
workspace: spoke
tenant: ${param:spoke.tenant}
layers:
segments:
hub: ${param:hub.name}
spoke: ${param:spoke.name}
environments:
- solution-env
- hub-${param:hub.name}-env
properties:
region: ${param:hub.region}
subscription_id: ${param:spoke.subscription_id}
state_account: sttfstate${param:spoke.code}${param:spoke.seq}
${param:}works in reference fields too:tenantand the environmenthub-${param:hub.name}-envare checked as real names once each spoke’s values are filled in.name_rulekeeps names honest: every deployment built on this base must be namedspoke-<spoke name>. Names stay plain text, so every command still finds a deployment by its name, but they cannot drift from the values.
The customer base reads three roles: the spoke it runs in, the hub, and its own project.
# stacks/customer/deployment.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: deployment
meta:
name: customer_deployment_base
name_rule: customer-${param:spoke.name}-${param:customer.code}
spec:
partial: true
workspace: customer
tenant: ${param:spoke.tenant}
environments:
- solution-env
- hub-${param:hub.name}-env
properties:
project: ${param:customer.project}
deploy_code: ${param:customer.code}
subscription_id: ${param:spoke.subscription_id}
4. One short leaf per spoke and per project
A leaf names its sets per role and extends the base. That is all it holds, unless it has an exception of its own.
# hubs/hub01/acme-001/deploy-spoke.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: deployment
meta:
name: spoke-acme-001
params: { hub: hub-hub01, spoke: spoke-acme-001 }
spec:
extends: spoke_deployment_base
# hubs/hub02/initech-001/deploy-spoke.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: deployment
meta:
name: spoke-initech-001
params: { hub: hub-hub02, spoke: spoke-initech-001 }
spec:
extends: spoke_deployment_base
# hubs/hub01/acme-001/acmep01/deploy-customer.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: deployment
meta:
name: customer-acme-001-acmep01
params: { hub: hub-hub01, spoke: spoke-acme-001, customer: customer-acmep01 }
spec:
extends: customer_deployment_base
Every leaf behind hub02 names hub: hub-hub02. A set never names the sets it builds on, and
nothing is implied by the folder: one name per leaf is the price of every value being explicit.
Each hub still has its own environment. An environment can also be built on a base that reads parameter sets (How To: tenant and environment bases); with one variable per hub, writing each out is shorter:
# hubs/hub01/environment.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: environment
meta:
name: hub-hub01-env
spec:
variables:
- { key: hub_vnet, store: constant, type: string, value: vnet-hub01 }
# hubs/hub02/environment.yaml
apiVersion: strata.huybrechts.xyz/v2
kind: environment
meta:
name: hub-hub02-env
spec:
variables:
- { key: hub_vnet, store: constant, type: string, value: vnet-hub02 }
5. Check it
strata validate
strata deploy list
strata deploy list shows each leaf as resolved (spoke-initech-001 with tenant initech
and environments solution-env, hub-hub02-env) and each base as written, tokens and all. The
merged result for spoke-initech-001:
spec:
workspace: spoke
tenant: initech
layers: { segments: { hub: hub02, spoke: initech-001 } }
environments: [solution-env, hub-hub02-env]
properties:
region: westus2 # hub-hub02 overrides hub-defaults
subscription_id: 00000000-0000-0000-0000-000000000002
state_account: sttfstateinitech001
To see where each value comes from, render the deployment. Every field names the document that wrote it; a value filled in from a parameter set shows the text as written and the set it read:
strata render deployment spoke-initech-001
deployment spoke-initech-001
chain: spoke-initech-001 <- spoke_deployment_base
parameter sets: hub: hub-defaults, hub-hub02; spoke: spoke-initech-001
FIELD VALUE FROM FILLED IN FROM
spec.workspace spoke spoke_deployment_base
spec.environments[1] hub-hub02-env spoke_deployment_base 'hub-${param:hub.name}-env': hub.name = hub02 (hub-hub02)
spec.tenant initech spoke_deployment_base '${param:spoke.tenant}': spoke.tenant = initech (spoke-initech-001)
spec.properties.region westus2 spoke_deployment_base '${param:hub.region}': hub.region = westus2 (hub-hub02)
spec.properties.state_account sttfstateinitech001 spoke_deployment_base 'sttfstate${param:spoke.code}${param:spoke.seq}': spoke.code = initech (spoke-initech-001), spoke.seq = 001 (spoke-initech-001)
...
strata render also takes environment and tenant, and -o json for the full origin of
every field. Secret values are always masked.
A deployment built on a base runs like any other: strata build run spoke-initech-001. A base
does not run on its own.
6. When something is wrong
strata reports a problem on the file you wrote, says which values made it, and names the deployment it was resolving:
A value is missing.
${param:spoke.subscription}in the base, but the sets holdsubscription_id:spoke_deployment_base spec.properties.subscription_id: ${param:spoke.subscription} not found in spoke: [spoke-acme-001] (for spoke-acme-001)A name does not exist once filled in. A spoke set says
tenant: acmee:spoke_deployment_base spec.tenant: unknown tenant 'acmee' ... from '${param:spoke.tenant}': spoke.tenant = 'acmee' (spoke-acme-001) (for spoke-acme-001)A leaf has the wrong name.
meta.name: spoke-acmeunder the spoke base:Deployment 'spoke-acme' must be named 'spoke-acme-001' by the name_rule of 'spoke_deployment_base'A value nothing reads is information, not an error (
param_unused): a set may hold more than one deployment needs.strata validate --strictstill passes.
Adding a spoke
Two files in a new folder, nothing else:
hubs/hub02/umbrella-001/spoke.yaml: a parameter setspoke-umbrella-001with the spoke’s values.hubs/hub02/umbrella-001/deploy-spoke.yaml: a leafspoke-umbrella-001withparams: { hub: hub-hub02, spoke: spoke-umbrella-001 }andextends: spoke_deployment_base.
strata validate then checks the new spoke’s tenant, environments, name and values like every
other.
Notes
Quote a value that holds a token inside a YAML flow list or map:
environments: [solution-env, 'hub-${param:hub.name}-env']. In block style, as above, no quotes are needed.${param:}is never allowed inmeta,spec.extendsorspec.partial: names, parameter sets and chains stay fixed.The YAML editor’s schema (
.strata/schemas/, refreshed bystrata sln update) accepts a${param:}token whereverstrata validatedoes, and still underlines one inmeta,extendsorpartial. Whether the filled-in value is right, onlystrata validatecan tell.The full rules are in parameterset.md; the decision is ADR-0061.