configMap的subPath及readOnly挂载文件案例
cat 18-pods-volumes-configMaps.yaml
apiVersion: v1
kind: Pod
metadata:
name: baimei-games-cm-subpath-006
spec:
nodeName: worker233
# hostNetwork: true
volumes:
- name: data01
configMap:
name: nginx-conf
items:
- key: nginx.conf
# path: nginx.conf
path: haha
- name: data02
configMap:
name: nginx-conf
items:
- key: games.conf
path: games.conf
containers:
- name: games
image: harbor.baimei.com/baimei-games/games:v0.5
volumeMounts:
- name: data01
# 指定挂载点,若不指定subPath属性,则挂载点默认为目录。若指定后,可以让挂载点对应的是一个文件。
mountPath: /etc/nginx/nginx.conf
# 指定subPath,声明其在挂载点的文件名称。要和"po.spec.volumes.configMap.items.path"相同。
# subPath: nginx.conf
subPath: haha
# 声明只读(ro)权限,默认是读写(rw)
readOnly: true
- name: data02
mountPath: /etc/nginx/conf.d/
欢迎来撩 : 汇总all