Linux Foundation KCNA: Kubernetes ConfigMaps vs Secrets

ConfigMaps and Secrets look similar in Kubernetes because both can provide key-value data to workloads. Their operational meaning is different. ConfigMaps are intended for non-confidential configuration, while Secrets are intended for sensitive values such as passwords, tokens, and keys. Choosing between them is the first step; designing how values are created, authorized, delivered, refreshed, and protected is the larger engineering task.

Within Kubernetes and Linux operations, configuration should be treated as a runtime dependency with its own lifecycle. A container image should not need to be rebuilt for every environment-specific endpoint or feature flag. At the same time, moving a credential into a Secret object does not automatically make the credential safe.

Current Kubernetes documentation explicitly distinguishes ConfigMaps as non-confidential and warns that Secrets are stored unencrypted in etcd by default unless encryption at rest is configured. The practical boundary is therefore not “plain text versus secure storage.” It is “ordinary configuration versus data that requires additional confidentiality controls.”

ConfigMaps are for portable configuration that is safe to disclose

A ConfigMap can provide environment variables, command-line values, or files mounted into a Pod. This lets the same image run with different endpoints, feature settings, or application configuration across environments. It also makes configuration reviewable independently from application code.

The deciding test should be disclosure impact. If the value appeared in a support bundle, namespace export, or authorized API query, would that create a security problem? If yes, the data does not belong in a ConfigMap. The API object itself offers no secrecy or encryption guarantee.

This separation supports repeatable releases. The relationship between immutable application artifacts and external configuration complements Kubernetes deployment control because the release process can decide whether a code change, configuration change, or both require a new rollout.

Secrets need encryption and RBAC before they deserve the name operationally

Kubernetes Secret objects are base64-encoded for transport representation, not encrypted merely because they use the Secret API. Cluster administrators should configure encryption at rest for Secret data in etcd and restrict read access with RBAC. Broad list or watch permissions are especially sensitive because they can expose many secrets at once.

secret and privileged-access controls apply directly. A controller that can read every Secret in the cluster has a much larger blast radius than an application that can read one Secret in one namespace. Service accounts, namespace boundaries, and controller permissions should reflect that difference.

Backups of etcd or cluster data also inherit the confidentiality requirement. Encryption and access control must cover recovery copies, not only the live API path.

External secret systems can remain the authority while Kubernetes handles delivery

Many organizations already have a secrets manager or vault that owns credential creation, rotation, audit, and access policy. Kubernetes does not need to replace that authority. A controller, CSI integration, or application-side retrieval pattern can bring secrets to workloads while the external system remains the source of truth.

The trade-off is complexity. Synchronizing a secret into the Kubernetes API creates another stored copy. Mounting directly from an external provider may reduce persistence but adds runtime dependency on that integration. Application retrieval can give fine control but pushes secret-client behavior into code. Teams should choose based on threat model and operational reliability.

centralized secrets management is most useful when it clarifies ownership: one system creates and rotates credentials, while cluster mechanisms deliver only what a workload is authorized to use.

Environment variables and mounted files have different update behavior

How data is consumed changes how updates propagate. Values injected as environment variables are established when the container starts; changing the ConfigMap or Secret does not rewrite the environment of an already running process. Mounted configuration can be updated by Kubernetes, but the application still needs to notice and reload the changed file correctly.

This difference matters during rotation. Updating a database password in a Secret is not enough if a long-running application never rereads the mounted value. A rollout, signal, sidecar, or application reload mechanism may be required. The same problem exists for ordinary configuration when a change must become active predictably.

Operations should therefore define the full path from object update to application behavior and test it under failure, not assume the Kubernetes API update completes the change.

Immutable configuration can reduce accidental coupling

ConfigMaps and Secrets support immutable objects. Immutability can protect workloads from unexpected in-place changes and reduce the number of watches the kubelet must maintain for large numbers of objects. The trade-off is that updates require creating a new object and changing the workload reference.

That explicit versioning can be valuable for controlled rollouts. A Deployment can reference a versioned configuration name, and rollback can restore both image and configuration identity. This makes release evidence clearer than mutating a shared object used by many unrelated workloads.

Shared mutable configuration should be used deliberately because one change can affect many replicas or services without a normal application deployment.

Secret values should stay out of manifests, logs, and command history

Even a well-protected Secret can be exposed before it reaches Kubernetes. Committing raw secret values to Git, placing them in Helm values stored in CI logs, printing them during debugging, or passing them as visible command-line arguments can bypass cluster-side protections entirely.

Build and deployment systems should transport references or encrypted material rather than ordinary plaintext where possible. Access should be scoped to the pipeline step that needs the secret, and logs should be reviewed for accidental disclosure.

Teams preparing around Linux Foundation KCNA should connect this to the wider cloud-native supply chain: configuration and secret safety begins before the API server and continues after the value enters the container.

Configuration boundaries should match ownership and blast radius

A namespace-wide ConfigMap used by ten applications is easy to create but difficult to change safely. Configuration objects should have clear ownership and a consumer set small enough that a change can be reviewed and rolled back. Application-specific configuration is easier to reason about than global objects with hidden consumers.

The same rule is even more important for Secrets. A shared credential used by many services couples their rotation and incident response. Separate identities can increase management work but reduce the blast radius of compromise and make audit evidence more meaningful.

Kubernetes RBAC should reinforce those boundaries so application teams can manage their configuration without gaining read access to unrelated credentials.

The correct choice is a lifecycle decision, not a YAML preference

Use ConfigMaps for non-confidential settings that benefit from being separated from the image. Use Secrets for confidential data, then add the controls that make that classification meaningful: encryption at rest, least-privilege access, safe backup, careful delivery, rotation, and observability.

Do not treat either object as a general database. ConfigMaps have size limits and are not intended for large payloads. Secrets should remain small and purpose-specific. If an application needs large dynamic configuration or complex secret workflows, a dedicated service may be the better abstraction.

The operational goal is clarity. Engineers should be able to identify who owns a value, who may read it, how it reaches the process, when it changes, how the process reloads it, and how rollback works. That discipline matters more than the superficial similarity of the two Kubernetes object types.

Secrets also interact with memory and filesystem behavior inside the Pod. A value mounted as a file can be read by any process in the container that has sufficient filesystem access, while an environment variable may be exposed through application diagnostics or crash reporting. The Pod security model and application logging behavior therefore determine whether a correctly authorized Secret remains confidential after delivery.

Rotation should be designed around overlap. Many credential systems allow an old and new credential to coexist briefly so applications can reload without downtime. If the upstream system invalidates the old credential before every replica has consumed the new one, a routine rotation can become an outage. Kubernetes can distribute the value, but application and dependency behavior determine the safe rotation sequence.

Cluster recovery adds another requirement. If Secret data is needed to restore control-plane or application function, backups must preserve it securely and restore procedures must re-establish encryption and access policy. The operational discipline behind Kubernetes data recovery applies to sensitive configuration as much as to ordinary cluster state.

For workloads with especially strong confidentiality requirements, Kubernetes security practices should include minimizing Secret exposure to namespaces, service accounts, containers, and human users. A Secret object is a useful delivery primitive, but its security comes from the access and lifecycle controls around it.

Configuration inventories should make unused objects visible. Old ConfigMaps and Secrets often survive after workloads are removed, leaving stale credentials or misleading settings that nobody owns. Garbage collection based only on age is risky because some objects support infrequent jobs, so cleanup needs consumer discovery and ownership metadata. Periodic review should identify which workloads reference each object, whether the value still has an external owner, and whether rotation or deletion is overdue. Reducing stale configuration improves both security and operational clarity during incidents.

Leave a Reply

How It Works

img
Step 1. Choose Exam
on ExamLabs
Download IT Exams Questions & Answers
img
Step 2. Open Exam with
Avanset Exam Simulator
Press here to download VCE Exam Simulator that simulates real exam environment
img
Step 3. Study
& Pass
IT Exams Anywhere, Anytime!