Skip to content

ADD Environment Variable to Deployment

Richard Salas edited this page Oct 23, 2025 · 1 revision

Adding a New Environment Variable to a 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.


Table of Contents


Purpose

  • 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.

Steps Overview

  1. Locate the correct environment’s Helm chart.
  2. Edit the deployment file and add your new environment variable.
  3. Run the helm upgrade command to apply changes to the cluster.

Step 1: Identify the Correct Environment and Chart

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

Step 2: Modify the Deployment File

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.


Step 3: Apply the Changes with Helm

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.


Step 4: Validation

After the upgrade completes, validate that the new variable has been applied correctly:

  1. Check the running pod’s environment:
    kubectl describe pod <pod_name>
    
  2. Ensure the pod restarted properly:
    kubectl get pods
    
  3. Confirm application behavior is consistent with the new variable in effect.

Step 5: Commit the Helm chart Changes

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.

Clone this wiki locally