Skip to content

Organize Configuration into Components

A Component is a piece of software, such as an application, a service, or a piece of infrastructure, together with the configuration that describes how it runs. The same component usually runs in many places, such as dev, staging, and production clusters in several regions, and each place has its own complete copy of the component's configuration, called a variant. A variant is a Space whose Units are that copy. A variant with no Target, the base, exists to create others from; a variant bound to a Target is a deployment. A Helm chart and its releases, or a kustomize base and its overlays, play similar roles, except that every variant holds complete configuration rather than a patch on another.

This guide shows how Spaces come to belong to a Component, how to see and select a component's variants, and how a Component decides which changes its variants accept. The Component page describes the model, and Manage Environments how environments, regions and other dimensions are laid out across components.

Making a component

Every way of bringing configuration into ConfigHub as a base also creates its Component, if it does not exist yet:

  • cub variant upload --component web uploads rendered manifests into the Component's base, as Create and Manage Variants describes.
  • cub package install installs a package into a Component named after the package. See Install Packages.
  • cub helm install installs a chart into a Component named after the release, or the one --component names. See Install Helm Charts.

To lay out Spaces yourself, create the Component first, then name it on each Space with --component, and the variant with --variant, which sets the Space's Variant label:

cub component create web
cub space create web-base --component web --variant base
cub space create web-prod --component web --variant prod --release-target prod/target

A variant created from another with cub variant create belongs to its source's Component, so a component's deployments join it as they are created:

cub variant create dev web/base --target dev/target

A variant is addressed as <component>/<variant>, such as web/dev, by the --variant flag that cub function, cub unit and other commands take, and the Spaces that cub variant commands create are named <component>-<variant> by default, such as web-dev. The Variant label is what makes the name: give each Space of a component a different one.

Seeing a component

cub component list lists the Components, each with its variants. cub component tree draws a component's variants as a tree, each under the variant it was created from, with the Target of each deployment:

$ cub component tree web
web
└── base
    ├── dev     → dev/target
    └── prod    → prod/target

cub space list --component web lists the variants' Spaces with their labels. In the web UI, the Components view shows each component's variants, with upgrades waiting to be promoted and changes not yet released.

Selecting across components

Because the variants are Spaces, everything that selects Spaces or Units selects by component. A Space's ComponentID names its Component, so a --where or a Filter on it selects every variant of one component, and one on a Space label, such as Environment, cuts across components to select every production deployment:

cub space list --where "Component.Slug = 'web'"

WEB=$(cub component get web -o jq=.Component.ComponentID)
cub unit list --where "Space.ComponentID = '$WEB'"
cub unit list --where "Space.ComponentID = '$WEB' AND Space.Labels.Environment = 'Prod'"

Set the Environment, Region, Stage, Layer and Owner labels on each Space when you create it, with the flags of the same names on cub space create, cub variant create and cub variant upload, so that each dimension of your fleet can be selected. Manage Sets of Units shows how to name such a set and act on it.

Governing changes to a component

A Component decides which changes its variants accept:

cub component update --patch web --require-change-workflow \
  --allowed-change-workflow platform/standard-rollout
cub component update --patch web --require-change-tracking

A Component also has permissions of its own, which --permission grants and an Organization role can grant over every Component; see Authorization.

One component or two

The variants of a component are meant to be alike: the same software adapted to where it runs. The test is whether a change to the component would normally need to reach every variant. If two variants differ widely, with different resources and little configuration in common, they are two components. Conversely, software that is always deployed together, such as an application and the database only it uses, can be one component made of several charts or packages; see More than one chart in a component.

A component can have several bases, such as a production base and a non-production base created from a root base, each holding the policy of its class of environment, with the deployments created from them. Manage Environments shows how.

Moving, renaming and deleting

Moving a Space to another Component, or out of every Component, is a change to the Space:

cub space update --patch web-canary --component web-edge
cub space update --patch web-canary --component -

An upload or install into a Space that belongs to a different Component is refused, rather than moving the Space.

Renaming a Component, with cub component rename web storefront, changes its slug and keeps its identity, so everything that refers to it by ID keeps doing so. A --where that names the old slug stops matching it, and an upload that names the old name creates a new Component.

Deleting a Component is refused while Spaces belong to it. cub component delete --recursive deletes its variants first, with their Units. With --archive as well, the Component and its variants are archived rather than deleted: hidden, until cub component unarchive --recursive restores them.