Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to manage configuration with ConfigMap

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about how to use ConfigMap to manage configuration, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Secret can provide Pod with sensitive data such as password, Token, private key, etc., and ConfigMap can be used for some non-sensitive data, such as application configuration information.

ConfigMap is created and used in a very similar way to Secret, except that the data is stored in clear text.

Like Secret, ConfigMap supports four creation methods:

1. Through-- from-literal:

Kubectl create configmap myconfigmap-from-literal=config1=xxx-from-literal=config2=yyy

Each-- from-literal corresponds to an information entry.

two。 Through-- from-file:

Echo-n xxx >. / config1echo-n yyy >. / config2kubectl create configmap myconfigmap-- from-file=./config1-- from-file=./config2

Each file content corresponds to an information entry.

3. Through-- from-env-file:

Cat env.txtconfig1=xxxconfig2=yyyEOFkubectl create configmap myconfigmap-from-env-file=env.txt

Each line of Key=Value in the file env.txt corresponds to an information entry.

4. Through the YAML configuration file:

The data in the file is entered directly in clear text.

Like Secret, Pod can also use Secret through Volume or environment variables.

Volume mode:

In most cases, configuration information is provided as a file, so ConfigMap is usually created in-- from-file or YAML mode, and ConfigMap is usually read in Volume mode.

For example, pass the configuration information on how to log to Pod:

Be careful not to leave out the | symbol after Key logging.conf.

Create and view the ConfigMap:

① specifies in volume that the relative path of the file where the configuration information is stored is myapp/logging.conf.

② volume mount to the container's / etc directory.

Create a Pod and read the configuration information:

The configuration information has been saved to the / etc/myapp/logging.conf file. Like Secret, ConfigMap in the form of Volume also supports dynamic updates, leaving it to everyone to practice.

We learned how to pass configuration information to Pod. If the information needs to be encrypted, you can use Secret;. If it is general configuration information, you can use ConfigMap.

Secret and ConfigMap support four definition methods. When using them, Pod can choose either Volume mode or environment variable mode, but only Volume mode supports dynamic updates.

The above is how to use ConfigMap to manage the configuration, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report