Skip to content
Branch: master
Find file Copy path
Find file Copy path
3 contributors

Users who have contributed to this file

@Liujingfang1 @monopole @thomas-riccardi
60 lines (52 sloc) 1.61 KB

Generator Options

Kustomize provides options to modify the behavior of ConfigMap and Secret generators. These options include

  • disable appending a content hash suffix to the names of generated resources
  • adding labels to generated resources
  • adding annotations to generated resources

This demo shows how to use these options. First create a workspace.

DEMO_HOME=$(mktemp -d)

Create a kustomization and add a ConfigMap generator to it.

cat > $DEMO_HOME/kustomization.yaml << EOF
- name: my-configmap
  - foo=bar
  - baz=qux

Add following generatorOptions

cat >> $DEMO_HOME/kustomization.yaml << EOF
 disableNameSuffixHash: true
   kustomize.generated.resource: somevalue
   annotations.only.for.generated: othervalue

Run kustomize build and make sure that the generated ConfigMap

  • doesn't have name suffix
    test 1 == \
    $(kustomize build $DEMO_HOME | grep "name: my-configmap$" | wc -l); \
    echo $?
  • has label kustomize.generated.resource: somevalue
    test 1 == \
    $(kustomize build $DEMO_HOME | grep -A 1 "labels" | grep "kustomize.generated.resource" | wc -l); \
    echo $?
  • has annotation annotations.only.for.generated: othervalue
    test 1 == \
    $(kustomize build $DEMO_HOME | grep -A 1 "annotations" | grep "annotations.only.for.generated" | wc -l); \
    echo $?
You can’t perform that action at this time.