Kubernetes and Cloud Native Associate (KCNA)Cloud Native ArchitectureMedium
A cloud-native development team is deploying a new service to Kubernetes. They want to ensure that the application's configuration, such as database connection strings and API keys, is managed securely and separately from the application code. This configuration needs to be injected into the running containers at runtime without rebuilding the Docker image. Which Kubernetes-native object is designed for this purpose?
- AService
- BConfigMap
- CPersistentVolume
- DDeployment
Show answer & explanationAnswer & explanation
Correct answer: B. ConfigMap
A ConfigMap is a Kubernetes object used to store non-confidential data in key-value pairs, which can then be injected into pods as environment variables or mounted as files, allowing configuration to be decoupled from application code.
Why the other options are wrong
- A. A Service defines a logical set of Pods and a policy by which to access them, acting as a stable network endpoint.
- C. A PersistentVolume is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned.
- D. A Deployment manages the desired state for a set of replica Pods, but doesn't store configuration itself.
Kubernetes ConfigMap
A Kubernetes API object used to store non-confidential configuration data in key-value pairs. It allows you to decouple configuration artifacts from image content to keep containerized applications portable.
- Stores non-confidential configuration data.
- Decouples config from application code.
- Injected into Pods as environment variables or files.
- Allows dynamic updates without rebuilding images.
Memory trick: ConfigMaps for non-secret data, Secrets for sensitive stuff.