0

I am searching for a way to add a specific label to ConfigMap using Kustomize. Using commonLabels is not an option because it adds a label to every resource. For config map generation, I am using the following:

configMapGenerator:
- name: ${REPOSITORY_NAME}-env
  envs:
  - .env

And I would like to achieve something like this:

configMapGenerator:
- name: ${REPOSITORY_NAME}-env
  labels:
    key: value
  envs:
  - .env
Jonas
  • 121,568
  • 97
  • 310
  • 388
Bjørson Bjørson
  • 1,583
  • 1
  • 17
  • 31
  • 1
    You could move the configmapGenerator to its own directory with only this file and be able to use commonLabels in this directory. Then use the directory as a base in orher directories. – Gaël J Jun 15 '23 at 18:58

1 Answers1

1

As per this git link you can add specific labels by using patch files in kustomize.

apiVersion: v1
data:
  a: "0"
kind: ConfigMap
metadata:
  labels:
    apps: a
  name: a-config-map-26kgmbk2md

Then add these in the configMapGenerator

configMapGenerator:
  - name: a-config-map
    envs:
      - a.properties
patchesStrategicMerge:
  - patch-a.yaml

This will add the specific label to individual configMaps to the configmap generator.

Additionally you can also refer to this git issue for additional information.

Sai Chandra Gadde
  • 2,242
  • 1
  • 3
  • 15