Variables
User variables provide a flexible way to inject custom configuration values that can be referenced across Workload Profiles using the standard PaletteAI macro syntax.
Variables are only valid within the hub context; they cannot be referenced in the spoke context, like Definition outputs and object outputs.
VariableSet Resource
The VariableSet custom resource is used to define Variables that can be referenced across Workload Profiles. VariableSets provide a structured way to manage Variables with additional metadata and control features.
VariableSet Structure
A VariableSet resource has the following structure.
apiVersion: spectrocloud.com/v1beta1
kind: VariableSet
metadata:
name: mural-variables # Must be exactly "mural-variables"
namespace: production # Determines scope (system or namespace level)
spec:
variables:
- name: textValue
variableType: 'string'
value:
string: 'hello world'
description: 'A string variable'
- name: enabledFlag
variableType: 'bool'
value:
bool: true
description: 'A boolean variable'
- name: smallNumber
variableType: 'int32'
value:
int32: 42
description: 'A 32-bit integer variable'
- name: largeNumber
variableType: 'int64'
value:
int64: 9223372036854775807
description: 'A 64-bit integer variable'
- name: percentage
variableType: 'float32'
value:
float32: 85.5
description: 'A 32-bit float variable'
- name: preciseValue
variableType: 'float64'
value:
float64: 3.141592653589793
description: 'A 64-bit float variable'
locked: true
- name: apiKey
variableType: 'string'
validationMode: 'required'
description: 'API key that must be provided (for example in WorkloadDeployment or namespace VariableSet'
Variable Resolution
Variables follow a three-tier resolution system with the following order of precedence (highest to lowest):
-
Workload Deployment Variables - Defined directly in the
WorkloadDeploymentspec. -
Namespace-Scoped Variables - Defined in the
mural-variablesVariableSetcustom resource in the Workload Deployment's namespace. -
System-Wide Variables - Defined in the
mural-variablesVariableSetcustom resource in the SystemDefinition namespace (typicallymural-system)
Higher-precedence sources override lower-precedence sources for the same Variable name. If the Variable is marked as locked in the VariableSet definition, it will not be possible to override the value in a higher precedence. context.
Workload Deployment Variables
Variables can be defined directly in the WorkloadDeployment specification using the variables field. These have the highest precedence and will override VariableSet values, unless the VariableSet variable is locked. This is ideal for deployment-specific configurations that vary between environments.
apiVersion: spectrocloud.com/v1beta1
kind: WorkloadDeployment
metadata:
name: my-workload-deployment
namespace: production
spec:
workload:
name: my-workload
namespace: my-workload-namespace
workloadProfileRef:
name: my-workload-profile
namespace: profiles
environmentRef:
name: my-environment
namespace: environments
variables:
environment: 'production'
debug: 'false'
apiUrl: 'https://api.production.example.com'
maxReplicas: '10'
Namespace-Scoped VariableSet
Create a VariableSet resource in the same namespace as your Workload Deployment to make the Variables available to all Workload Deployments in the namespace.
apiVersion: spectrocloud.com/v1beta1
kind: VariableSet
metadata:
name: mural-variables
namespace: production
spec:
variables:
- name: environment
variableType: 'string'
value:
string: 'production'
description: 'Environment name'
- name: region
variableType: 'string'
value:
string: 'us-west-2'
description: 'AWS region'
- name: team
variableType: 'string'
value:
string: 'platform'
description: 'Team ownership'
locked: true
- name: alertingEnabled
variableType: 'bool'
value:
bool: true
description: 'Enable alerting'
- name: maxConnections
variableType: 'int32'
value:
int32: 100
description: 'Maximum connections'
- name: timeout
variableType: 'float32'
value:
float32: 30.5
description: 'Timeout in seconds'
System-Wide VariableSet
Create a VariableSet resource in the SystemDefinition namespace (typically mural-system) to provide clyster-wide default Variables.
apiVersion: spectrocloud.com/v1beta1
kind: VariableSet
metadata:
name: mural-variables
namespace: mural-system
spec:
variables:
- name: company
variableType: 'string'
value:
string: 'Spectro Cloud'
description: 'Company name'
locked: true
- name: region
variableType: 'string'
value:
string: 'us-east-1'
description: 'Default region'
- name: clusterType
variableType: 'string'
value:
string: 'managed'
description: 'Cluster management type'
locked: true
- name: defaultLogLevel
variableType: 'string'
value:
string: 'warn'
description: 'System default log level'
- name: monitoringEnabled
variableType: 'bool'
value:
bool: true
description: 'Enable monitoring by default'
- name: maxRetries
variableType: 'int32'
value:
int32: 3
description: 'Default retry count'
- name: requestTimeout
variableType: 'float64'
value:
float64: 60.0
description: 'Request timeout in seconds'