teluzia.Cloud Engineer · Day 115
CHAPTER 17 · KUBERNETES FUNDAMENTALS

ConfigMaps and secrets

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

ConfigMaps carry ordinary operating instructions; Secrets carry sensitive instructions behind access controls, though their envelope is not automatically encrypted. ConfigMaps store nonsecret key-value configuration that can be consumed as environment variables or files. Environment values are set at container startup and do not refresh automatically. Mounted updates have different behavior and timing, and applications must reread files when dynamic changes are intended. Kubernetes Secret data uses base64 representation, which is encoding rather than encryption. Protection depends on API authorization, cluster encryption-at-rest settings, and safe workload use. Anyone allowed to read a Secret can recover its values, and unnecessary environment or log exposure adds risk.

Think of it this way

ConfigMaps carry ordinary operating instructions; Secrets carry sensitive instructions behind access controls, though their envelope is not automatically encrypted.

TOPIC 01 / 03Step by step

ConfigMaps and consumption

ConfigMaps store nonsecret key-value configuration that can be consumed as environment variables or files. Environment values are set at container startup and do not refresh automatically. Mounted updates have different behavior and timing, and applications must reread files when dynamic changes are intended. For example, aPP_MODE=dev comes from a ConfigMap; changing it does not alter an already-started container’s environment value.

WORKED EXAMPLE
APP_MODE=dev comes from a ConfigMap; changing it does not alter an already-started container’s environment value.

A Pod starts with APP_MODE supplied through configMapKeyRef. Kubernetes resolves that value when constructing the container environment. Editing the ConfigMap later does not mutate the already-running process's environment. A rollout or application-specific refresh mechanism may therefore be necessary. Mounted file consumption has different update behavior and the application must actually reread the file.

A ConfigMap stores nonsecret configuration. An environment variable is a process startup value. A mounted configuration file appears through a volume mechanism. SubPath mounts and other consumption details can affect update behavior, so check the exact setup. External configuration improves separation from images, but creates a release dependency: the same image can behave differently with different values. Preserve the intended configuration revision and validation evidence. Do not label passwords ordinary configuration merely to avoid managing Secrets, and do not assume a successful ConfigMap edit establishes that the application has adopted the change.

Why this matters

APP_MODE=dev comes from a ConfigMap; changing it does not alter an already-started container’s environment value.

A common trap

Do not overlook this operational distinction: Mounted updates have different behavior and timing, and applications must reread files when dynamic changes are intended.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

ConfigMaps and consumption

ConfigMaps store nonsecret key-value configuration that can be consumed as environment variables or files. Environment values are set at container startup and do not refresh automatically. Mounted updates have different behavior and timing, and applications must reread files when dynamic changes are intended. For example, aPP_MODE=dev comes from a ConfigMap; changing it does not alter an already-started container’s environment value.

WORKED EXAMPLE
APP_MODE=dev comes from a ConfigMap; changing it does not alter an already-started container’s environment value.

A Pod starts with APP_MODE supplied through configMapKeyRef. Kubernetes resolves that value when constructing the container environment. Editing the ConfigMap later does not mutate the already-running process's environment. A rollout or application-specific refresh mechanism may therefore be necessary. Mounted file consumption has different update behavior and the application must actually reread the file.

A ConfigMap stores nonsecret configuration. An environment variable is a process startup value. A mounted configuration file appears through a volume mechanism. SubPath mounts and other consumption details can affect update behavior, so check the exact setup. External configuration improves separation from images, but creates a release dependency: the same image can behave differently with different values. Preserve the intended configuration revision and validation evidence. Do not label passwords ordinary configuration merely to avoid managing Secrets, and do not assume a successful ConfigMap edit establishes that the application has adopted the change.

Why this matters

APP_MODE=dev comes from a ConfigMap; changing it does not alter an already-started container’s environment value.

A common trap

Do not overlook this operational distinction: Mounted updates have different behavior and timing, and applications must reread files when dynamic changes are intended.

Secrets and protection limits

Kubernetes Secret data uses base64 representation, which is encoding rather than encryption. Protection depends on API authorization, cluster encryption-at-rest settings, and safe workload use. Anyone allowed to read a Secret can recover its values, and unnecessary environment or log exposure adds risk. For example, a fake password encoded as cHJhY3RpY2U= can be decoded; a real value must not be committed in a manifest.

WORKED EXAMPLE
A fake password encoded as cHJhY3RpY2U= can be decoded; a real value must not be committed in a manifest.

A manifest's Secret data field contains a base64 string. Anyone able to read that field can decode the original bytes. The representation enables handling of data in the API format; it is not encryption or proof that storage is confidential. Actual protection depends on API authorization, encryption-at-rest configuration, workload exposure, and operational handling.

Encoding changes representation without requiring a secret decryption key. Encryption protects information under cryptographic control. RBAC governs permitted Kubernetes API actions. Read access to a Secret is sensitive, and permission to create workloads that mount it can also matter. Avoid dumping real Secret YAML into logs or screenshots. Environment injection can expose values through application diagnostics, while mounted files need appropriate permissions and process handling. A namespace helps organize access but is not automatically strong tenant isolation. Use only fake values in beginner demonstrations, then document the cluster's real protection requirements separately.

Why this matters

A fake password encoded as cHJhY3RpY2U= can be decoded; a real value must not be committed in a manifest.

A common trap

Do not overlook this operational distinction: Anyone allowed to read a Secret can recover its values, and unnecessary environment or log exposure adds risk.

Access and release coordination

Grant workloads only the secret access or mounted content they need. Coordinate configuration changes with rollout behavior and credentials accepted by dependencies. Avoid displaying values during diagnostics, and use external secret management when requirements call for centrally controlled rotation or lifecycle. For example, a database credential change requires the database and application refresh strategy to agree, not only a changed Secret object.

WORKED EXAMPLE
A database credential change requires the database and application refresh strategy to agree, not only a changed Secret object.

A database credential changes and the application Secret is updated. The database must accept the new credential, and the application must obtain it through its configured consumption path. If the process retains an old environment value or connection pool behavior masks refresh timing, some operations can keep working while new connections fail.

Rotation changes credential authority and consumers in coordination. Refresh updates an application's retained value. A service account identifies a Kubernetes workload's API identity and may also participate in AWS workload identity design. These identities do not automatically grant every Secret or cloud action. Limit mounts and permissions to required values, and consider supported external-secret integration when centralized lifecycle or rotation is necessary. That integration adds controllers and synchronization behavior needing monitoring. Keep configuration promotion, database changes, and application rollout coordinated, with rollback compatibility recorded instead of assuming one changed Kubernetes object completes the whole credential lifecycle.

Why this matters

A database credential change requires the database and application refresh strategy to agree, not only a changed Secret object.

A common trap

Do not overlook this operational distinction: Avoid displaying values during diagnostics, and use external secret management when requirements call for centrally controlled rotation or lifecycle.

KEEP THESE WITH YOU

Today’s takeaways

ConfigMaps and consumption: ConfigMaps store nonsecret key-value configuration that can be consumed as environment variables or files. Environment values are set at container startup and do not refresh automatically. Mounted updates have different behavior and timing, and applications must reread files when dynamic changes are intended.

Secrets and protection limits: Kubernetes Secret data uses base64 representation, which is encoding rather than encryption. Protection depends on API authorization, cluster encryption-at-rest settings, and safe workload use. Anyone allowed to read a Secret can recover its values, and unnecessary environment or log exposure adds risk.

Access and release coordination: Grant workloads only the secret access or mounted content they need. Coordinate configuration changes with rollout behavior and credentials accepted by dependencies. Avoid displaying values during diagnostics, and use external secret management when requirements call for centrally controlled rotation or lifecycle.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed