values.yaml
- Docker & Kubernetes course
- Advanced
- Lesson 10/70
- 4 min
Learn chart configuration with values.yaml.
values.yaml
values.yaml holds the chart's default values. They are overridden at install time in three ways; precedence runs from last to first (later wins):
# values.yaml
replicaCount: 1
image:
repository: ghcr.io/ali/magaza-web
tag: ""
service:
type: ClusterIP
port: 80
helm install magaza ./magaza -f prod-values.yaml --set replicaCount=3Here values.yaml is applied first, prod-values.yaml on top of it, and --set last.
Nested values
With --set, nested keys are written with dots; lists are given with braces or indexes. For complex values, an environment-specific values file is more readable:
helm install magaza ./magaza --set image.tag=1.4.2,service.type=NodePort
helm install magaza ./magaza --set ingress.hosts[0].host=magaza.example.com
helm get values magaza # values given at install
helm show values bitnami/redis # all the chart's defaultsPractice Environment values
Two steps: first write the contents of prod-values.yaml: replicaCount: 3; tag: "1.4.2" under image; type: NodePort under service. Then write the command installing ./magaza as magaza with this file and --set service.port=8080.
Starter code
# prod-values.yaml
# buraya yazSample solution
# prod-values.yaml
replicaCount: 3
image:
tag: "1.4.2"
service:
type: NodePort
helm install magaza ./magaza -f prod-values.yaml --set service.port=8080Expected output
NAME: magaza STATUS: deployed REVISION: 1
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 With replicaCount: 1 in values.yaml, 2 in prod-values.yaml and --set replicaCount=3, what is the result?
- 3 Correct answer
- 2
- 1
- 6
Explanation: --set has the highest precedence.
2 Give the environment-specific values file.
helm install magaza ./magaza ____ prod-values.yaml
helm install magaza ./magaza -f prod-values.yaml
Explanation: -f (--values) takes a values file.
3 Match.
| Term | Meaning |
|---|---|
values.yaml |
Default |
-f dosya |
Environment values |
--set |
Highest precedence |
helm show values |
Chart defaults |