Helm
Kubernetes
Configuration
Deployment
DevOps

How to set multiple values with helm?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Helm provides several ways to set multiple values: --set key=value flags (inline, one per flag), -f values.yaml files (bulk configuration), --set-string for explicit string values, and --set-json for complex structures. For production use, prefer values files (-f) for readability and version control. Use --set for quick overrides and CI/CD pipelines. Multiple -f files are merged left to right, with later files taking precedence.

Method 1: Multiple --set Flags

bash
1helm install my-release my-chart \
2  --set replicaCount=3 \
3  --set image.repository=nginx \
4  --set image.tag=1.25 \
5  --set service.type=LoadBalancer \
6  --set service.port=80

Each --set flag sets one key-value pair. Nested keys use dot notation.

Method 2: Comma-Separated --set

bash
# Multiple values in a single --set (comma-separated)
helm install my-release my-chart \
  --set replicaCount=3,image.repository=nginx,image.tag=1.25

This is more compact but harder to read for many values.

Method 3: Values Files (-f)

yaml
1# production-values.yaml
2replicaCount: 3
3
4image:
5  repository: nginx
6  tag: "1.25"
7  pullPolicy: IfNotPresent
8
9service:
10  type: LoadBalancer
11  port: 80
12
13resources:
14  limits:
15    cpu: 500m
16    memory: 256Mi
17  requests:
18    cpu: 100m
19    memory: 128Mi
20
21env:
22  - name: DATABASE_URL
23    value: "postgres://prod-db:5432/myapp"
24  - name: LOG_LEVEL
25    value: "info"
bash
helm install my-release my-chart -f production-values.yaml

Method 4: Multiple Values Files (Merged)

bash
1# base-values.yaml is applied first, then production overrides
2helm install my-release my-chart \
3  -f base-values.yaml \
4  -f production-values.yaml
5
6# Later files override earlier files for the same keys
yaml
1# base-values.yaml
2replicaCount: 1
3image:
4  repository: nginx
5  tag: "latest"
6resources:
7  requests:
8    cpu: 100m
yaml
1# production-values.yaml
2replicaCount: 3
3image:
4  tag: "1.25"
5# resources.requests.cpu from base is preserved

Method 5: --set with Complex Types

Arrays/Lists

bash
1# Set array elements by index
2helm install my-release my-chart \
3  --set ingress.hosts[0].host=example.com \
4  --set ingress.hosts[0].paths[0].path=/ \
5  --set ingress.hosts[0].paths[0].pathType=Prefix
6
7# Set a simple list
8helm install my-release my-chart \
9  --set "tolerations[0].key=dedicated" \
10  --set "tolerations[0].operator=Equal" \
11  --set "tolerations[0].value=gpu" \
12  --set "tolerations[0].effect=NoSchedule"

--set-string for Explicit Strings

bash
1# Prevents Helm from interpreting "true" as boolean
2helm install my-release my-chart \
3  --set-string image.tag=1.25 \
4  --set-string env.DEBUG=true

--set-json for Complex Structures

bash
helm install my-release my-chart \
  --set-json 'resources={"limits":{"cpu":"500m","memory":"256Mi"}}' \
  --set-json 'env=[{"name":"LOG_LEVEL","value":"info"}]'

Method 6: --set with --values Combined

bash
1# Values file provides defaults, --set overrides specific values
2helm install my-release my-chart \
3  -f production-values.yaml \
4  --set image.tag=1.26 \
5  --set replicaCount=5

--set flags always take precedence over -f files.

Helm Upgrade with Values

bash
1# Upgrade with new values
2helm upgrade my-release my-chart \
3  -f production-values.yaml \
4  --set image.tag=1.26
5
6# Reuse existing values and override specific ones
7helm upgrade my-release my-chart \
8  --reuse-values \
9  --set image.tag=1.27

Debugging Values

bash
1# See the final merged values without installing
2helm install my-release my-chart \
3  -f production-values.yaml \
4  --set replicaCount=5 \
5  --dry-run --debug
6
7# Show current values of a release
8helm get values my-release
9
10# Show all values (including defaults)
11helm get values my-release --all
12
13# Template rendering to verify
14helm template my-release my-chart -f production-values.yaml

Common Pitfalls

  • Values containing commas in a single --set flag: Commas separate key-value pairs in --set. If a value contains a comma, it splits incorrectly. Escape commas with \,: --set annotation="app\,version=1", or use --set-json instead.
  • Helm interpreting numeric strings as numbers: --set image.tag=1.25 sets the value to the float 1.25, not the string "1.25". Use --set-string image.tag=1.25 or quote in YAML: tag: "1.25" to ensure it stays a string.
  • Not quoting special characters in shell: Values with !, $, {, or spaces need quoting: --set "password=my\!pass" or --set 'password=my!pass'. Without quotes, the shell interprets these characters.
  • Using --reuse-values without understanding merge behavior: --reuse-values takes the values from the last release and merges your new --set flags. If the chart added new default values in an update, those defaults are not applied because the old values take priority.
  • Overriding nested maps with --set instead of merging: --set resources.limits.cpu=500m only sets that one key. But --set-json 'resources={"limits":{"cpu":"500m"}}' replaces the entire resources map, deleting any existing requests section. Be aware of set vs replace semantics.

Summary

  • Use -f values.yaml for bulk configuration — readable, version-controlled, and mergeable
  • Use --set key=value for quick overrides and CI/CD pipelines
  • Use --set-string to prevent numeric or boolean interpretation of string values
  • Use --set-json for complex structures like arrays and nested objects
  • Multiple -f files merge left to right; --set always takes highest precedence

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.