Inferensys

Glossary

ConfigMap

A ConfigMap is a Kubernetes API object used to store non-confidential configuration data as key-value pairs, which can be consumed by pods as environment variables or configuration files.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
KUBERNETES OBJECT

What is ConfigMap?

A ConfigMap is a Kubernetes API object used to decouple configuration data from containerized application code, enabling configuration management and dynamic updates without rebuilding images.

A ConfigMap is a Kubernetes API object that stores non-confidential configuration data as key-value pairs. This data can be consumed by pods as environment variables, command-line arguments, or configuration files mounted as volumes. By externalizing configuration from the application image, ConfigMaps facilitate immutable infrastructure practices, allowing the same container image to be deployed across different environments (development, staging, production) with environment-specific settings injected at runtime.

ConfigMaps are essential for agent deployment observability as they allow runtime configuration of telemetry endpoints, log levels, and feature flags without pod restarts. They differ from Secrets, which are for sensitive data. Changes to a ConfigMap are automatically propagated to mounted volumes, though pods may require a restart to pick up new environment variables. This makes ConfigMaps a foundational tool for managing the dynamic configuration of observability agents and ensuring consistent behavior across deployments.

KUBERNETES CONFIGURATION MANAGEMENT

Key Features of ConfigMaps

A ConfigMap is a Kubernetes API object used to decouple configuration artifacts from container images, storing non-confidential data as key-value pairs for consumption by pods.

01

Key-Value Data Storage

A ConfigMap stores configuration data as simple key-value pairs. This data is entirely non-confidential (unlike a Secret). The keys must consist of alphanumeric characters, '-', '_', or '.'. Values can be arbitrary strings or structured text like JSON snippets.

  • Example: database.host: "prod-db.internal"
  • Use Case: Storing environment-specific variables like feature flags, external service endpoints, or UI configuration strings.
02

Pod Consumption Methods

Pods can consume ConfigMap data through several mechanisms, providing flexibility for different application needs:

  • Environment Variables: Inject individual keys or the entire ConfigMap as environment variables into a container.
  • Configuration Files: Mount the ConfigMap as a read-only volume, where each key becomes a file and its value becomes the file's content. This is ideal for applications expecting config files (e.g., nginx.conf).
  • Command-Line Arguments: Use ConfigMap data to populate a container's command arguments.

Changes to a mounted ConfigMap volume are eventually propagated to the running pods, though the update latency depends on the kubelet's sync period.

03

Immutable Configuration

ConfigMaps can be marked as immutable. When immutable: true is set in the ConfigMap spec, its data cannot be updated after creation.

Benefits:

  • Security: Prevents accidental or malicious runtime modifications that could affect application behavior.
  • Performance: Significantly reduces load on the kube-apiserver as it stops watching for changes on these objects.
  • Predictability: Ensures the configuration for a given pod revision is static, which is critical for canary deployments and rollback scenarios. To update an immutable ConfigMap, you must delete and recreate it, which typically requires a new pod deployment.
04

Namespace Scoping

ConfigMaps are namespaced objects. They exist within a specific Kubernetes namespace and are only accessible to pods residing in that same namespace. This provides natural isolation for configuration between different environments (e.g., dev, staging, prod) or teams sharing a cluster.

Operational Implications:

  • A pod can only reference a ConfigMap in its own namespace.
  • Role-Based Access Control (RBAC) policies can be applied at the namespace level to control who can read or modify ConfigMaps.
  • For configuration needed cluster-wide (e.g., a corporate CA certificate), the ConfigMap must be created in each namespace or alternative methods like a DaemonSet with a hostPath volume might be considered.
05

Separation from Application Code

The primary architectural benefit of a ConfigMap is the separation of configuration from application code. This adheres to the Twelve-Factor App methodology.

Consequences:

  • The same container image can be promoted through different environments (dev, prod) by binding it to environment-specific ConfigMaps.
  • Configuration changes do not require rebuilding and repushing the container image, enabling faster and safer deployments.
  • Configuration can be managed via the same GitOps workflows (e.g., using ArgoCD or Flux) as other Kubernetes manifests, providing versioning, audit trails, and rollback capabilities.
06

Limitations and Constraints

Understanding ConfigMap constraints is vital for production design:

  • Size Limit: Individual ConfigMaps have a practical size limit of ~1 MiB. Larger configurations should be split or stored in a PersistentVolume.
  • No Encryption: Data is stored as plaintext (base64 encoding is not encryption). Use a Secret for confidential data, though note Secrets are also base64-encoded by default.
  • Update Propagation Delay: For ConfigMaps mounted as volumes, updates can take up to the kubelet's sync period (default 1 minute) plus cache propagation delay to reach the pod.
  • Pod Dependency: A pod must be able to start even if its referenced ConfigMap is missing or invalid, or it will fail creation. Using optional references can mitigate this.
KUBERNETES CONFIGURATION MANAGEMENT

How ConfigMaps Work

A ConfigMap is a Kubernetes API object that decouples configuration artifacts from container images, enabling dynamic, environment-specific application configuration without rebuilding.

A ConfigMap is a Kubernetes API object used to store non-confidential configuration data as key-value pairs. This data can be injected into pods as environment variables, command-line arguments, or mounted as configuration files in a volume. By separating configuration from application code, ConfigMaps facilitate the same container image to be deployed across different environments—such as development, staging, and production—with environment-specific settings applied at runtime.

ConfigMaps are created from literals, files, or directories using kubectl. Within a pod specification, you define a volume from the ConfigMap and mount it to a container's filesystem, or you populate environment variables directly from its keys. Changes to a ConfigMap's data are eventually propagated to mounted volumes, though pods may require a restart to pick up new environment variables. For sensitive data like passwords, use the Secret object, which provides similar functionality with additional security measures like encryption at rest.

KUBERNETES CONFIGURATION

Common ConfigMap Use Cases

ConfigMaps decouple configuration artifacts from container images, enabling application configuration to be managed independently of the application lifecycle. Below are the primary patterns for consuming ConfigMap data within pods.

06

Shared Configuration Across Microservices

A single ConfigMap can be mounted into multiple pods across different deployments, providing a centralized source for common configuration. This is useful for microservices architectures where several services need the same baseline settings.

  • Consistency: Ensures all related services use identical values for shared resources (e.g., the address of a central caching service like Redis).
  • Centralized Management: A change to the shared ConfigMap can propagate to all consuming pods, though careful orchestration is required to manage rolling updates and avoid breaking changes.
KUBERNETES CONFIGURATION OBJECTS

ConfigMap vs. Secret: A Comparison

A feature-by-feature comparison of the two primary Kubernetes API objects used for injecting configuration data into pods, highlighting their distinct use cases and security postures.

FeatureConfigMapSecret

Primary Use Case

Storing non-confidential configuration data

Storing sensitive information

Data Encoding in Manifest

Plain text (key-value pairs)

Base64-encoded (key-value pairs)

Data Storage at Rest (etcd)

Plain text (unless encryption at rest is enabled)

Base64-encoded (not encrypted by default)

Recommended Security Posture

No special handling required

Enable etcd encryption at rest; use external secret providers (e.g., HashiCorp Vault)

Common Data Examples

Configuration files, environment variables, command-line arguments

Passwords, OAuth tokens, SSH keys, TLS certificates

Mountable as Volume

Consumable as Environment Variable

Automatic Update Propagation to Running Pods

Yes, for volumes (with some delay). No, for env vars.

Yes, for volumes (with some delay). No, for env vars.

Size Limit (Kubernetes 1.19+)

1 MiB

1 MiB

CONFIGMAP

Frequently Asked Questions

A ConfigMap is a core Kubernetes API object used to decouple configuration data from application code. This glossary answers common technical questions about its creation, use, and role in modern, observable deployments.

A ConfigMap is a Kubernetes API object used to store non-confidential configuration data as key-value pairs, which can be consumed by pods as environment variables, command-line arguments, or configuration files in a volume. Its primary purpose is to decouple environment-specific configuration from container images, enabling the same image to be used across different deployment stages (development, staging, production) by injecting different ConfigMaps. This separation is a foundational practice for Agent Deployment Observability, as it allows for clear versioning and auditing of configuration changes independent of code changes. ConfigMaps are namespace-scoped objects, meaning they exist within a specific Kubernetes namespace and are only accessible to pods within that same namespace.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.