How to merge two configmaps using volume mount in kubernetes

前端 未结 5 1796
醉酒成梦
醉酒成梦 2021-01-04 20:38

I am having two different config maps test-configmap and common-config. I tried to mount them at the same location, but one config map over

5条回答
  •  忘掉有多难
    2021-01-04 21:14

    You have to use special projected volumes for achieve that. Example your deployment:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: testing
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: testing
      template:
        metadata:
          name: testing
          labels:
            app: testing
        spec:
          containers:
          - name: testing-container
            image: testing
            imagePullPolicy: IfNotPresent
            ports:
            - containerPort: __PORT__
            volumeMounts:
            - name: commonconfig-volume
              mountPath: /usr/src/app/config
          volumes:
            - name: commonconfig-volume
              projected:
                sources:
                - configMap:
                    name: test-configmap
                - configMap:
                    name: common-config
    

    You can use secret same as configMap

提交回复
热议问题