Variables allow you to define reusable values that can be referenced across your stacks. Define them at the organisation, cluster, or stack level and use them in manifests and add-on configurations.
Overview
Ankra supports variables at three levels with a clear precedence hierarchy: Precedence Order (highest to lowest):- Stack variables - Variables defined for a specific stack (highest precedence)
- Cluster variables - Variables defined for a specific cluster
- Organisation variables - Variables defined for the entire organisation (lowest precedence)
Lower-level variables override higher-level ones. A stack variable with the same name as a cluster or organisation variable will take precedence for that stack.
Variable Syntax
Reference variables in your stacks using the following syntax:Organisation Variables
Organisation variables apply to all clusters and stacks within your organisation. Use them for values that are consistent across your entire infrastructure.Creating Organisation Variables
Enter Variable Details
Fill in the required fields:
- Variable Name: Must start with a letter, containing only letters, numbers, and underscores (e.g.,
domain_name,api_key) - Value: The variable’s value
- Description (optional): A brief description for documentation
- Secret: Check this box to mask the value in the UI
Common Organisation Variables
| Variable Name | Example Value | Use Case |
|---|---|---|
domain_name | example.com | Base domain for all services |
registry_url | ghcr.io/myorg | Container registry URL |
environment | production | Environment identifier |
alert_email | [email protected] | Notification email address |
log_level | info | Default logging level |
Cluster Variables
Cluster variables apply to all stacks deployed to a specific cluster. Use them for cluster-specific configurations that differ between environments.Creating Cluster Variables
Enter Variable Details
Fill in the required fields:
- Variable Name: Must start with a letter, containing only letters, numbers, and underscores
- Value: The variable’s value
- Description (optional): A brief description
- Secret: Check this box to mask the value in the UI
Common Cluster Variables
| Variable Name | Example Value | Use Case |
|---|---|---|
cluster_domain | prod.example.com | Cluster-specific subdomain |
storage_class | gp3 | Default storage class |
node_selector | app=production | Node selector labels |
replica_count | 3 | Default replica count |
resource_quota | high | Resource allocation tier |
Stack Variables
Stack variables are specific to a single stack and have the highest precedence. Use them for stack-specific configurations that should override cluster and organisation variables.Creating Stack Variables
Open the Stack Builder
Navigate to your cluster → Stacks and open an existing stack or create a new one.
Enter Variable Details
Fill in the fields:
- Variable Name: Must start with a letter, containing only letters, numbers, and underscores
- Value: The variable’s value
Common Stack Variables
| Variable Name | Example Value | Use Case |
|---|---|---|
app_version | v2.1.0 | Application version tag |
replicas | 5 | Stack-specific replica count |
feature_flag | enabled | Feature toggles |
log_level | debug | Stack-specific logging |
custom_config | {"key": "value"} | JSON configuration |
When to Use Stack Variables
Use stack variables when:- A specific stack needs values that differ from cluster defaults
- You want to override cluster or organisation variables for one stack
- You’re testing different configurations on the same cluster
- You need stack-specific feature flags or version tags
Secret Variables
Mark variables as secrets when they contain sensitive values like API keys, passwords, or tokens.Secret Variable Features
- Masked Display: Values show as
••••••••in the UI - Reveal Option: Click the eye icon to temporarily reveal the value
- Copy Protection: Values can still be copied for use in configurations
When to Use Secrets vs SOPS
| Feature | Secret Variables | SOPS Encryption |
|---|---|---|
| UI Masking | Yes | N/A |
| Git Storage | Plaintext | Encrypted |
| Runtime Decryption | No | Yes |
| Best For | UI-only protection | Full encryption at rest |
Using Variables in Stacks
In Manifests
Reference variables anywhere in your Kubernetes manifests:In Add-on Values
Use variables in Helm chart values:Variable Resolution
When you deploy a stack, Ankra resolves variables in this order:- Check for a matching stack variable (highest priority)
- If not found, check for a matching cluster variable
- If not found, check for a matching organisation variable
- If still not found, the literal
${{ ankra.variable_name }}is left in place (which will likely cause deployment errors)
This precedence allows you to define sensible defaults at the organisation level, environment-specific overrides at the cluster level, and stack-specific customizations when needed.
Managing Variables
Copying Variable Syntax
Click the Copy icon next to any variable to copy its full syntax:Deleting Variables
- Click the Delete (trash) icon next to the variable
- The variable is immediately removed
Variable Naming Rules
Variable names must follow these rules:- Start with a letter (a-z, A-Z)
- Contain only letters, numbers, and underscores
- Be unique within their scope (organisation or cluster)
domain_name, API_KEY, replica_count_v2
Invalid names: 123_name, my-variable, name with spaces
Best Practices
AI Prompts
Press⌘+J to open the AI Assistant and use these prompts:
Create Variables for a Stack
Create Variables for a Stack
Migrate Hardcoded Values
Migrate Hardcoded Values