2018年06月19日 18:57:51 画个圈圈自己跳 阅读数:1778
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhangxiangui40542/article/details/80737783
问题表现:
解决办法:
1、volumes中设置path
2、volumeMounts中这是subPath
ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: smartcity-frontend-config
namespace: portal-frontend
data:
config-js: | xxxx自定义文件内容
log4j-js-json: | xxxx自定义文件内容
Deployment(正确挂载方式)
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: smartcity-frontend
namespace: portal-frontend
spec:
replicas: 2
selector:
matchLabels:
app: smartcity-frontend
template:
metadata:
labels:
app: smartcity-frontend
spec:
containers:
- name: node
image: hub.cloud.pub/frontend/node:2.12.4
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- name: smartcity-frontend-config
mountPath: /opt/frontend/config.js
subPath: path/to/config.js
- name: smartcity-frontend-config
mountPath: /opt/frontend/log4js.json
subPath: path/to/log4js.json
volumes:
- name: smartcity-frontend-config
configMap:
name: smartcity-frontend-config
items:
- key: config-js
path: path/to/config.js
- key: log4j-js-json
path: path/to/log4js.json