kubernetes - ConfigMap mount into single file

5/24/2019

I'm trying to mount a file using configmap during kubernetes deployment. I have my application properties as data in my configmap. I'm creating configmap using kustomize. Kustomize will help to merge two configmaps. When I build kustomize it returns configmap like

apiVersion: v1
data:
  append.properties: |
    TEST_PROPERTY_1=5
  base.properties: |
    TEST_PROPERTY_2=test
kind: ConfigMap
metadata:
  name: test-configmap

When I mount this config map it will create two different files. But I want to merge into a single file. my application server will expect a single property file. Can someone help this problem?

-- Dinesh
configmap
kubernetes
kustomize

3 Answers

5/24/2019

I'd suggest using a startup script to merge these two files into one property file when the pod startup.

-- Kun Li
Source: StackOverflow

6/5/2019

I think config mixin documentation is what you are looking for. You are probably just missing the

behavior: merge

in the configMapGenerator of your overlay.

-- ITChap
Source: StackOverflow

5/24/2019

you can try this

apiVersion: v1
data:
  append.properties: |
    TEST_PROPERTY_1=5
    TEST_PROPERTY_2=test
kind: ConfigMap
metadata:
  name: test-configmap


you can also look at loading properties from the two files as env variables, like below

      envFrom:
      - configMapRef:
          name: append.properties
-- P Ekambaram
Source: StackOverflow