挂载ConfigMap数据卷
更新时间:2024-09-25
挂载ConfigMap数据卷
本文介绍如何挂载ConfigMap数据卷。ConfigMap数据卷是一个配置文件,用于向BCI实例注入配置数据,具体详见create-a-configmap,同时BCI已支持ConfigMap配置文件的动态更新,即在K8S集群内更新ConfigMap配置文件内容,BCI Pod使用的该配置文件会自动更新。
配置示例
1.声明configMap
apiVersion: v1
kind: ConfigMap
metadata:
name: game-config
namespace: default
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
2.使用vk提交pod
apiVersion: v1
kind: Pod
metadata:
annotations:
myannotation: "myannotation"
labels:
app: bci-test-vk
mylabel: "mylabel"
name: config-file-test
namespace: default
spec:
nodeSelector:
type: virtual-kubelet
tolerations:
- effect: NoSchedule
key: virtual-kubelet.io/provider
operator: Equal
value: baidu
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
containers:
- image: hub.baidubce.com/cce/nginx-alpine-go
imagePullPolicy: IfNotPresent
name: c01
workingDir: /work
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: 250m
memory: 512Mi
requests:
cpu: 250m
memory: 512Mi
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
name: game-config