当前位置:网站首页>configmap
configmap
2022-04-23 05:04:00 【canger_】
establish ConfigMap
Be careful : ConfigMap The key name in must be a legal DNS Domain , Contains only numbers and letters 、 Dashes 、 Draw lines and dots below , The first dot symbol is optional
Use command kubectl establish ConfigMap
$ kubectl create configmap app-config --from-literal=qos=1
This command creates a file called app-config Of ConfigMap, And contains only configuration items qos=1
As shown below :
root@VM-16-4-ubuntu:~/code/charts/stable# kubectl create configmap app-config --from-literal=qos=1
configmap/app-config created
root@VM-16-4-ubuntu:~/code/charts/stable# kubectl get cm
NAME DATA AGE
app-config 1 6s
kube-root-ca.crt 1 25d
root@VM-16-4-ubuntu:~/code/charts/stable# kubectl describe cm app-config
Name: app-config
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
qos:
----
1
BinaryData
====
Events: <none>
root@VM-16-4-ubuntu:~/code/charts/stable#
If you want more than one configuration item, it comes with more than one --from-literal
adopt Yaml establish ConfigMap
command :
$ kubectl create -f app-config.yaml
Yaml Format :
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
app-config.ini: | [MQ] qos=1
Create... From the contents of the file ConfigMap
ConfigMap You can also store coarse-grained configuration data , For example, a complete configuration file .kubectl create configmap
The command supports reading files from disk , And store the contents of the file separately as
ConfigMap Items in
$ kubectl create configmap app-config --from-file=app-config.ini
After creation, it is as follows :
root@VM-16-4-ubuntu:~# kubectl get cm app-config -o yaml
apiVersion: v1
data:
app-config.ini: |
[MQ]
qos=1
kind: ConfigMap
metadata:
creationTimestamp: "2022-02-15T07:03:34Z"
name: app-config
namespace: default
resourceVersion: "2829911"
uid: c9f74808-129b-4cf2-96c3-5489194609ea
When running the above command , kubectl Will find in the current directory app-config.ini
file , And store the contents of the file in ConfgMap China and Israel app-config.ini
Under the entry for the key name , Of course, you can also specify the key name manually :
$ kubectl create configmap app-config --from-file=customkey=app-config.ini
After creation, it is as follows :
root@VM-16-4-ubuntu:~# kubectl get cm app-config -o yaml
apiVersion: v1
data:
customkey: |
[MQ]
qos=1
kind: ConfigMap
metadata:
creationTimestamp: "2022-02-15T07:04:51Z"
name: app-config
namespace: default
resourceVersion: "2830017"
uid: 58c4184c-6d09-4ecb-9dd3-a252c9dc04df
Same as when using literal quantity , Used multiple times --from-file Parameter can add multiple file entries
Create... From a folder ConfigMap
In addition to introducing each file separately , You can even import all the files in a folder
$ kubectl create configmap my-config --from-file=/path/to/dir
In this case , kubectl A separate entry is created for each file in the folder , Only those file names can be used as legal ConfigMap File with key name
see ConfigMap
command :
$ kubectl get cm
as follows :
root@VM-16-4-ubuntu:~# kubectl get cm
NAME DATA AGE
app-config 1 8m17s
kube-root-ca.crt 1 25d
modify ConfigMap
command :
$ kubectl edit cm cm-name
for example :
root@VM-16-4-ubuntu:~# kubectl edit cm app-config
Edit cancelled, no changes made.
modify ConfigMap Pay attention to pod Whether the application in will reload the configuration , Otherwise, restart is required pod To read the changed configuration again .
Delete ConfigMap
command :
$ kubectl delete cm cm-name
for example :
root@VM-16-4-ubuntu:~/code/charts/stable# kubectl delete cm app-config
configmap "app-config" deleted
版权声明
本文为[canger_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220552063667.html
边栏推荐
- Painless upgrade of pixel series
- Sword finger offer: the path with a certain value in the binary tree (backtracking)
- The vscode ipynb file does not have code highlighting and code completion solutions
- Opencv + clion face recognition + face model training
- [winui3] write an imitation Explorer file manager
- 深度学习笔记 —— 微调
- Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)
- Innovation training (10)
- JS determines whether the numeric string contains characters
- Informatics Olympiad 1955: [11noip popularization group] Swiss round | openjudge 4.1 4363: Swiss round | Luogu p1309 [noip2011 popularization group] Swiss round
猜你喜欢
[database] MySQL multi table query (I)
Pixel mobile phone brick rescue tutorial
【数据库】MySQL单表查询
深度学习笔记 —— 微调
#define 定义常量和宏,指针和结构体
Transaction isolation level of MySQL transactions
[2022 ICLR] Pyramid: low complexity pyramid attention for long range spatiotemporal sequence modeling and prediction
How can continuous integration (CI) / continuous delivery (CD) revolutionize automated testing
AQS source code reading
【数据库】MySQL基本操作(基操~)
随机推荐
JS détermine si la chaîne de nombres contient des caractères
Details related to fingerprint payment
A trinomial expression that causes a null pointer
深度学习笔记 —— 数据增广
Innovation training (V) configuration information
Innovation training (XII) reptile
什么是指令周期,机器周期,和时钟周期?
Independent station operation | Facebook marketing artifact - chat robot manychat
PHP counts the number of files in the specified folder
跨境电商 | Facebook 和 Instagram:哪个社交媒体更适合你?
Informatics Aosai yibentong 1212: letters | openjudge 2.5 156: Letters
Progress of innovation training (IV)
洛谷P2731骑马修栅栏
Leetcode -- heuristic search
COM in wine (2) -- basic code analysis
独立站运营 | FaceBook营销神器——聊天机器人ManyChat
2022/4/22
Painless upgrade of pixel series
TypeError: ‘Collection‘ object is not callable. If you meant to call the ......
【数据库】MySQL多表查询(一)