Environments and Per-Env Values
Promoting the same setup from dev to prod.
Environments and Per-Env Values is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 3 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.
One Stack, Many Stages
Dev, staging, and prod run the same apps with different settings. Helmfile environments let one file describe all of them cleanly.
The environments Block
You declare each stage under a top-level environments block. Each named environment can load its own values file.
environments:
dev:
values:
- envs/dev.yaml
prod:
values:
- envs/prod.yamlSelect with -e
You choose the active environment on the command line with -e. Helmfile then loads only that environment's values.
helmfile -e prod syncThe .Environment.Values Tree
Loaded values land in .Environment.Values. You read them with Go template syntax anywhere in your helmfile.yaml.
{{ .Environment.Values.replicaCount }}Per-Env Replica Counts
A classic use: dev runs one replica, prod runs many. You template the set value from the environment instead of hardcoding it.
set:
- name: replicaCount
value: {{ .Environment.Values.replicaCount }}Shared Base, Env Override
List a base values file first, then the env file. The environment file overrides only the keys that differ, keeping shared config in one place.
values:
- envs/base.yaml
- envs/{{ .Environment.Name }}.yamlThe .Environment.Name Helper
.Environment.Name gives the active environment's name as a string. It is great for naming, labels, or choosing a file path dynamically.
namespace: app-{{ .Environment.Name }}A Default Environment
Define a default environment so a plain helmfile command still works without -e. It runs when no environment is specified.
environments:
default:
values:
- envs/dev.yamlInline Env Values
Small differences can live inline under an environment instead of a file. Use values with a map for just a key or two.
environments:
prod:
values:
- replicaCount: 5Promote Without Forking
Because logic is shared and only values change, you promote the same release from dev to prod by switching -e, not by copying files.
Keep Secrets Out
Environment value files often hold sensitive config. Keep real secrets encrypted or in a vault, never as plaintext in these files in Git.
Quick Check
You want to deploy the prod stage of your helmfile.yaml. How do you select it?
Recap: Environments
You learned to define environments, select one with -e, and read .Environment.Values to promote the same stack across stages. Next: applying it. 🚀
Learn DevOps Bootcamp with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 142
- Lessons
- 568
Frequently Asked Questions
Is the “Environments and Per-Env Values” lesson free?
Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Environments and Per-Env Values”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.
What will I learn in “Environments and Per-Env Values”?
Promoting the same setup from dev to prod. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 4.
How long does the “Environments and Per-Env Values” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Why Helmfile Sits Above Helm
- Defining Releases in helmfile.yaml
- Environments and Per-Env Values
- helmfile diff, apply, and sync