M2-S1 — Values and secrets
Section titled “M2-S1 — Values and secrets”| Module | M2 — Install, upgrade and roll back |
| After this session you can | Write Northwind’s values and secrets so the chart renders cleanly, with nothing secret in the file you commit, and say in advance which mistakes the chart will catch and which it will not. |
| Time | Facilitated: 42 min · On your own: 42 min |
| Before you start | M1-S1: pack-values.yaml, the osos/ chart folder, your inventory. The lab cluster from M0-S2. |
| Go deeper | Helm chart: install and upgrade · Configuration reference: required secrets |
◆ Orientation (1 min) — The values file is the deployment
Section titled “◆ Orientation (1 min) — The values file is the deployment”Everything that makes the release Northwind’s (its address, its datastores, its keys, its mail server) is a value. The chart turns values into ConfigMaps and Secrets, and the services read them as environment variables when they start. So the values file is not paperwork: it is the deployment, and a mistake in it is either caught by the chart at once or found by your users later. This session is about knowing which.
▤ Concept (8 min) — From values to running pods
Section titled “▤ Concept (8 min) — From values to running pods”Where a value goes
Section titled “Where a value goes”flowchart LR V["Your values files"] --> H["helm template / install"] H -->|"settings"| CM["ConfigMaps"] H -->|"passwords, keys"| S["Secrets"] CM --> P["Pods read them as<br/>environment variables at start"] S --> P
What to notice: pods read their environment only when they start. The chart stamps a checksum of each ConfigMap and Secret on most Deployments, so a changed value rolls the pods that read it on the next upgrade.
There is no configuration file inside a running service to edit. If you change a ConfigMap by hand,
nothing happens until the pod restarts, and the next helm upgrade overwrites your change. The
values files are the only source of truth.
Three files, one release
Section titled “Three files, one release”| File | Holds | Committed to Git? |
|---|---|---|
nw-values.yaml | Every setting: addresses, datastores, which services run, sizes | Yes. It contains no secret. |
nw-secrets.yaml | Every password and key, generated once (in production: from your secret manager) | Never |
pack-values.yaml | The license values from your vendor’s evaluation pack | Never |
You pass all three to Helm, settings first: -f nw-values.yaml -f nw-secrets.yaml -f pack-values.yaml.
When two files set the same key, the later one wins.
The license step. A license is required to activate Administration. Your vendor gives you
the values; you do not create or edit them. Put them in pack-values.yaml: license.clientId,
license.tokenUrl (an https:// address the gateway pods must reach) and the private key, held in
your own Secret named by license.existingSecret and license.existingSecretKey. A multi-tenant
cell adds license.cellId. You install them with the release in M2-S2 and renew them in M2-S3; the
job aid has the commands. There is no license
screen: ask your vendor.
What the chart refuses to render
Section titled “What the chart refuses to render”Some values are checked while the chart is rendered. If one is missing or malformed, helm template
and helm install stop before anything reaches the cluster, with a message naming the problem:
| Value | Message or behaviour |
|---|---|
secrets.sharedKey | A valid shared key should be provided. |
core.mongoUrlTemplate | Stops when empty, or when it lacks the literal {db} |
web.config.clientId | web.config.clientId is required |
altcha.config.altchaHMACKey (while altcha.enabled) | A valid altcha HMAC key should be provided. |
core.enabled: false | Refused: the combined pods are the only shape |
A render-time failure is the cheapest failure there is. Always render (helm template) and lint
(helm lint) before you install or upgrade.
What only fails once pods start
Section titled “What only fails once pods start”Other mistakes render perfectly and fail later, sometimes much later:
| Mistake | When you find out |
|---|---|
| A MongoDB, RabbitMQ or Redis address that is wrong or unreachable | Pods start, never become ready, and log connection errors |
identity.config.recoveryCodePepper left empty | The install succeeds; the first time someone uses a two-factor recovery code, it fails |
core.mongoUrlTemplate composing a database name that does not exist | Nothing fails: the application connects to a new, empty database, and the data seems to be missing |
| The message-bus set-up Job cannot reach RabbitMQ’s management address | The install hangs on that Job, then fails |
Values you set once and protect
Section titled “Values you set once and protect”| Value | Why you never change it casually |
|---|---|
data.config.fieldEncryptionMasterKey | It protects the key that encrypts every encrypted field. Change it and those fields become permanently unreadable. Back it up outside the cluster (M4-S3). |
identity.config.recoveryCodePepper | Rotating it invalidates every two-factor recovery code already issued. |
identity.config.totpEncryptionKey | It encrypts the stored two-factor secrets; a new key cannot read the old ones. |
secrets.sharedKey | Rotation is a planned procedure, not an edit (M3-S2). |
identity.oidc.cookieKeys, storage.linkSigning.key | Left empty, the chart generates them once and keeps them. If you render with helm template (for example from Argo CD), set them explicitly, or a new key on every render signs everyone out and breaks every file link. |
Generate keys with openssl rand -hex 32 (32 bytes, 64 hexadecimal characters). That is the form the
encryption and pepper values expect.
⛏ Lab (16 min) — Northwind’s values, rendered clean
Section titled “⛏ Lab (16 min) — Northwind’s values, rendered clean”Goal. Three values files that render without error, with every secret in the two files you never commit.
Before you start. Your working folder with osos/ and pack-values.yaml. Add nw-secrets.yaml
to .gitignore next to pack-values.yaml.
-
Create
nw-values.yaml. Replace<registry from your vendor>with the registry from your pack; nothing else in it is secret.# nw-values.yaml: Northwind lab release. Settings only; no secret belongs here.rootHost: localhostimage:repository: <registry from your vendor>/imageCredentials:enabled: trueregistry: <registry from your vendor>ingress:className: nginxhosts:- host: localhostweb:config:clientId: nw-webidentity:ingress:enabled: false # sign-in served under localhost, not on its own host nameconfig:mongodb:url: "mongodb://mongo-0.mongo.datastores.svc.cluster.local:27017/nw-identity?replicaSet=rs0"core:mongoUrlTemplate: "mongodb://mongo-0.mongo.datastores.svc.cluster.local:27017/nw-{db}?replicaSet=rs0"storage:config:storageType: diskmongodb:url: "mongodb://mongo-0.mongo.datastores.svc.cluster.local:27017/nw-storage?replicaSet=rs0"scheduler:config:mongodb:url: "mongodb://mongo-0.mongo.datastores.svc.cluster.local:27017/nw-scheduler?replicaSet=rs0"translation:deployment:config:mongodb:url: "mongodb://mongo-0.mongo.datastores.svc.cluster.local:27017/nw-translation?replicaSet=rs0"rabbitmq:vhostManagement:managementUrl: "http://rabbitmq.datastores.svc.cluster.local:15672"vhost: nwimage:repository: docker.io/redis:host: redis.datastores.svc.cluster.localport: "6379"database: "1"email:deployment:enabled: true # the lab has no shared email function: run the sender hereconfig:smtp:host: mailpit.datastores.svc.cluster.localport: "1025"secure: "false"migration:config:superAdminEmail: operator@northwind.example.comsuperAdminUsername: nwoperator -
Generate
nw-secrets.yaml. The heredoc runsopensslonce per key, so every key is new and none is typed by hand. Replace the two registry placeholders with your pack’s values when the file is written, in an editor, not on the command line.Terminal window cat > nw-secrets.yaml <<EOF# nw-secrets.yaml: NEVER COMMIT. Lab secrets generated $(date +%F).imageCredentials:username: "<user from your vendor>"password: "<token from your vendor>"secrets:sharedKey: "$(openssl rand -hex 24)"backendClientId: nw-backendbackendClientSecret: "$(openssl rand -hex 24)"rabbitmq:url: "amqp://lab:lab-only-rabbit@rabbitmq.datastores.svc.cluster.local:5672/nw"vhostManagement:credentials: "lab:lab-only-rabbit"redis:password: "lab-only-redis"identity:config:expressSessionKey: "$(openssl rand -hex 32)"totpEncryptionKey: "$(openssl rand -hex 32)"recoveryCodePepper: "$(openssl rand -hex 32)"data:config:fieldEncryptionMasterKey: "$(openssl rand -hex 32)"altcha:config:altchaHMACKey: "$(openssl rand -hex 32)"EOF -
Copy
nw-secrets.yamlandpack-values.yamlinto your password manager now. The field-encryption key in particular has no other copy. -
Lint, then render:
Terminal window values="-f nw-values.yaml -f nw-secrets.yaml -f pack-values.yaml"helm lint ./osos $valueshelm template nw ./osos -n northwind $values > rendered.yaml && echo RENDER-OK -
Confirm the field-encryption key went into a Secret and not a ConfigMap:
grep -n "FIELD_ENCRYPTION_MASTER_KEY" rendered.yamland read thekind:above each hit. -
Confirm the committed file holds no secret:
grep -n -i -E "password|secret|key:" nw-values.yaml. OnlyclientIdlines and comments may appear.
Check.
-
helm lintreports0 chart(s) failed. - The render prints
RENDER-OK. - Every
FIELD_ENCRYPTION_MASTER_KEYhit sits in akind: Secret. -
nw-values.yamlcontains no password, token or key. -
nw-secrets.yamlandpack-values.yamlare listed in.gitignoreand saved in your password manager. - The super-administrator email is at
northwind.example.com, not a vendor address.
Pass condition. All six checks hold. These three files are what you install from in M2-S2.
If something goes wrong
| What you see | What to do |
|---|---|
... is required or should be provided | A render-time value is missing. The message names it; check its spelling and indentation against step 1 or 2. |
| A YAML error with a line number | Usually indentation. Two spaces per level, no tabs. |
helm lint warns about an icon or missing Chart.yaml fields | Warnings about the chart itself are not yours to fix; only [ERROR] lines matter. |
FIELD_ENCRYPTION_MASTER_KEY also appears in a ConfigMap | Report it to your vendor; never work around it by editing rendered files. |
openssl is not found | Install it (it ships with Git for Windows, macOS and most Linux distributions), or generate the keys in your password manager as 64 hexadecimal characters. |
Model answer
A clean result looks like this:
helm lintends with1 chart(s) linted, 0 chart(s) failed.RENDER-OKis printed andrendered.yamlis several thousand lines long.FIELD_ENCRYPTION_MASTER_KEYappears in the identity and data Secrets: both need it, because the identity server stores its own keys encrypted with the same root key.- The
grepofnw-values.yamlshows onlyclientId: nw-weband the comment lines.
Why the split matters: nw-values.yaml can now be reviewed, diffed and committed like code, and the
two secret files can be replaced by your secret manager in production without touching it.
⛏ Lab (10 min) — Render-time or runtime?
Section titled “⛏ Lab (10 min) — Render-time or runtime?”Goal. See the chart’s guards fire, and recognize the mistake that slips through.
Before you start. Lab A passed. values is still set in your shell.
Run each command, read the result, and write in inventory.md whether the chart caught it.
helm template nw ./osos $values --set secrets.sharedKey= > /dev/nullhelm template nw ./osos $values --set core.mongoUrlTemplate="mongodb://mongo-0.mongo.datastores.svc.cluster.local:27017/nw-data" > /dev/nullhelm template nw ./osos $values --set core.enabled=false > /dev/nullhelm template nw ./osos $values --set identity.config.recoveryCodePepper= > /dev/null && echo render-ok- For case 4, write what would happen after an install, and who would notice first.
Check.
- Cases 1 to 3 stop with a message, and you copied each message.
- Case 4 prints
render-ok. - Your note on case 4 names the symptom (a recovery code fails) and that it appears only when someone uses one.
Pass condition. You classified all four correctly: three render-time, one runtime.
If something goes wrong
| What you see | What to do |
|---|---|
| Case 1 renders | Your shell may have quoted the empty value away. Use --set "secrets.sharedKey=". |
| Case 4 also fails | Check the rest of the command: it must differ from Lab A only by the --set. |
Model answer
| Case | Caught at render? | What you see |
|---|---|---|
| 1 Empty shared key | Yes | A valid shared key should be provided. |
2 Template without {db} | Yes | The render stops, naming core.mongoUrlTemplate and the missing {db} |
3 core.enabled=false | Yes | Refused: the combined pods are the only way the twelve applications run |
| 4 Empty recovery-code pepper | No | Renders and installs. The first person who signs in with a two-factor recovery code is refused, and the identity server logs that the pepper is required. |
The lesson: a clean render proves the chart’s guards passed, not that the release works. M2-S2 adds the second half, the smoke test.
✓ Practice (6 min) — Check your understanding
Section titled “✓ Practice (6 min) — Check your understanding”A teammate edits a ConfigMap of the release with kubectl edit to raise a log level. An hour later
the change has had no effect, and after the next upgrade it is gone. What should they have done?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
helm install succeeds and every pod is ready. A week later, encrypted fields show errors after an
operator “tidied up” data.config.fieldEncryptionMasterKey to a new value. What is the way back?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
Which of these mistakes does helm template catch?
Check your answer
The correct answer is C. Open the explanation under each option to see why.
After an install, the portal shows an error page with a Retry button instead of the sign-in
page. The private key lives in your own Secret, and pack-values.yaml was copied from an old email.
What do you do?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
Your platform team deploys with Argo CD, which renders charts with helm template. Which values
must they set explicitly that a plain helm install would have generated?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
↺ Recap (1 min) — Values you can trust
Section titled “↺ Recap (1 min) — Values you can trust”You have three values files that render cleanly, with nothing secret in the one you commit, and you know which mistakes the chart catches and which ones wait for your users.
Next. In M2-S2 you install from them, watch Helm’s hooks run in order, and prove the release works with a smoke test that ends with the operator signed in to Administration.