Referencing other files content using just the filename inside ConfigMap in k8s

9/30/2021

Let's say I have a couple of JSON (a.json,b.json, c.json) files containing some data (a : "data", b : "some_data", c : "some_more_data" }. Now I create a ConfigMap using this files so the map looks like

apiVersion: v1
kind: ConfigMap
metadata:
  name: a-data
  namespace: monitoring
data:
  a.json: |
    a : "data"      // I want to remove this part
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: b-data
  namespace: monitoring
data:
  b.json: |
     b : "some_data"    // I want to remove this part
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: c-data
  namespace: monitoring
data:
  c.json: |
    c : "some_more_data"    // I want to remove this part

Now the files a.json,b.json can be very big and I don't want my ConfigMap file to be very large. I was wondering if there is a way so that I can just give a reference to the filename and the data will be picked from the actual file. Basically, I want to trim out the contents of json files from the ConfigMap but the use-case will remain the same. Help will be appreciated.

-- Rahul Agrawal
configmap
grafana
kubernetes

0 Answers