Variables and Shared Config

You find yourself typing the same value — a registry URL, a region, an
environment name — into Component after Component, and changing it later means
editing every one of them. Variables let you define the value once and
reference it everywhere.

When to use a variable

Use a variable when a value is the same for every Component within a scope, but
differs between scopes. A registry URL that differs per cloud, a domain suffix
that differs per stage, an environment-specific endpoint — all good candidates.
A value used by exactly one Component is usually clearer left inline.

Variables are scoped by stage, cloud, environment, or namespace.
A Component only sees the variables whose scope matches where it is deployed.

Creating a variable

  1. In the left sidebar, open the Variables section under Deployment.
  2. Click + New.
  3. Enter the variable's name and value, and select its scope.

Using a variable

Inside a Component's configuration editor, reference a variable with the
.VARIABLE notation. The templating engine works like Helm templates, but
uses << and >> as the delimiters instead of {{ and }}.

image:
  repository: .REGISTRY_URL/my-app

A Variables tab appears next to the editor listing the variables available
to the Component you are editing. If a variable you expect is not there, its
scope does not match this Component.

Reserved variables

These are predefined and always available, with no need to create them:

VariableValue
._METADATA.CLOUDThe cluster's cloud provider (aws, gcp)
._METADATA.INSTANCEThe Component's name
._METADATA.ENVIRONMENTThe Environment name
._METADATA.STAGEThe stage (dev, prod, and so on)
._METADATA.NAMESPACEThe namespace the Component is deployed to

Related articles


Did this page help you?