How to use key value pair in kubernetes configmaps

2019-08-20 02:39发布

I have created a kubernetes configmap which contains multiple key value pairs. I want to mount each value in a different path. Im using helm to create charts.

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Values.name }}-configmap
  namespace: {{ .Values.namespace }}
  labels:
    name: {{ .Values.name }}-configmap
data:
    test1.yml: |-
  {{ .Files.Get .Values.test1_filename }}

    test2.yml: |-
  {{ .Files.Get .Values.test2_filename }}

I want test1.yml and test2.yml to be mounted in different directories.How can i do it?

1条回答
霸刀☆藐视天下
2楼-- · 2019-08-20 03:30

You can use subPath field to pickup specific file from configMap:

  volumeMounts:
  - mountPath: /my/first/path/test.yaml
    name: configmap
    subPath: test1.yaml
  - mountPath: /my/second/path/test.yaml
    name: configmap
    subPath: test2.yaml
查看更多
登录 后发表回答