Overview
Variables in Ctrlplane make your deployments dynamic and adaptable. They let you maintain consistent processes while accommodating differences across environments, resources, and releases.Variable Types
Ctrlplane supports several variable sources:-
Resource Variables: Values specific to individual resources
- Example:
namespace,cluster_endpoint,region - Defined on each resource
- Example:
-
Deployment Version Config: Values from the deployment version configuration
- Example:
imageTag,gitSha,buildNumber - Passed when creating a deployment version
- Example:
-
Job Variables: Values specific to a job execution
- Example: Custom parameters for the job
- Can reference workspace secrets
-
Computed Variables: System-provided variables about the deployment context
- Example:
resource.name,version.tag,environment.name
- Example:
Defining Variables
Resource Variables
Define variables on resources via the UI or API:- Navigate to a resource in the Ctrlplane UI
- Go to the “Variables” tab
- Add key-value pairs
- Can reference workspace secrets for sensitive values
Deployment Version Config
Pass configuration when creating a deployment version:Using Variables in Job Configurations
Reference variables in your job agent configuration using template syntax. The exact syntax depends on your job agent:Kubernetes Job Agent
Script Executor Agent
Available Variables
When executing a job, these variables are available:{{.version.tag}}: The deployment version tag (e.g.,v1.2.3){{.version.name}}: The deployment version name{{.deployment.name}}: The deployment name{{.deployment.slug}}: The deployment slug{{.resource.name}}: The resource name{{.resource.identifier}}: The resource identifier{{.resource.kind}}: The resource kind{{.resource.variables.KEY}}: Resource variable values{{.environment.name}}: The environment name{{.config.KEY}}: Deployment version config values
Best Practices
- Use Resource Variables: Store infrastructure-specific values (namespaces, endpoints) as resource variables
- Version Config for Build Info: Pass build metadata (image tags, git SHAs) in deployment version config
- Secrets Management: Reference workspace secrets in resource variables for sensitive data
- Consistent Naming: Use consistent variable names across resources for easier management
- Documentation: Document required variables for each deployment in your team’s runbooks