ConfigMap updates and reloads
Separate configuration from the image
A ConfigMap holds nonsecret configuration. Mount its keys as files in a dedicated directory and tell Nginx which file to read. This avoids overwriting the image’s default configuration directory. The complete config explicitly assigns runtime paths under /tmp and uses a foreground master. A ConfigMap volume is read-only. The sample below is a partial Pod spec; the file key nginx.conf becomes /etc/bm-config/nginx.conf.
volumes:- name: config configMap: name: catalog-config-v1containers:- name: nginx volumeMounts: - name: config mountPath: /etc/bm-config readOnly: trueUnderstand updates and reloads
With a mutable ConfigMap directory mount, kubelet eventually projects new file content; the delay is not guaranteed to be zero. A subPath mount does not receive those updates. Environment values from ConfigMaps are set for a container when it starts; changing the object does not refresh them. Nginx does not automatically reread configuration merely because bytes changed. In a separately approved mutable-config lab, check the exact mounted config before requesting a reload; verify a new response afterward. A failed reload can leave old workers serving the previous configuration.
nginx -t -c /etc/bm-config/nginx.conf# Only after successful validation in the lab container:nginx -c /etc/bm-config/nginx.conf -s reloadPrefer versioned configuration for this lab
The fixture creates immutable catalog-config-v1 and catalog-config-v2. Each Pod template names exactly one config version. Creating v2 alone does not change the Deployment. Updating the Pod template to reference v2 creates a new revision and replacement Pods; it avoids dependence on an automatic file watcher. Keep v1 for rollback, and ensure the new image and config are tested together. A rollout undo only restores a previous Pod template; it cannot recreate a deleted ConfigMap. During the update, both markers may legitimately appear.
volumes:- name: config configMap: name: catalog-config-v2Treat secrets as a separate boundary
A Secret is intended for confidential values such as certificate keys, but base64 representation alone provides no confidentiality. Restrict RBAC, verify encryption at rest and mount only needed values into the intended container. Never put real private keys in the curriculum or dump Secret objects into logs. A TLS-enabled variant could mount a separately provisioned Secret at a private directory; verify ownership, mode and certificate rotation behavior for the selected image. The current lab is HTTP only and creates no Secret. The fragment is illustrative, not an instruction to create credentials.
volumes:- name: tls secret: secretName: catalog-tls defaultMode: 0440Use the Chapter 49 manual practice and lab. Configuration and manifest snippets are illustrative. Kubernetes execution and image compatibility have not been verified; no cluster is required for offline study.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
ConfigMap updates and reloads
Assess decisions from the lesson and original lab.
What happens to a mutable ConfigMap directory mount after an update?
What happens to a ConfigMap subPath mount after the object changes?
What triggers a Deployment rollout in this lab?
Why retain config-v1?
Is base64 encoding of a Secret encryption?