Configmap Description of Kubernetes
In this blog post, let's say a question about customizing the configuration in the pod of kubernetes.
We know that in almost all application development, configuration file changes are involved, such as in the Web program, the need to connect to the database, cache, and even queues. And one of our applications starts with writing the first line of code, going through the development environment, the test environment, the pre-release environment only to the final online environment. Each environment is defined by its own set of configurations. If we do not manage these configuration files well, your operations will suddenly become extremely cumbersome. For this, some of the industry's major companies have developed their own set of configuration management center, such as Qcon, Baidu's disconf and so on. Kubernetes also offers its own set of options, namely Configmap. Kubernetes uses Configmap to implement configuration management for applications in containers.
Create Configmap
There are 4 ways to create Configmap:
-
-
Created by specifying the CONFIGMAP parameter directly on the command line, i.e.--from-literal
-
-
Create a configuration file as a configmap by specifying the file creation--from-file=<文件>
-
-
By specifying the directory creation, all profiles under a directory are created as a configmap,--from-file=<目录>
Created by the Yaml file, and the other by Kubectl directly at the command line.
-
-
Write the standard configmap Yaml file in advance, and then Kubectl create-f create
Using Configmap
There are three ways to use Configmap, one is to pass the pod directly through the environment variable, the other is to run it through the command line of the pod, and the third is to mount it in the pod using volume.
After updating Configmap:
ENV is injected when the container is started, kubernetes will not change the value of the environment variable after startup, and the environment variable of pod in the same namespace is constantly accumulating, refer to The service discovery in Kubernetes and the environment variable transfer between Docker containers is explored. In order to update the configuration using Configmap mounts in the container, you can force the Configmap to be re-mounted by rolling the pod update, or you can set the number of replicas to 0 before you update the CONFIGMAP, and then expand the capacity.
Configmap Description of Kubernetes
Reference https://www.cnblogs.com/breezey/p/6582082.html
Kubernetes configmap Thermal Update test
Https://www.kubernetes.org.cn/3138.html
Kubernetes's Configmap explanation
Reference 79492374
Kubernetes Configmap Detailed