Repository navigation
ADD Environment Variable to Deployment
This page provides a step-by-step guide for adding a new environment variable to a deployment in the UnlockEdv2 environments. Follow this process whenever you need to introduce a new configuration value.
- Purpose
- Steps Overview
- Step 1: Identify the Correct Environment and Chart
- Step 2: Modify the Deployment File
- Step 3: Apply the Changes with Helm
- Step 4: Validation
- Step 5: Commit the Helm chart Changes
- Add Configuration to Deployment: Introduce new environment variables needed for new features or integrations.
- Ensure Proper Scoping: Make sure the variable is defined in the correct environment and chart.
- Apply Safely: Use Helm to deploy the updated configuration.
- Locate the correct environment’s Helm chart.
- Edit the deployment file and add your new environment variable.
- Run the
helm upgradecommand to apply changes to the cluster.
Depending on which environment needs the variable, update the corresponding repository:
| Environment | Repository | Path / Notes |
|---|---|---|
| Demo | https://github.com/UnlockedLabs/v2_deployment_definitions | Demo environment |
| Staging | https://github.com/UnlockedLabs/staging_helmfile | Staging environment |
| Production (mocode, stlouis, alaska, maine) | https://github.com/UnlockedLabs/production_scripts | Contains environment directories for each deployment |
Open the relevant deployment file that needs the new variable:
| Image | File Name |
|---|---|
| Frontend | frontend-deployment.yml |
| Provider Middleware | provider-service-deployment.yaml |
| Backend / API | server-deployment.yaml |
Inside the env: section of the container spec, add your new environment variable. Example:
containers:
- name: server
image: <image_name>
env:
- name: NEW_ENV_VARIABLE
value: "your_value_here"Ensure indentation and YAML syntax are correct.
Incorrect spacing can cause Helm or Kubernetes parsing errors.
Once your changes are committed or staged locally, navigate to the directory where the Chart.yaml and values.yaml files are located.
Run the Helm upgrade command to apply the updated configuration:
helm upgrade unlockedv2 .
This command deploys the latest chart configuration, updating environment variables and restarting affected pods automatically.
After the upgrade completes, validate that the new variable has been applied correctly:
- Check the running pod’s environment:
kubectl describe pod <pod_name> - Ensure the pod restarted properly:
kubectl get pods - Confirm application behavior is consistent with the new variable in effect.
Make sure to add/commit/push helm changes.
Success: The new environment variable is now active within your deployment.
All future Helm releases will include this configuration.