Adding Environment Variables
You can add environment variables when creating a deployment or update them later.During Deployment Creation
1
Create a new deployment
Start creating a deployment from image or GitHub.
2
Scroll to Environment Variables
Find the Environment Variables section.
3
Add variables
Click Add Variable and enter:
- Key: The variable name (e.g.,
DATABASE_URL) - Value: The variable value
4
Add more as needed
Repeat for each environment variable your application needs.
Updating Existing Deployments
1
Open your deployment
Navigate to the deployment you want to update.
2
Go to Settings
Click on the Settings tab.
3
Edit environment variables
Add, modify, or remove environment variables as needed.
4
Save changes
Click Save. The deployment will restart with the new configuration.
Changing environment variables requires a restart of your pods. Orchard performs a rolling restart to minimize downtime.
Common Use Cases
Database Connections
API Keys and Secrets
Application Configuration
Feature Flags
Best Practices
Use descriptive names
Use descriptive names
Use clear, uppercase names with underscores:Good:
DATABASE_URLAPI_KEYENABLE_FEATURE_X
dbkey1x
Don't commit secrets
Don't commit secrets
Never commit secrets to your repository. Use environment variables for:
- API keys
- Database passwords
- JWT secrets
- Third-party service credentials
Use different values per environment
Use different values per environment
Keep development and production configurations separate:Development:Production:
Document required variables
Document required variables
Keep a list of required environment variables in your README or documentation:
Referencing Internal Services
When your deployment needs to connect to another service in the same project, use Kubernetes internal DNS:{org-slug}-{workspace-slug}-{project-slug}
Variable Interpolation
Environment variable values are stored exactly as entered. Orchard does not perform variable interpolation. If you need to build URLs from components: Instead of:Bulk Operations
Importing from .env File
While Orchard doesn’t directly import.env files, you can quickly add multiple variables:
- Prepare your variables in key=value format
- Add them one by one in the UI
- Or use the API for bulk operations
Copying Between Deployments
To copy environment variables from one deployment to another:- Note the variables from the source deployment
- Create or edit the target deployment
- Add the same variables
Be careful when copying variables between environments. Database URLs, API keys, and other secrets should differ between staging and production.
Sensitive Values
Environment variables containing sensitive data like passwords and API keys are:- Stored securely in the database
- Not exposed in logs or the UI after creation
- Passed securely to containers at runtime
Troubleshooting
Variable not available in container
Variable not available in container
If your application can’t find an environment variable:
- Verify the variable is saved in deployment settings
- Check for typos in the variable name
- Ensure the deployment has been restarted after changes
- Check your application is reading the correct variable name
Special characters in values
Special characters in values
If your value contains special characters:
- Quotes, spaces, and special characters are supported
- No need to escape characters in the UI
- The value is passed exactly as entered to your container