valuesyaml
Values.yaml Explained: The Complete Guide to Helm Chart Configuration for Kubernetes
Key Takeaways
- values.yaml is the single source of truth for every configurable parameter in a Helm chart — it drives templates through
{{ .Values }}references. - Override precedence follows a strict hierarchy:
--setflags >-fcustom value files > defaultvalues.yaml— a fact that causes subtle deployment bugs when ignored. - Schema validation with
values.schema.jsoncatches misconfigurations before they reach the cluster, reducing production incidents by up to 40% according to CNCF observability data. - Environment promotion without duplication is achievable through layered override files (e.g.,
values-dev.yaml,values-prod.yaml) rather than forking full copies. - Sensitive data must never live in values.yaml; use Kubernetes Secrets, SealedSecrets, or external vault integration to prevent credential leakage in version control.
What Is values.yaml in Helm?
values.yaml is the default configuration file bundled inside every Helm chart. It defines the baseline set of tunable parameters that chart templates reference via the .Values object. When you run helm install or helm upgrade, Helm merges your supplied values into this default file, resolves all template expressions, and renders the final Kubernetes manifests.
Think of values.yaml as the chart author's contract with the operator: it declares every configurable surface area — image tags, replica counts, resource limits, feature flags — in a single human-readable document.
Why values.yaml Exists: Solving Template Parameterization
Before Helm popularized the values.yaml pattern, Kubernetes deployments required either hand-edited YAML files per environment or complex shell variable substitution. The problem was structural: Kubernetes manifests are declarative and static, but applications need to run identically across dev, staging, and production with only environmental differences.
values.yaml solves this by decoupling structure from configuration:
- Templates (
.yamlfiles in the chart'stemplates/directory) define what gets deployed — Deployments, Services, ConfigMaps, etc. - Values (
values.yaml) define how those resources are configured — image versions, scaling parameters, environment-specific overrides. - The merge engine combines them at render time, producing cluster-ready manifests.
This separation is what makes Helm charts reusable. The same chart can provision a 1-replica debug instance or a 50-replica production cluster simply by swapping the values layer.
Structure and Syntax of a Well-Formed values.yaml
Top-Level Keys and Nesting Patterns
A production-grade values.yaml typically follows a nested hierarchy that mirrors the Kubernetes objects it configures. Here is a representative structure from a real-world application chart:
# values.yaml — Representative structure
replicaCount: 3
image:
repository: myregistry/app-server
tag: "2.4.1"
pullPolicy: IfNotPresent
secretName: registry-credentials
service:
type: ClusterIP
port: 8080
targetPort: http-api
externalTrafficPolicy: Local
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 250m
memory: 256Mi
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 20
targetCPUUtilizationPercentage: 70
ingress:
enabled: true
className: nginx
hosts:
- host: app.example.com
paths:
- path: /
pathType: Prefix
tls:
- secretName: app-tls-cert
hosts:
- app.example.com
nodeSelector:
kubernetes.io/os: linux
tolerations: []
affinity: {}
envConfig:
LOG_LEVEL: info
CACHE_TTL_SECONDS: 300
FEATURE_FLAGS: '{"darkMode":true,"betaApi":false}'
database:
host: postgres-primary.svc.cluster.local
port: 5432
name: appdb
credentialsFromSecret: db-credentials
sslMode: require
Naming Conventions That Matter
Chart authors should follow consistent naming patterns to reduce friction for operators:
- kebab-case for top-level keys and sub-keys (
replica-countoverreplicaCount) — aligns with Kubernetes convention and improves readability. - Explicit defaults for every key — never rely on Helm's zero-value behavior for critical parameters.
- Group related settings under descriptive namespaces (
image.,service.,autoscaling.) rather than flat structures. - Avoid inline comments for defaults — if a value needs explanation, the key name should be self-documenting.
How Value Overrides Work: The Precedence Hierarchy
One of the most frequently misunderstood aspects of Helm is how values are merged. Helm uses a deep-merge strategy — nested objects are merged recursively, not replaced wholesale. Understanding this behavior is essential for predicting deployment outcomes.
The Three-Layer Override Model
Helm applies values in the following order, with later layers taking precedence over earlier ones at the key level:
- Default values.yaml — bundled in the chart package. Lowest priority.
- Custom value files (-f flag) — one or more files passed via
helm install -f overrides.yaml -f prod-overrides.yaml. Applied left-to-right; rightmost file wins on conflicts. - CLI --set flags — highest priority.
helm install --set replicaCount=5 --set image.tag=v2.1.
Deep-Merge Behavior: A Critical Detail
Consider this scenario. Your values.yaml defines:
resources:
limits:
cpu: 500m
memory: 512Mi
requests: