Variables let you define reusable configuration values that can be referenced in your manifests and Helm add-on values. They support a hierarchical inheritance model where stack variables override cluster variables, which override organisation variables.
What are Variables?
Variables in Ankra are key-value pairs that you can reference in your Kubernetes manifests and Helm values files. Instead of hardcoding values like database URLs, API keys, or environment-specific settings, you define them as variables and reference them using Ankra’s variable syntax.Variable Hierarchy
Ankra supports three levels of variables, each with increasing specificity:| Level | Scope | Use Case |
|---|---|---|
| Organisation | All clusters and stacks in your organisation | Shared values like company domain, default registry URL |
| Cluster | All stacks within a specific cluster | Environment-specific values like API endpoints, resource limits |
| Stack | Single stack only | Stack-specific values like application version, feature flags |
Precedence Rules
When the same variable name exists at multiple levels, the most specific level wins:- Stack variables (highest priority)
- Cluster variables
- Organisation variables (lowest priority)
DATABASE_URL at the organisation level and also at the stack level, the stack value will be used when deploying that stack.
Variable Syntax
Reference variables in your manifests and Helm values using this syntax:- Start with a letter (a-z, A-Z)
- Contain only letters, numbers, and underscores
- Be case-sensitive
Example Usage
In a Kubernetes manifest:Managing Organisation Variables
Organisation variables apply to all clusters and stacks within your organisation.1
Open Organisation Settings
Click your profile icon in the bottom-left menu and select Organisation.
2
Navigate to Variables
Select your organisation, then go to Settings and click Variables.
3
Add a Variable
Click Add Variable, enter a name and value, and optionally add a description. Toggle Secret if the value should be masked in the UI.
4
Copy Reference
Click the copy icon next to any variable to copy its reference syntax for use in your manifests.
Managing Cluster Variables
Cluster variables apply to all stacks within a specific cluster and override organisation variables with the same name.1
Open Cluster Settings
Navigate to your cluster and click Settings in the sidebar.
2
Navigate to Variables
Click Variables in the settings menu.
3
Add a Variable
Click Add Variable, enter a name and value, and optionally add a description. Toggle Secret if the value should be masked.
Managing Stack Variables
Stack variables apply only to a specific stack and have the highest precedence.1
Open Stack Editor
Navigate to your cluster, open a stack, and click Edit.
2
Open Variables Tab
Click the Variables tab in the stack editor.
3
Add Variables
Click Add Variable to create new variables. Enter the name and value for each.
4
Save Changes
Click Save to store the variables. Deploy the stack to apply changes.
Variable Resolution Example
Consider this setup:| Variable | Organisation | Cluster | Stack |
|---|---|---|---|
log_level | info | debug | - |
database_url | postgres://shared | postgres://staging | postgres://local |
app_name | myapp | - | - |
| Variable | Resolved Value | Source |
|---|---|---|
log_level | debug | Cluster (overrides org) |
database_url | postgres://local | Stack (overrides cluster and org) |
app_name | myapp | Organisation |
Best Practices
Use Descriptive Names
Name variables clearly:
production_database_url is better than db_url. Include context in the name.Document with Descriptions
Add descriptions to variables explaining their purpose and expected format.
Leverage Hierarchy
Put shared defaults at the organisation level, environment overrides at cluster level, and app-specific values at stack level.
Mark Secrets Appropriately
Toggle the secret flag for sensitive values like API keys and passwords to mask them in the UI.
Naming Conventions
| Convention | Example | Use For |
|---|---|---|
UPPER_SNAKE_CASE | DATABASE_URL | Environment-style variables |
lower_snake_case | app_version | General configuration |
prefix_name | redis_host, redis_port | Grouped related variables |
Common Use Cases
Multi-Environment Deployments
Define environment-specific values at the cluster level: Production Cluster:database_url=postgres://prod-db.internal:5432/applog_level=warnreplicas=5
database_url=postgres://staging-db.internal:5432/applog_level=debugreplicas=2
${{ ankra.database_url }} and automatically get the correct value per environment.
Shared Configuration
Define organisation-wide defaults:registry_url=registry.company.comdefault_namespace=appsmonitoring_endpoint=https://metrics.company.com
Application Versioning
Set version at the stack level for controlled rollouts:backend_version in the stack variables to deploy a new version.
Troubleshooting
Variable Not Substituted
If you see${{ ankra.variable_name }} in your deployed resources instead of the actual value:
- Check the variable name matches exactly (case-sensitive)
- Verify the variable is defined at the appropriate level
- Ensure there are no typos in the syntax
Unexpected Value
If a variable resolves to an unexpected value:- Check all three levels for the variable name
- Remember that stack overrides cluster, which overrides organisation
- Use the copy button in the UI to ensure you’re using the correct syntax