What is an Environment?
Environments organize your deployment pipeline into stages:- Development - Where developers test their changes
- QA - Quality assurance and testing
- Staging - Pre-production validation
- Production - Live customer-facing environment
- New resources matching the selector automatically join the environment
- Resources can belong to multiple environments
- No manual resource assignment needed
Environment Properties
name
Display name for the environment. Examples:- “Production”
- “Staging”
- “Development”
- “QA US East”
systemId
The system this environment belongs to. Environments are scoped to systems.resourceSelector
The selector that determines which resources belong to this environment. This is the heart of how environments work. Example Selectors: Simple metadata match (CEL expression):directory
Optional path for hierarchical organization of environments. Examples:""- Root level"regions"- First level grouping"regions/us-east"- Nested grouping
- Organizing by region:
regions/us-east,regions/eu-west - Organizing by type:
permanent/production,temporary/feature-1 - Organizing by team:
teams/platform,teams/product
description
Optional description of the environment’s purpose and usage.metadata
Key-value pairs with environment information (not used for resource matching). Common Metadata:Creating Environments
Via Web UI
- Navigate to your system
- Click “Environments” tab
- Click “Create Environment”
- Fill in:
- Name: “Production”
- Description: “Production environment”
- Resource Selector: Add conditions
- Click “Create”
Via CLI
Multiple Environments
How Resource Selectors Work
Selectors match resources based on their metadata, kind, identifier, or other properties.Selector Types
Ctrlplane uses CEL (Common Expression Language) for resource selectors.Metadata Selector
Match resources by metadata key-value pairs. Single condition:==- Exact match!=- Not equalsin- Value in listhas()- Key exists
Kind Selector
Match resources by theirkind field.
Identifier Selector
Match resources by their identifier.Complex CEL Expressions
Use CEL for complex matching logic.Selector Evaluation
When determining which resources belong to an environment:- Ctrlplane evaluates the
resourceSelectoragainst all resources - Resources that match are included in the environment
- As resources are added/updated, they’re re-evaluated
- Resources are automatically added/removed as they match/unmatch
- ✅
{name: "Cluster A", metadata: {environment: "production"}}- Matched - ❌
{name: "Cluster B", metadata: {environment: "staging"}}- Not matched - ✅
{name: "Cluster C", metadata: {environment: "production", region: "us-east"}}- Matched
Release Targets
When you create a deployment and an environment, Ctrlplane automatically creates release targets for each matching resource. Formula:Deployment × Environment × Resource = Release Target
Example:
Given:
- Deployment: “API Service”
- Environment: “Production” (matches 3 resources)
- Resource A: k8s-prod-use1
- Resource B: k8s-prod-usw2
- Resource C: k8s-prod-euw1
- API Service → Production → k8s-prod-use1
- API Service → Production → k8s-prod-usw2
- API Service → Production → k8s-prod-euw1
Hierarchical Environments
Use thedirectory field to organize environments hierarchically.
Example Structure
Creating Hierarchical Environments
Benefits
- Visual organization in UI
- Easier navigation with many environments
- Logical grouping by region, team, or purpose
- Permission scoping (future feature)
Common Environment Patterns
Standard Pipeline
Multi-Region Environments
Canary Environments
Team-Specific Environments
Viewing Environment Resources
Via CLI
Via Web UI
- Navigate to the environment
- Click “Resources” tab
- See all matched resources
- Resource name and kind
- Metadata
- Current deployed versions
- Job status
Environment Variables
Environments can have variables that differ per deployment.Deployment Variables
Define a variable at the deployment level, then set values per environment. Variables are typically configured via the Web UI, but can also be managed via API. See the Deployments documentation for details on creating and setting deployment variables. During job execution, the appropriate value is resolved based on the environment.Policies and Environments
Policies often target specific environments using selectors.Approval Required for Production
Environment Progression
Ensure deployments go to staging before production:Best Practices
Naming
Good Names:- ✅ “Production”
- ✅ “Staging”
- ✅ “Development”
- ✅ “QA US East”
- ❌ “Prod” (use full names)
- ❌ “Environment 1” (not descriptive)
- ❌ “John’s Test” (not permanent)
Selector Design
Do:- ✅ Use consistent metadata keys across resources
- ✅ Make selectors explicit and clear
- ✅ Test selectors match expected resources
- ✅ Document complex selectors
- ❌ Overly complex selectors that are hard to understand
- ❌ Selectors that might accidentally match wrong resources
- ❌ Selectors based on frequently changing metadata
Environment Count
Start Simple:- Avoid creating environments you won’t use
- Consolidate similar environments
- Use resource metadata to differentiate within an environment
Troubleshooting
Environment shows no resources
- Check the resource selector syntax
- Verify resources exist with matching metadata
- Test selector with “Query Resources” feature
- Check resources aren’t deleted
Wrong resources in environment
- Review resource selector logic
- Check for OR vs AND conditions
- Verify resource metadata is correct
- Test selector in isolation
Release targets not created
- Verify environment has matching resources
- Check deployment has resource selector (if any)
- Ensure deployment and environment are in same system
- Review logs for errors
Next Steps
- Deployments - Create deployments
- Selectors - Deep dive into selector syntax
- Release Targets - Understand the deployment matrix
- Policies - Control deployments with policies