generatorOptions

Control behavior of ConfigMap and Secret generators.

Additionally, generatorOptions can be set on a per resource level within each generator. For details on per-resource generatorOptions usage see field-name-configMapGenerator and See field-name-secretGenerator.

  1. apiVersion: kustomize.config.k8s.io/v1beta1
  2. kind: Kustomization
  3. generatorOptions:
  4. # labels to add to all generated resources
  5. labels:
  6. kustomize.generated.resources: somevalue
  7. # annotations to add to all generated resources
  8. annotations:
  9. kustomize.generated.resource: somevalue
  10. # disableNameSuffixHash is true disables the default behavior of adding a
  11. # suffix to the names of generated resources that is a hash of
  12. # the resource contents.
  13. disableNameSuffixHash: true

Example I

Using ConfigMap

Input Files

  1. apiVersion: kustomize.config.k8s.io/v1beta1
  2. kind: Kustomization
  3. configMapGenerator:
  4. - name: my-application-properties
  5. files:
  6. - application.properties
  7. generatorOptions:
  8. labels:
  9. kustomize.generated.resources: config-label
  10. annotations:
  11. kustomize.generated.resource: config-annotation
  1. # application.properties
  2. FOO=Bar

Output File

  1. apiVersion: v1
  2. data:
  3. application.properties: |-
  4. # application.properties
  5. FOO=Bar
  6. kind: ConfigMap
  7. metadata:
  8. annotations:
  9. kustomize.generated.resource: config-annotation
  10. labels:
  11. kustomize.generated.resources: config-label
  12. name: my-application-properties-f7mm6mhf59

Example II

Using Secrets

Input Files

  1. # kustomization.yaml
  2. apiVersion: kustomize.config.k8s.io/v1beta1
  3. kind: Kustomization
  4. secretGenerator:
  5. - name: app-tls
  6. files:
  7. - "tls.cert"
  8. - "tls.key"
  9. type: "kubernetes.io/tls"
  10. generatorOptions:
  11. labels:
  12. kustomize.generated.resources: secret-label
  13. annotations:
  14. kustomize.generated.resource: secret-annotation
  15. disableNameSuffixHash: true

Output File

  1. apiVersion: v1
  2. data:
  3. tls.cert: TFMwdExTMUNSVWQuLi50Q2c9PQ==
  4. tls.key: TFMwdExTMUNSVWQuLi4wdExRbz0=
  5. kind: Secret
  6. metadata:
  7. annotations:
  8. kustomize.generated.resource: secret-annotation
  9. labels:
  10. kustomize.generated.resources: secret-label
  11. name: app-tls
  12. type: kubernetes.io/tls