Sunday, March 26, 2023

K8 ConfigMap

 ConfigMap:

A ConfigMap stores configuration settings that your Kubernetes Pods consume.

In Kubernetes, a ConfigMap is a resource object that stores configuration data in key-value pairs. 

This data can be used by containers running in a pod to configure applications and services. 

ConfigMaps provide a way to separate configuration data from application code, making it easier to manage configuration across multiple environments and deployments.

ConfigMaps can be created manually using the kubectl command-line tool or using YAML configuration files. 

Once a ConfigMap is created, it can be mounted as a volume or used as environment variables in a container. This allows applications to be configured without needing to rebuild or redeploy them.

ConfigMaps can be used to store any type of configuration data, including database connection strings, API endpoints, and application settings. 

They can be updated without restarting the associated containers, making it easy to make configuration changes on-the-fly. ConfigMaps can also be used in conjunction with Secrets to manage sensitive configuration data such as passwords and API keys.


How does a ConfigMap work?

A ConfigMap is a dictionary of key-value pairs that store configuration settings for your applications.

First, create a ConfigMap in your cluster by tweaking our sample YAML to your needs.

Second, consume to ConfigMap in your Pods and use its values.



Example:

This YAML creates a ConfigMap with the value database set to mongodb, and database_uri, and keys set to the values in the YAML example code.



Using a ConfigMap in Environment Variables

The key to adding your ConfigMap as environment variables to your pods is the envFrom property in your Pod’s YAML.




No comments:

Post a Comment

Sample Game App Deployment on EKS cluster

 https://padmakshi.medium.com/setting-up-an-eks-cluster-and-deploying-a-game-application-a-step-by-step-guide-08790e0be117