Chapter 85: Helm for Kubernetes
85.6 Values files, --set and --set-string
Story. At a TCS-style account, Rahul kept values-dev.yaml, values-stage.yaml and values-prod.yaml. Prod set replicaCount: 4 and a private image repository. Dev used one replica and a public tag. One chart, three files, no copy-paste of Deployments.
Why
CLI --set is fine for a quick lab. Teams need files in Git for review.
What
- -f values-prod.yaml — Load a file (can repeat; later files win).
- --set a.b=c — Override one key; types are guessed.
- --set-string — Force a string (useful for versions like
1.10). - --set-file — Read a value from a file contents.
Example 1: Layered files
helm upgrade --install cart ./cart -f values.yaml -f values-prod.yaml -n prod
What it shows: Defaults first, then prod overrides.
Example 2: --set-string for a tag
helm upgrade --install cart ./cart -n prod --set-string image.tag=1.10
What it shows: Tag stays the string 1.10, not the number 1.1.
Example 3: See computed values
helm get values cart -n prod --all
Output
replicaCount: 4
image:
repository: 123456789012.dkr.ecr.ap-south-1.amazonaws.com/cart
tag: "1.10"
What it shows: The live release's values (including defaults with --all).
Ravindra Bagale's Tip
Never put real passwords in values committed to Git. Use sealed secrets, External Secrets, or a private values file outside the repo.
Git मध्ये commit होणाऱ्या values मध्ये खरोखरचे passwords ठेवू नका. Sealed secrets, External Secrets, किंवा repo बाहेरील private file वापरा.
Git में commit होने वाली values में असली passwords न रखें. Sealed secrets, External Secrets, या repo के बाहर private file इस्तेमाल करें.
Quick quiz
Q1. Which wins when two -f files set the same key?
The later file.
Q2. When do you need --set-string?
When a value must stay a string, like image tag 1.10.
Q3. How do you inspect live values?
helm get values RELEASE -n NS --all
Did you understand? Let us try it once more.