Skip to content

Commit 51bbf57

Browse files
committed
Tweak documentation on directive.
1 parent 3e4ec3a commit 51bbf57

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

docs/kustomization.yaml

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,13 @@ crds:
212212
- crds/typeA.yaml
213213
- crds/typeB.yaml
214214

215-
# Vars are used to insert values from resources that cannot be referenced
216-
# otherwise. For example if you need to pass a Service's name to the arguments
217-
# or environment variables of a program but without hard coding the actual name
218-
# of the Service you'd insert `$(MY_SERVICE_NAME)` into the value field of the
219-
# env var or into the command or args of the container as shown here:
215+
# Vars are used to capture text from one resource's field
216+
# and insert that text elsewhere.
217+
#
218+
# For example, suppose one specify the name of a k8s Service
219+
# object in a container's command line, and the name of a
220+
# k8s Secret object in a container's environment variable,
221+
# so that the following would work:
220222
# ```
221223
# containers:
222224
# - image: myimage
@@ -226,19 +228,8 @@ crds:
226228
# value: $(SOME_SECRET_NAME)
227229
# ```
228230
#
229-
# Then you'll add an entry to `vars:` like shown below with the same name
230-
# and a reference to the resource from which to pull the field's value.
231-
# The actual field's path is optional and by default it will use
232-
# `metadata.name`. Currently only string type fields are supported, no integers
233-
# or booleans, etc. Also array access is currently not possible. For example getting
234-
# the image field of container number 2 inside of a pod can currently not be done.
235-
#
236-
# Not every location of a variable is supported. To see a complete list of locations
237-
# see the file [varreference.go](https://github.com/kubernetes-sigs/kustomize/blob/master/pkg/transformers/config/defaultconfig/varreference.go#L20).
231+
# To do so, add an entry to `vars:` as follows:
238232
#
239-
# An example of a situation where you'd not use vars is when you'd like to set a
240-
# pod's `serviceAccountName`. In that case you would just reference the ServiceAccount
241-
# by name and Kustomize will resolve it to the eventual name while building the manifests.
242233
vars:
243234
- name: SOME_SECRET_NAME
244235
objref:
@@ -259,6 +250,34 @@ vars:
259250
apiVersion: apps/v1
260251
fieldref:
261252
fieldpath: spec.template.spec.restartPolicy
253+
#
254+
# A var is a tuple of variable name, object reference and field
255+
# reference within that object. That's where the text is found.
256+
#
257+
# The field reference is optional; it defaults to `metadata.name`,
258+
# a normal default, since kustomize is used to generates or
259+
# modify the names of resources.
260+
#
261+
# At time of writing, only string type fields are supported.
262+
# No ints, bools, arrays etc. It's not possible to, say,
263+
# extract the name of the image in container number 2 of
264+
# some pod template.
265+
#
266+
# A variable reference, i.e. the string '$(FOO)', can only
267+
# be placed in particular fields of particular objects as
268+
# specified by kustomize's configuration data.
269+
#
270+
# The default config data for vars is at
271+
# https://github.com/kubernetes-sigs/kustomize/blob/master/pkg/transformers/config/defaultconfig/varreference.go
272+
# Long story short, the default targets are all
273+
# container command args and env value fields.
274+
#
275+
# Vars should _not_ be used for inserting names in places
276+
# where kustomize is already handling that job. E.g.,
277+
# a Deployment may reference a ConfigMap by name, and
278+
# if kustomize changes the name of a ConfigMap, it knows
279+
# to change the name reference in the Deployment.
280+
262281

263282
# Images modify the name, tags and/or digest for images without creating patches.
264283
# E.g. Given this kubernetes Deployment fragment:

0 commit comments

Comments
 (0)