From a200df182e3d151ab7cfe44782f0d179254fe5b1 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Sun, 4 Dec 2022 19:03:33 -0500 Subject: [PATCH] docs: Add documentation for namespace transformer Add a short description of the namespace transformer and example usage to examples/transformerconfigs/README.md. References: #629 Signed-off-by: Lars Kellogg-Stedman --- examples/transformerconfigs/README.md | 61 +++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/examples/transformerconfigs/README.md b/examples/transformerconfigs/README.md index 6b3d8b56db4..92e038be0df 100644 --- a/examples/transformerconfigs/README.md +++ b/examples/transformerconfigs/README.md @@ -606,3 +606,64 @@ metadata: foo.k8s.io/bar: baz ``` Kustomize supports escaping special characters in path, e.g `metadata/annotations/foo.k8s.io\/bar` + +## Namespace + +The namespace transformer is used to update namespace references in your manifests when you set the `namespace` declaration in your `kustomization.yaml`. + +### Example + +kustomization.yaml + +``` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: example + +resources: +- resources.yaml + +configurations: +- namespace.yaml +``` + +namespace.yaml + + +``` +namespace: +- kind: AnimalPark + path: spec/gorillaRef/namespace + create: true +``` + +resources.yaml + +``` +apiVersion: animal/v1 +kind: AnimalPark +metadata: + name: ap +spec: + gorillaRef: + name: gg + kind: Gorilla + apiVersion: animal/v1 +``` + +Output of `kustomize build`: + +``` +apiVersion: animal/v1 +kind: AnimalPark +metadata: + name: ap + namespace: example +spec: + gorillaRef: + apiVersion: animal/v1 + kind: Gorilla + name: gg + namespace: example +```