How to merge two configmaps using volume mount in kubernetes

前端 未结 5 1747
醉酒成梦
醉酒成梦 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:20

    Another example of how this can be done for mounting multiple configmaps. This for an nginx dock were you want to both replace the main /etc/nginx/nginx.conf and the files in /etc/nginx/conn.f. This also deletes the default.conf file in conf.d

     containers:
        - name: nginx-proxy
          image: nginx:1.16-alpine
          imagePullPolicy: Always
          ports:
            - containerPort: 443
            - containerPort: 80
          volumeMounts:
            - name: nginx-main-conf-file
              mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf
            - name: nginx-site-conf-file
              mountPath: /etc/nginx/conf.d
      volumes:
        - name: nginx-main-conf-file
          configMap:
            name: nginx-main-conf
        - name: nginx-site-conf-file
          configMap:
            name: nginx-site-conf
    

    And one very important point. If you have any out commented lines (# something) in your yaml file, then this will not work. It's a bug. Tested in kubectl v1.14

提交回复
热议问题