-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d718fe3
commit 4827d99
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Generator Options | ||
|
||
Kustomize provides options to modify the behavior of ConfigMap and Secret generators. These options include | ||
|
||
- disable appending a content has suffix to the names of generated resources | ||
- adding labels to generated resources | ||
- adding annotations to generated resources | ||
- changing shell and arguments for getting data from commands | ||
- changing timeout for executing commands | ||
|
||
This demo shows how to use these options. First create a workspace. | ||
``` | ||
DEMO_HOME=$(mkdir -d) | ||
``` | ||
|
||
Create a kustomization and add a ConfigMap generator to it. | ||
|
||
<!-- @createCMGenerator @test --> | ||
``` | ||
cat > $DEMO_HOME/kustomization.yaml << EOF | ||
configMapGenerator: | ||
- name: my-configmap | ||
literals: | ||
- foo=bar | ||
- baz=qux | ||
EOF | ||
``` | ||
|
||
Add following generatorOptions | ||
<!-- @addGeneratorOptions @test --> | ||
``` | ||
cat >> $DEMO_HOME/kustomization.yaml << EOF | ||
generatorOptions: | ||
disableNameSuffixHash: true | ||
labels: | ||
kustomize.generated.resource: somevalue | ||
annotations: | ||
annotations.only.for.generated: othervalue | ||
EOF | ||
``` | ||
Run `kustomize build` and make sure that the generated ConfigMap | ||
|
||
- doesn't have name suffix | ||
<!-- @verify @test --> | ||
``` | ||
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 $? | ||
``` | ||