ConfigMapThis article is about pod configuration mapping in Kubernetes. Here, we will learn how we can create and manage the ConfigMapConfigMap in our Kubernetes applications. ConfigMapConfigMap is useful for managing the configuration data in a microservices-based architecture where we have many different components that need access to distinct configuration data. We will explain the ConfigMapConfigMap configuration process in Kubernetes by dividing it into different chunks or parts in this article. We will walk through each step while also presenting each command and its corresponding output against Kubernetes applications that run in our system.
What Is ConfigMap in Kubernetes?
Here, we’ll only talk about Kubernetes’ ConfigMapConfigMap. We can store the configuration, thanks to ConfigMap, to another resource. The configuration data that our application cluster needs can be stored in these key values. Since our container image is easily portable and its environment-specific settings can be separated from it, we can use a ConfigMapConfigMap. Without encryption, the ConfigMap cannot be used. Secret should be used instead of ConfigMap if confidential information needs to be stored.
Users must know about Ubuntu and Linux operating systems. The latest version of Ubuntu must run on the User system and the system must have a high processor speed. Windows users must also run the Ubuntu on their system using Virtual Box. We install the Ubuntu version in the Virtual box and run the Ubuntu parallel to Windows operating system without switching down any operating system.
Let’s start our topic configuration mapping in Kubernetes. We will explain it to you step-by-step in a better way. Let’s start with the first step.
Step 1: Run the Minikube Kubernetes
In this step, we run the minikube in our Kubernetes application. Minikube is essentially a locally running cluster in which we configure the ConfigMap in our application. We run the following command:
When we run this command, the minikube is successfully started in our system.
Step 2: Setup the Pod ConfigMap Folder in Kubernetes
In this step, we will learn how to create a folder of pod containers that is related to ConfigMap in Kubernetes. Run the following command on the terminal:
When a command is executed, a system folder is created. In the Ubuntu operating system, the “mkdir” command creates a new directory. The “-p” option creates a parent directory if one does not already exist. The ConfigMap folder is then created in the Kubernetes system’s configure-pod-container directory. As a result, we successfully create a ConfigMap folder in Kubernetes using this command if the folder does not exist. Otherwise, this command is useless.
Step 3: Download the File of Game Properties in Configure-Pod-Container
In this step, we download a file to add the game properties to the ConfigMap directory in pod-configure-container using the following link. We run the command to configure the game properties on the terminal:
When we run the command, the game properties are added to our Kubernetes application configuration directory, as shown in the previous screenshot. The file is downloaded through the mentioned link.
Step 4: Download the UI Properties through the Link in Kubernetes
In this step, we discuss the configuration of UI properties in Kubernetes. Here, we download a UI property through the URL. We issue the command and specify the URL from which the UI properties file are downloaded. Run the following command:
Upon the command execution, the file of UI properties starts downloading in the ConfigMap directory in our Kubernetes application, as shown in the previous output as displayed in the attached screenshot. We use the “wget” command-line utility to specifically download the files from the internet. We can also verify that this file is downloaded to the specified location in the command after the download.
Step 5: Create a ConfigMap in the Container
In this step, we create a ConfigMap in our directory. We run the command for this purpose. The command is as follows:
When the command is executed, the ConfigMap named “game-config” is created from the file that is located in the “configure-pod-container” directory named “ConfigMap”. The game-config is successfully created, as shown in the previous screenshot.
Step 6: Display Information About Kubernetes Resources
In this step, we enlist all running resources in Kubernetes. Here, we only show the list of Kubernetes resources that are in “game-config” config map. We run the commands on the kubectl command-line tool.
This command essentially returns the detailed information about the ConfigMap”game-config” ConfigMap such as metadata, namespaces, labels, and annotations of the config pod. The output of this command is attached in the previous screenshot.
Step 7: Representation of ConfigMap in Kubernetes
In this step, we get the YAML representation of a ConfigMap in our Kubernetes cluster. We run the command on the kubectl command-line terminal as mentioned in the following:
When the command is executed, the YAML file of game-config is displayed in the output. The command’s output is shown in the previous screenshot. In a command, the “-o” is a flag that specifies the file output. In this file, the game.properties and ui.properties details are displayed in return.
Step 8: Create Another File of ConfigMap in Kubernetes Directory
In this step, we create a ConfigMap file again in Kubernetes. We run the command on the kubectl command line tool. The command is as follows:
When we run the command, the “game-config-2” file in the ConfigMap directory is successfully created, as shown in the attached screenshot.
Step 9: Describe the ConfigMaps File in Kubernetes
In this step, we describe the resources of ConfigMap files in detail. We run the following command:
We can see the output which is shown in the previous screenshot. Here, the name, namespace, labels, annotations of the file, and along with this all-packages detail are shown on this file.
We conclude that the ConfigMap directory is the best way to manage the configuration across different architectures. As we saw throughout the ConfigMap explanation process in the preceding sessions, we explained every point very clearly. You can edit these commands on your Kubernetes application for better understanding. ConfigMap is an important feature of Kubernetes, and the users must know about ConfigMap in Kubernetes.