Ensure you have minikube installed and configured before using kubectl to edit a ConfigMap on Ubuntu 20.04 LTS. For the completion of this comprehensive article, you should have sudo privileges.
Method to create ConfigMaps configuration file
To begin, you must first open a command-line terminal. You can do this operation by utilizing the shortcut key Ctrl+Alt+T or by scrolling between applications.
You must run the following written command in your console as immediately as your terminal window appears.
To start with minikube, you have to pause for a few minutes after executing this program. You can also verify the minikube version exhibited after the command has been effectively executed.
Now we are ready to create ConfigMaps; for this purpose, we will use the touch command for file creation having. yaml extension.
The touch command is a basic yet important command in Linux systems that allows users to create files. It is one of the most basic terminal commands in Linux, and sysadmins frequently use it for a range of tasks. To execute the below-affixed command to create ConfigMaps configuration file.
There will be no output of this command on the terminal. The command will create a file in your home directory. You can verify it by going to the home directory of your Ubuntu 20.04 system. You can confirm that the file has been generated effectively.
Now we have to add some of the content in the file that we created earlier. The simplest approach to use ConfigMaps is to define them in YAML and mount them as a Volume. Create a YAML file with your ConfigMap’s key-value pairs. Here’s a sample ConfigMap with certain keys with single values and others with values that resemble a configuration style fragment.
You have to save the same content, and after saving it, you have to close the file. Now we are ready to create ConfigMaps in Kubernetes by utilizing the kubectl command. Execute the affixed command in the terminal shell of your Ubuntu 20.04 system.
The output depicts the effective creation of the config map in Kubernetes.
Method to edit ConfigMaps in Kubernetes using kubectl
Now, if you want to edit the same file, check out the below-appended command in the shell of your Ubuntu 20.04 system.
Upon the execution of the above-cited command, the following output will appear. You can alter the file as per your work needs.
We have discussed the concept of a ConfigMap in Kubernetes in the article mentioned above. In addition, we expanded on how to use kubectl to form a ConfigMap. After reading this post, I am confident that you will have no doubts about changing and creating a ConfigMap in kubectl.