增加configMap文件到deployment挂载卷
创建configMap,nginx配置文件nginx.conf和default.conf
kubectl create configmap nginxconfig --from-file nginx.conf=nginx.conf --from-file default.conf=default.conf -n openeuler
挂载卷配置,将多个配置文件映射数据添加到卷中的特定路径
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: deploy-volume
name: deploy-volume
namespace: openeuler
spec:
selector:
matchLabels:
app: deploy-volume
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: deploy-volume
spec:
volumes:
- name: nginx-config
configMap:
name: nginxconfig
items:
- key: nginx.conf
path: nginx.conf
- key: default.conf
path: default.conf
containers:
- image: nginx
name: deploy-volume
resources: {}
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: nginx-config
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
status: {}
kubectl apply -f deploy-volume.yaml