Variables in Ctrlplane
Variables in Ctrlplane are key-value pairs that enable dynamic configuration and parameterization of deployment workflows. They’re essential for injecting environment-specific settings, secrets, and runtime values into your pipelines.
Variable Scopes
Ctrlplane offers three variable scopes:
- System Level: Global variables applicable to all resources across all deployments within a system.
- Deployment Level (Wildcard Selector): Variables applicable to all resources within a specific deployment.
- Deployment Level (Custom Selector): Variables applicable to a subset of resources within a deployment, based on defined selectors (e.g., metadata, environment, type).
Precedence and Conflict Resolution
When variable keys are defined at multiple levels, Ctrlplane resolves conflicts in this order:
- Per-Resource Variables (highest priority)
- Deployment Level Variables
- System Level Variables (lowest priority)
Variable Types
Ctrlplane supports:
String
: Plain text (e.g., API_KEY)Number
: Numeric values (e.g., PORT)Boolean
: True/False values (e.g., ENABLE_DEBUG)Array
: List of values (e.g., ALLOWED_IPS)Object
: Structured data (e.g., DATABASE_CONFIG)Secret
: Encrypted sensitive values (e.g., passwords)
Usage
Variables can be used in:
- Workflow definitions:
{{ vars.api_key }}
- Job agent configurations
- Resource configurations
Best Practices
- Organize variables logically at the appropriate level
- Use descriptive names
- Store sensitive values as secrets
Implementation Tips
- Use system-level variables for shared configurations (e.g., global API endpoints, common timeouts)
- Leverage deployment-level variables for environment-specific settings (e.g., staging vs. production configs)
- Utilize custom selectors for fine-grained control over specific resource groups
- Regularly audit and rotate sensitive variables, especially secrets
By mastering Ctrlplane’s variable system, DevOps engineers can create flexible, secure, and easily maintainable deployment workflows across diverse environments.