Kustomize: Disabling hashed ConfigMap when using configMapGenerator

kustomize configMapGenerator ConfigMap

2 min read | by Jordi Prats

When we try to use configMapGenerator to generate a ConfigMap containing some files like this:

configMapGenerator: - name: config-files behavior: create files: - files/file1.txt - files/file2.txt 

By default, it is going to append a hash to it:

$ kubectl get configmap NAME DATA AGE config-files-m55tkfhh8f 2 45d 

If we need to access this ConfigMap by name we might want to remove the hash.

To do so we have two options, add the disableNameSuffixHash: true flag to all the different ConfigMaps we are defining:

configMapGenerator: - name: config-files  disableNameSuffixHash: true  behavior: create files: - files/file1.txt - files/file2.txt 

Or use the generatorOptions key to set a default for the entire kustomize.yaml file:

generatorOptions:  disableNameSuffixHash: true  configMapGenerator: - name: config-files  behavior: create  files:  - files/file1.txt  - files/file2.txt 

Either way, kustomize is going to create the ConfigMap without appending any hash to it:

$ kubectl get configmap NAME DATA AGE config-files 2 45d 

Posted on 07/03/2023