File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,24 @@ secretGenerator:
102
102
envCommand : printf \"DB_USERNAME=admin\nDB_PASSWORD=somepw\"
103
103
type : Opaque
104
104
105
+ # generatorOptions modify behavior of all ConfigMap and Secret generators
106
+ generatorOptions :
107
+ # labels to add to all generated resources
108
+ labels :
109
+ kustomize.generated.resources : somevalue
110
+ # annotations to add to all generated resources
111
+ annotations :
112
+ kustomize.generated.resource : somevalue
113
+ # timeoutSeconds specifies the timeout for commands
114
+ timeoutSeconds : 30
115
+ # shell and arguments to use as a context for commands used in resource
116
+ # generation. Default at time of writing: ["sh", "-c"]
117
+ shell : ["sh", "-c"]
118
+ # disableNameSuffixHash is true disables the default behavior of adding a
119
+ # suffix to the names of generated resources that is a hash of
120
+ # the resource contents.
121
+ disableNameSuffixHash : true
122
+
105
123
# Each entry in this list should resolve to a directory
106
124
# containing a kustomization file, else the
107
125
# customization fails.
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ go get sigs.k8s.io/kustomize
29
29
30
30
* [ configGenerations] ( configGeneration.md ) -
31
31
Rolling update when ConfigMapGenerator changes
32
+
33
+ * [ generatorOptions] ( generatorOptions.md ) - Modifying behavior of all ConfigMap and Secret generators.
32
34
33
35
* [ breakfast] ( breakfast.md ) - Customize breakfast for
34
36
Alice and Bob.
Original file line number Diff line number Diff line change
1
+ # Generator Options
2
+
3
+ Kustomize provides options to modify the behavior of ConfigMap and Secret generators. These options include
4
+
5
+ - disable appending a content has suffix to the names of generated resources
6
+ - adding labels to generated resources
7
+ - adding annotations to generated resources
8
+ - changing shell and arguments for getting data from commands
9
+ - changing timeout for executing commands
10
+
11
+ This demo shows how to use these options. First create a workspace.
12
+ ```
13
+ DEMO_HOME=$(mkdir -d)
14
+ ```
15
+
16
+ Create a kustomization and add a ConfigMap generator to it.
17
+
18
+ <!-- @createCMGenerator @test -->
19
+ ```
20
+ cat > $DEMO_HOME/kustomization.yaml << EOF
21
+ configMapGenerator:
22
+ - name: my-configmap
23
+ literals:
24
+ - foo=bar
25
+ - baz=qux
26
+ EOF
27
+ ```
28
+
29
+ Add following generatorOptions
30
+ <!-- @addGeneratorOptions @test -->
31
+ ```
32
+ cat >> $DEMO_HOME/kustomization.yaml << EOF
33
+ generatorOptions:
34
+ disableNameSuffixHash: true
35
+ labels:
36
+ kustomize.generated.resource: somevalue
37
+ annotations:
38
+ annotations.only.for.generated: othervalue
39
+ EOF
40
+ ```
41
+ Run ` kustomize build ` and make sure that the generated ConfigMap
42
+
43
+ - doesn't have name suffix
44
+ <!-- @verify @test -->
45
+ ```
46
+ test 1 == \
47
+ $(kustomize build $DEMO_HOME | grep "name: my-configmap$" | wc -l); \
48
+ echo $?
49
+ ```
50
+ - has label `kustomize.generated.resource: somevalue`
51
+ ```
52
+ test 1 == \
53
+ $(kustomize build $DEMO_HOME | grep -A 1 "labels" | grep "kustomize.generated.resource" | wc -l); \
54
+ echo $?
55
+ ```
56
+ - has annotation `annotations.only.for.generated: othervalue`
57
+ ```
58
+ test 1 == \
59
+ $(kustomize build $DEMO_HOME | grep -A 1 "annotations" | grep "annotations.only.for.generated" | wc -l); \
60
+ echo $?
61
+ ```
62
+
You can’t perform that action at this time.
0 commit comments