|NO.Z.00173|——————————|CloudNative|——|KuberNetes&配置管理.V04|——|configmap.v04|从生成器创建configmap|
一、从生成器中创建一个configmap
### --- 从生成器中创建一个configmap
~~~ # 从文件中生产configmap
~~~ 从文件生成ConfigMap configure-pod-container/configmap/game.properties
~~~ kubectlkustomization.yaml自1.14开始支持。您还可以从生成器创建ConfigMap,
~~~ 然后将其应用于在Apiserver上创建对象。生成器应在kustomization.yaml目录内部指定。
### --- 创建一个kustomzation,yaml文件configmapGenerator
[root@k8s-master01 configmap]# cat <<EOF >./kustomization.yaml
configMapGenerator:
- name: game-config-4
files:
- configure-pod-container/configmap/game.properties
EOF
### --- 应用kustomization目录创建configmap对象
[root@k8s-master01 ~]# kubectl apply -k .
configmap/game-config-4-m9dm2f92bt created
二、检查configmap是按照以下方式创建的
### --- 检查configmap是按照以下方式创建的
[root@k8s-master01 ~]# kubectl get configmap
NAME DATA AGE
game-config-4-m9dm2f92bt 1 19s
### --- 查看容器创建流程
~~~ 请注意,生成的ConfigMap名称具有通过对内容进行散列而附加的后缀。
~~~ 这样可以确保每次修改内容时都会生成一个新的ConfigMap
[root@k8s-master01 ~]# kubectl describe configmaps/game-config-4-m9dm2f92bt
Name: game-config-4-m9dm2f92bt
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>
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
浙公网安备 33010602011771号