Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using ConfigMap created using Generator in Kustomize/Kubernetes

I have been trying to figure out how to consume a ConfigMap created using a ConfigMap generator via Kustomize.

When created using Kustomize generators, the configMaps are named with a special suffix. See here:

https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-a-configmap-from-generator

Question is how can this be referenced?

like image 684
user3123834 Avatar asked Sep 14 '25 12:09

user3123834


1 Answers

You don't reference it yourself. Kustomize recognizes where the configMap is used in the other resources (like a Deployment) and changes those references to use the name+hash.

The reason for this is so that if you change the configMap, Kustomize generates a new hash and updates the Deployment, causing a rolling restart of the Pods.

If you don't want this behavior, you can add the following to your kustomization.yaml file:

generatorOptions:
  disableNameSuffixHash: true
like image 122
monachus Avatar answered Sep 17 '25 19:09

monachus