From f4eef1dc0bad6b707f07ef3e59045ca32c128cd3 Mon Sep 17 00:00:00 2001 From: Jingfang Liu Date: Wed, 27 Feb 2019 13:26:58 -0800 Subject: [PATCH 1/2] update transformerconfigs/crd example --- examples/transformerconfigs/README.md | 1 - examples/transformerconfigs/crd/README.md | 39 +---------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/examples/transformerconfigs/README.md b/examples/transformerconfigs/README.md index d18f1e518c..292cc3e4be 100644 --- a/examples/transformerconfigs/README.md +++ b/examples/transformerconfigs/README.md @@ -91,6 +91,5 @@ nameReference: Kustomize has a default set of configurations. They can be saved to local directory through `kustomize config save -d`. Kustomize allows modifying those configuration files and using them in kustomization.yaml file. This tutorial shows how to customize those configurations to - [support a CRD type](crd/README.md) -- disabling adding commonLabels to fields in some kind of resources - add extra fields for variable substitution - add extra fields for name reference diff --git a/examples/transformerconfigs/crd/README.md b/examples/transformerconfigs/crd/README.md index 6943c416e0..00aee7f803 100644 --- a/examples/transformerconfigs/crd/README.md +++ b/examples/transformerconfigs/crd/README.md @@ -8,38 +8,6 @@ Create a workspace by DEMO_HOME=$(mktemp -d) ``` -### Get the native config as a starting point - -Get the default transformer configurations using this command: - - -``` -kustomize config save -d $DEMO_HOME/kustomizeconfig -``` -The default configurations are saved -in the directory `$DEMO_HOME/kustomizeconfig` as several files - -> ``` -> commonannotations.yaml -> commonlabels.yaml -> nameprefix.yaml -> namereference.yaml -> namespace.yaml -> varreference.yaml -> ``` - -These files contain the field specifications for native resources -that transformation directives like `namePrefix`, `commonLabels`, etc. -need to do their work. - -These default configurations already include some common -field specifictions for all types: - -- nameprefix is added to `.metadata.name` -- namespace is added to `.metadata.namespace` -- labels is added to `.metadata.labels` -- annotations is added to `.metadata.annotations` - ### Adding a custom resource Consider a CRD of kind `MyKind` with fields @@ -51,6 +19,7 @@ Consider a CRD of kind `MyKind` with fields Add the following file to configure the transformers for the above fields ``` +mkdir $DEMO_HOME/kustomizeconfig cat > $DEMO_HOME/kustomizeconfig/mykind.yaml << EOF commonLabels: @@ -148,12 +117,6 @@ in the kustomization file: cat >> $DEMO_HOME/kustomization.yaml << EOF configurations: - kustomizeconfig/mykind.yaml -- kustomizeconfig/commonannotations.yaml -- kustomizeconfig/commonlabels.yaml -- kustomizeconfig/nameprefix.yaml -- kustomizeconfig/namereference.yaml -- kustomizeconfig/namespace.yaml -- kustomizeconfig/varreference.yaml EOF ``` From b0c3cd75e1dc818c3a011db69ad387f82e8a1b1e Mon Sep 17 00:00:00 2001 From: Jingfang Liu Date: Wed, 27 Feb 2019 14:11:15 -0800 Subject: [PATCH 2/2] update the doc for crds: the files in this list should be openAPI definition --- docs/kustomization.yaml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/kustomization.yaml b/docs/kustomization.yaml index 75e1701fec..668405223a 100644 --- a/docs/kustomization.yaml +++ b/docs/kustomization.yaml @@ -201,7 +201,7 @@ patchesJson6902: path: add_service_annotation.yaml # Each entry in this list should be a relative path to -# a file for custom resource definition(CRD). +# a file for custom resource definition(CRD) in openAPI definition. # # The presence of this field is to allow kustomize be # aware of CRDs and apply proper @@ -211,9 +211,17 @@ patchesJson6902: # In kustomization, the ConfigMap object name may change by adding namePrefix, nameSuffix, or hashing # The name reference for this ConfigMap object in CRD object need to be # updated with namePrefix, nameSuffix, or hashing in the same way. +# +# The annotations can be put into openAPI definitions are: +# "x-kubernetes-annotation": "" +# "x-kubernetes-label-selector": "" +# "x-kubernetes-identity": "" +# "x-kubernetes-object-ref-api-version": "v1", +# "x-kubernetes-object-ref-kind": "Secret", +# "x-kubernetes-object-ref-name-key": "name", crds: -- crds/typeA.yaml -- crds/typeB.yaml +- crds/typeA.json +- crds/typeB.json # Vars are used to capture text from one resource's field # and insert that text elsewhere.