您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
37、存储 configmap(1)
发布时间:2022-12-30 21:14:32编辑:雪饮阅读()
Step1
基于目录的configmap创建
[root@k8s-master01 ~]# mkdir configmap
[root@k8s-master01 ~]# cd configmap/
[root@k8s-master01 configmap]# vi game.properties
[root@k8s-master01 configmap]# cat game.properties
enemies=aliens
lives=3
enemies.cheat=true
enemies.cheat.level=noGoodRotten
secret.code.passphrase=UUDDLRLRBABAS
secret.code.allowed=true
secret.code.lives=30
[root@k8s-master01 configmap]# vi ui.properties
[root@k8s-master01 configmap]# cat ui.properties
color.good=purple
color.bad=yellow
allow.textmode=true
how.nice.to.look=fairlyNice
[root@k8s-master01 configmap]# kubectl create configmap game-config --from-file=./
configmap/game-config created
可以看出,其实就基于当前目录创建,然后新创建的这个configmap名称为game-config
然后这个game-config中有两大配置分别是game和ui,那么game和ui的对应子配置键值对列表又在各自的properties文件中
以下两种方式都能看到新建的这个configmap
[root@k8s-master01 configmap]# kubectl get cm
NAME DATA AGE
game-config 2 2m13s
[root@k8s-master01 configmap]# kubectl get cm game-config
NAME DATA AGE
game-config 2 2m29s
当然查看configmap详情也是同样有两种方法的
[root@k8s-master01 configmap]# kubectl get cm game-config -o yaml
apiVersion: v1
data:
game.properties: |+
enemies=aliens
lives=3
enemies.cheat=true
enemies.cheat.level=noGoodRotten
secret.code.passphrase=UUDDLRLRBABAS
secret.code.allowed=true
secret.code.lives=30
ui.properties: |+
color.good=purple
color.bad=yellow
allow.textmode=true
how.nice.to.look=fairlyNice
kind: ConfigMap
metadata:
creationTimestamp: "2022-12-30T13:01:46Z"
name: game-config
namespace: default
resourceVersion: "166696"
selfLink: /api/v1/namespaces/default/configmaps/game-config
uid: 302501ad-ce7c-43d2-9b41-a2f63ec1cdf1
[root@k8s-master01 configmap]# kubectl describe cm game-config
Name: game-config
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
game.properties:
----
enemies=aliens
lives=3
enemies.cheat=true
enemies.cheat.level=noGoodRotten
secret.code.passphrase=UUDDLRLRBABAS
secret.code.allowed=true
secret.code.lives=30
ui.properties:
----
color.good=purple
color.bad=yellow
allow.textmode=true
how.nice.to.look=fairlyNice
Events: <none>
Step2
单文件创建configmap
其实单文件创建configmap和目录创建configmap实际上是差不多的,这里就以上面创建的game.properties为例:
[root@k8s-master01 configmap]# kubectl create configmap game-config2 --from-file=game.properties
configmap/game-config2 created
[root@k8s-master01 configmap]# kubectl get cm
NAME DATA AGE
game-config 2 5m52s
game-config2 1 13s
[root@k8s-master01 configmap]# kubectl describe cm game-config2
Name: game-config2
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
game.properties:
----
enemies=aliens
lives=3
enemies.cheat=true
enemies.cheat.level=noGoodRotten
secret.code.passphrase=UUDDLRLRBABAS
secret.code.allowed=true
secret.code.lives=30
Events: <none>
Step3
字面量创建configmap
字面量创建适合一些配置不是特别多的情况,如
[root@k8s-master01 configmap]# kubectl create configmap special-config --from-literal=special.how=very --from-literal=special.type=charm
configmap/special-config created
这里创建了special-config这个configmap,该configmap中有两个键值对
special.how=》very
special.type=》charm
就是说每一个--from-literal参数就指定一对键值对。
然后咱们也可以看看这个基于字面量创建的configmap
[root@k8s-master01 configmap]# kubectl describe cm special-config
Name: special-config
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
special.how:
----
very
special.type:
----
charm
Events: <none>
其实也都是差不了多少的。
关键字词:存储,configmap
相关文章
- 13_EL_获取域中存储的值_List集合&Map集合值
- 12_EL_获取域中存储的值_对象值(对象值、对象属性值(通
- 11_EL_获取域中存储的值(从request与session中拿取数据
- workerman的http服务-session管理-更改存储驱动
- workerman的http服务-session管理-设置session存储位
- workerman的http服务-session管理-更改session存储引
- workerman的http服务-session会话-存储session
- elasticSearch桶聚合-ip范围与IP类型字段存储方式
- 【第17章:Java数据库编程】_CallableStatement接口
- 06-Docker存储卷