网上搜到了很多,
有说用projected volumn的–不好用
有说用subpath加key的–我用也不好用

放上亲测可用的,关键点是volumeMounts的mountpath最后是直接加文件名(本来subpath是设计来避免文件夹覆盖的,这里文件也可以这么用。)

volumeMounts:
- name: cfg-vol
  mountPath: /etc/grafana/provisioning/datasources
- name: cfg-ini
  mountPath: /usr/share/grafana/conf/sample.ini
  subPath: sample.ini
- name: cfg-temp
  mountPath: /usr/share/grafana/conf/test.json
  subPath: test.json
  volumes:
  - name: cfg-vol
    configMap:
      name: cm-grafana-yaml
  - name: cfg-ini
    configMap:
      name: cm-grafana-ini
  - name: cfg-temp
    configMap:
      name: cm-grafana-temp
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐