Components
The tutorial gives one component two deployments, each cloned straight from its base. A real fleet has more structure than that: a development and a staging deployment, several production regions, and settings that every production deployment shares but no other deployment has. This example builds that shape for CubbyChat and walks one change through it, on the command line and in the component view.
What you'll build
One component, with six variants:
cubbychat
└── base
├── dev → dev/target
├── staging → dev/target
└── prod-base
├── prod-us → prod/target
└── prod-eu → prod/target
base holds the configuration everything shares. prod-base is a second, intermediate base: it is cloned from base, holds what every production deployment has in common, and is never deployed itself. The four deployments run on two local clusters: dev and staging share the dev cluster, and the two production regions share the prod cluster, each in a namespace of its own. In a real fleet each region would be a cluster of its own; the shape of the tree would be the same.
Requirements
This example uses the tutorial's component name and clusters. If you still have the tutorial's cubbychat, run the tutorial's cleanup first.
Set up the clusters
cub cluster up dev
cub cluster up prod
Each command creates a local kind cluster running Argo CD and registers it as a target, dev/target and prod/target. See Set Up Your Cluster for what else they set up.
Create the component and its base
cub component create cubbychat
cub variant upload --component cubbychat --variant base \
oci://ghcr.io/confighub/configs/cubbychat
The Component entity is what the variants belong to. Each variant is a space that names it in its ComponentID, which is how cub component list finds them and how --variant cubbychat/<variant> addresses one. The upload makes one unit per resource in the bundle, with every namespace left as a placeholder for the deployments to fill in.
Create the deployments
Dev and staging are cloned from the base, onto the dev cluster, each in its own namespace:
cub variant create dev cubbychat/base --stage Development \
--target dev/target --namespace cubbychat-dev
cub variant create staging cubbychat/base --stage Staging \
--target dev/target --namespace cubbychat-staging
--stage sets the well-known Stage label, which says where each variant sits in the delivery path. Labels like it are how you select across the fleet later: every production deployment, every deployment in one region. See managing environments.
Add an intermediate base for production
Production deployments differ from the others in the same ways: more replicas, a production role. Rather than make that change in each production deployment, and remember to make it in the next one, make it once in a base of its own. Clone it from base with no target, which is what keeps it a base:
cub variant create prod-base cubbychat/base --stage Production
cub function set --variant cubbychat/prod-base --resource Deployment/backend \
set-replicas 3
cub function set --variant cubbychat/prod-base --resource Deployment/backend \
set-env-var backend ROLE production
Now clone the two regions from it:
cub variant create prod-us cubbychat/prod-base --region us-east1 \
--target prod/target --namespace cubbychat-us
cub variant create prod-eu cubbychat/prod-base --region europe-west1 \
--target prod/target --namespace cubbychat-eu
Each region inherits prod-base's labels, Stage=Production among them, and its configuration: three backend replicas and the production role, with no further work. What is particular to a region is set in that region. CubbyChat's backend reads its region from an environment variable:
cub function set --variant cubbychat/prod-us --resource Deployment/backend --guard Override=Upstream \
set-env-var backend REGION us-east1
cub function set --variant cubbychat/prod-eu --resource Deployment/backend --guard Override=Upstream \
set-env-var backend REGION europe-west1
--guard Override=Upstream makes each region's value its own: a later change to REGION upstream is withheld from it, and reported as a conflict, rather than overwriting it. See protecting a variant's own values.
Release the deployments
Nothing is running yet. Publish a release of each deployment:
cub release publish cubbychat/dev
cub release publish cubbychat/staging
cub release publish cubbychat/prod-us
cub release publish cubbychat/prod-eu
Argo CD in each cluster pulls its deployments' releases on its next sync. Check their live status:
cub release list --variant cubbychat/prod-us
There is no release of base or prod-base. A base has no target, so it has nothing to release: it exists to be cloned and promoted from.
Look at the component
cub component list
cub component tree cubbychat
cub component list shows cubbychat with its six variants. cub component tree draws the tree at the top of this page, each variant under the variant it was cloned from and each deployment with the target it releases to.
The web UI draws the same tree:
cub component open cubbychat
The component view shows the variants as a deployment graph, with each deployment's pending upgrades and unreleased changes. Select a variant to see its configuration. When the variant is behind its upstream, its Configuration tab previews the merge field by field, and Upgrade takes it. A deployment's Releases tab lists its releases and the live status reported for each, and Release publishes a new one. Each step below can be done there instead of on the command line.
Labels select across the component's variants the way they do across the fleet:
cub space list --component cubbychat --stage Production
That lists prod-base, prod-us and prod-eu.
Flow a change through the tree
Make a change once, in the base:
cub function set --variant cubbychat/base --resource Deployment/backend \
set-env-var backend CHAT_TITLE "Cubby Chat 2.0"
Every variant downstream of the base is now behind it, and none of them has changed. Units that are behind their upstream can be listed:
cub unit list --where "UpstreamRevisionNum > 0 AND UpstreamRevisionNum < UpstreamUnit.HeadRevisionNum" \
--columns Space.Slug,Unit.Slug
Of CubbyChat's units, only the backend units of dev, staging and prod-base are listed. prod-us and prod-eu are not behind anything yet: their upstream is prod-base, which hasn't taken the change.
Dev, then staging
Promote dev, release it, and check that it is healthy:
cub variant promote cubbychat/dev --dry-run -o mutations
cub variant promote cubbychat/dev
cub release publish cubbychat/dev
cub release list --variant cubbychat/dev
Then the same for staging:
cub variant promote cubbychat/staging
cub release publish cubbychat/staging
Production
Try promoting a production region directly:
cub variant promote cubbychat/prod-us --dry-run -o mutations
There is nothing to promote. A variant takes changes from its own upstream, and prod-us's upstream is prod-base. The change reaches production by being promoted into prod-base first, and from there into each region. Preview what prod-base would take, then promote all three with a selector, in one command:
cub variant promote cubbychat/prod-base --dry-run -o mutations
COMPONENT_ID=$(cub component get cubbychat -o jq=.Component.ComponentID)
cub variant promote \
--where-space "ComponentID = '$COMPONENT_ID' AND Labels.Stage = 'Production'"
Variants are promoted in upstream order, so prod-base takes the change before the regions take it from prod-base. Each region's REGION is untouched, and so are the production settings prod-base gave it. Promotion merges only what changed upstream. Release the regions:
cub release publish cubbychat/prod-us
cub release publish cubbychat/prod-eu
What is left
Units with changes that have not been released yet can be listed the same way:
cub unit list --where "HeadRevisionNum > LastReleasedRevisionNum AND TargetID IS NOT NULL" \
--columns Space.Slug,Unit.Slug
With every deployment released, none of CubbyChat's units is listed. The component view shows the same thing: no deployment has pending upgrades or unreleased changes.
The two states of a deployment
Between a change and its release, a deployment is in one of two states, and each can be selected with a filter:
| State | Meaning | Units in it |
|---|---|---|
| Behind | Its upstream has changes it has not merged yet | UpstreamRevisionNum > 0 AND UpstreamRevisionNum < UpstreamUnit.HeadRevisionNum |
| Unreleased | Its configuration has changed since its last release, by a promotion or by a change of its own | HeadRevisionNum > LastReleasedRevisionNum AND TargetID IS NOT NULL |
Promoting moves a deployment out of the first state and into the second; releasing moves it out of the second. Saved as filters or views, they show where every change in the fleet has got to.
Ordering the rollout
Nothing in this example stops you from promoting production before staging has the change. The tree says where a change can go; it does not say in what order, or what has to hold first. To require that a change is released and healthy in staging before production may take it, declare the stages as a ChangeWorkflow and name the change with a ChangeOrder. The Stage labels set here are what its stages select on. See tracking and promoting changes.
Cleanup
cub cluster down dev --delete-config
cub cluster down prod --delete-config
cub component delete --recursive cubbychat
--delete-config deletes each cluster's ConfigHub side along with the kind cluster, the deployments bound to it included. cub component delete --recursive deletes the component with the variants that are left, base and prod-base.
Further reading
- Components and Variants — the model this example applies
- Bases — including intermediate bases like
prod-base - Creating and managing variants — cloning, promoting, keeping a variant's own values, and conflicts
- Managing environments — the well-known labels, and selecting across environments
- Tracking and promoting changes — ChangeWorkflows and ChangeOrders
- Releases and Integrating with GitOps operators — how configuration reaches a cluster
- Filters and views — saving the queries above