下面以chart为例子:
1、创建ConfigMap,这里要注意config.js为挂载的文件名
[root@cn-hongkong templates]# cat app-config.yaml apiVersion: v1 kind: ConfigMap metadata: name: {{ .Values.app.name }}-config namespace: {{ .Values.app.namespace }} data: config.js: | {{ .Values.configjs | indent 4 }}
2、Deployment部分,意思就是讲ConfigMap中的config.js文件挂载覆盖/usr/share/nginx/page-management/js/config.js。单个文件挂载要用参数:subPath
volumeMounts: - name: config-js mountPath: "/usr/share/nginx/page-management/js/config.js" subPath: config.js volumes: - name: config-js configMap: name: page-management-nginx-config
3、values.yaml部分,注意"|"下面的配置要缩进2个空格
configjs: | window.webApi = { AXIOS_TIMEOUT: 10000 }