Kubernetes - Create Config Map From Files Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 3 Likes Like Report Pre-requisite: Kubernetes While creating a manifest file in Kubernetes, we can define environment variables. However, when you have a lot of manifest files, it will become difficult to manage the environment data stored in various manifest files. To overcome this issue, we can manage environment data centrally using ConfigMaps. ConfigMaps are used to pass configuration data in the form of key-value pairs in Kubernetes. Let's say when a pod is created, ConfigMap is injected into that pod so that key-value pairs are available as environment variables for applications hosted inside the container in the pod. There are two phases involved in configuring ConfigMaps: 1. Create ConfigMap Using Definition File:You can use a definition/manifest file to create a ConfigMap and store environment variables. In the case of manifest files, we generally have a spec field whereas, in the case of a ConfigMap, we have a data or binary data field. The keys stored in the data field should not have a duplicate in the binary data field. Use a manifest file where we are creating a ConfigMap "app-config" with 2 environment variables "ENV" and "APP-COLOR".Manifest file for ConfigMap Using kubectl apply, we can create the manifest file on Kubernetes as shown in the image below.creating a manifest file on KubernetesUsing kubectl describe, we can see the environment variables within our ConfigMap.checking env variablesYou can create ConfigMaps from a particular file as well using the kubectl create configmap command. Let's say we have a file migration.properties where we have our environment variables as shown in the image belowenvironment variables in migration.propertiesenvs/migration.propertiesWe can use these properties files to create config maps using kubectl commands as shown belowCreating ConfigMap using a file These files can also be represented under the data section of manifest files as shown in the image belowConfigMaps from files2. Inject ConfigMap in Manifest Files:Now that we have the ConfigMap created, we need to inject it into our pod definition file. There are 3 ways to inject ConfigMaps in our pod definition file listed as follows: Injecting all the environment variables from ConfigMap. To inject a ConfigMap in the pod definition file, we use the envFrom property to our container field. Below is an image for your reference.Injecting a ConfigMapInjecting a single environment variable from a ConfigMap. Here, we use the env property under the containers field as shown in the image below.Injecting a single environment variable from ConfigMapInject environment data as a file in a volume. Below is an image for your reference.Injecting a file from the volume Comment D devanshpopli Follow 3 Improve D devanshpopli Follow 3 Improve Article Tags : Cloud Computing Explore Cloud Computing Tutorial 10 min read Basics Of Cloud ComputingIntroduction to Cloud Computing 10 min read History of Cloud Computing 4 min read Evolution of Cloud Computing 6 min read Characteristics of Cloud Computing 2 min read Advantages of Cloud Computing 8 min read Architecture of Cloud Computing 6 min read Cloud Computing Infrastructure 3 min read Cloud Management in Cloud Computing 6 min read What is Cloud Storage? 15 min read Real World Applications of Cloud Computing 6 min read Cloud Deployment ModelsCloud Deployment Models 12 min read Types of Cloud Computing 12 min read Difference Between Public Cloud and Private Cloud 6 min read Public Cloud vs Private Cloud vs Hybrid Cloud 7 min read Cloud Service ModelsCloud Based Services 11 min read Platform As A Service (PaaS) and its Types 11 min read Software As A Service (SaaS) 2 min read SaaS, PaaS and IaaS 4 min read Cloud VirtualizationVirtualization in Cloud Computing and Types 6 min read Difference between Cloud Computing and Virtualization 4 min read Pros and Cons of Virtualization in Cloud Computing 5 min read Data Virtualization 9 min read Hardware Based Virtualization 5 min read Server Virtualization 3 min read Types of Server Virtualization in Computer Network 4 min read Network Virtualization in Cloud Computing 4 min read Operating system based Virtualization 5 min read Cloud Service ProviderAmazon Web Services (AWS) Tutorial 9 min read Microsoft Azure Tutorial 13 min read Google Cloud Platform Tutorial 8 min read Advanced Concepts of CloudOn Premises VS On Cloud 3 min read Differences between Cloud Servers and Dedicated Servers 4 min read Cloud Networking 4 min read Server Consolidation in Cloud Computing 6 min read Hypervisor Security in Cloud Computing 5 min read Cloud Computing Security 5 min read Security Issues in Cloud Computing 5 min read 7 Privacy Challenges in Cloud Computing 5 min read Security Threats in Implementing SaaS of Cloud Computing 6 min read Multitenancy in Cloud computing 2 min read Middleware in Grid Computing 2 min read Difference between Cloud Computing and Grid Computing 4 min read Scalability and Elasticity in Cloud Computing 4 min read Cloud Bursting vs Cloud Scaling 7 min read Automated Scaling Listener in Cloud Computing 4 min read Difference Between Multi-Cloud and Hybrid Cloud 5 min read Difference Between Cloud Computing and Fog Computing 3 min read Overview of Multi Cloud 10 min read Service level agreements in Cloud computing 6 min read Overview of Everything as a Service (XaaS) 5 min read Resource Pooling Architecture in Cloud Computing 3 min read Load balancing in Cloud Computing 6 min read Overview of Desktop as a Service (DaaS) 5 min read IoT and Cloud Computing 6 min read Container as a Service (CaaS) 5 min read Principles of Cloud Computing 3 min read Resiliency in Cloud Computing 4 min read Serverless Computing 3 min read Like