挂载ConfigMap数据卷
更新时间:2024-09-25
挂载ConfigMap数据卷
本文介绍如何挂载ConfigMap数据卷。ConfigMap数据卷是一个配置文件,用于向BCI实例注入配置数据,具体详见create-a-configmap,同时BCI已支持ConfigMap配置文件的动态更新,即在K8S集群内更新ConfigMap配置文件内容,BCI Pod使用的该配置文件会自动更新。
配置示例
1.声明configMap
Plain Text
1apiVersion: v1
2kind: ConfigMap
3metadata:
4 name: game-config
5 namespace: default
6data:
7 game.properties: |
8 enemies=aliens
9 lives=3
10 enemies.cheat=true
11 enemies.cheat.level=noGoodRotten
12 secret.code.passphrase=UUDDLRLRBABAS
13 secret.code.allowed=true
14 secret.code.lives=30
15 ui.properties: |
16 color.good=purple
17 color.bad=yellow
18 allow.textmode=true
19 how.nice.to.look=fairlyNice
2.使用vk提交pod
Plain Text
1apiVersion: v1
2kind: Pod
3metadata:
4 annotations:
5 myannotation: "myannotation"
6 labels:
7 app: bci-test-vk
8 mylabel: "mylabel"
9 name: config-file-test
10 namespace: default
11spec:
12 nodeSelector:
13 type: virtual-kubelet
14 tolerations:
15 - effect: NoSchedule
16 key: virtual-kubelet.io/provider
17 operator: Equal
18 value: baidu
19 - effect: NoExecute
20 key: node.kubernetes.io/not-ready
21 operator: Exists
22 tolerationSeconds: 300
23 - effect: NoExecute
24 key: node.kubernetes.io/unreachable
25 operator: Exists
26 tolerationSeconds: 300
27 containers:
28 - image: hub.baidubce.com/cce/nginx-alpine-go
29 imagePullPolicy: IfNotPresent
30 name: c01
31 workingDir: /work
32 ports:
33 - containerPort: 8080
34 protocol: TCP
35 resources:
36 limits:
37 cpu: 250m
38 memory: 512Mi
39 requests:
40 cpu: 250m
41 memory: 512Mi
42 volumeMounts:
43 - name: config-volume
44 mountPath: /etc/config
45 volumes:
46 - name: config-volume
47 configMap:
48 name: game-config