@@ -136,3 +136,51 @@ patches:
136
136
crds :
137
137
- crds/typeA.yaml
138
138
- crds/typeB.yaml
139
+
140
+ # Vars are used to insert values from resources that cannot be referenced
141
+ # otherwise. For example if you need to pass a Service's name to the arguments
142
+ # or environment variables of a program but without hard coding the actual name
143
+ # of the Service you'd insert `$(MY_SERVICE_NAME)` into the value field of the
144
+ # env var or into the command or args of the container as shown here:
145
+ # ```
146
+ # containers:
147
+ # - image: myimage
148
+ # command: ["start", "--host", "$(MY_SERVICE_NAME)"]
149
+ # env:
150
+ # - name: SECRET_TOKEN
151
+ # value: $(SOME_SECRET_NAME)
152
+ # ```
153
+ #
154
+ # Then you'll add an entry to `vars:` like shown below with the same name
155
+ # and a reference to the resource from which to pull the field's value.
156
+ # The actual field's path is optional and by default it will use
157
+ # `metadata.name`. Currently only string type fields are supported, no integers
158
+ # or booleans, etc. Also array access is currently not possible. For example getting
159
+ # the image field of container number 2 inside of a pod can currently not be done.
160
+ #
161
+ # Not every location of a variable is supported. To see a complete list of locations
162
+ # see the file [refvars.go](https://github.com/kubernetes-sigs/kustomize/blob/master/pkg/transformers/refvars.go#L20).
163
+ #
164
+ # An example of a situation where you'd not use vars is when you'd like to set a
165
+ # pod's `serviceAccountName`. In that case you would just reference the ServiceAccount
166
+ # by name and Kustomize will resolve it to the eventual name while building the manifests.
167
+ vars :
168
+ - name : SOME_SECRET_NAME
169
+ objref :
170
+ kind : Secret
171
+ name : my-secret
172
+ apiVersion : v1
173
+ - name : MY_SERVICE_NAME
174
+ objref :
175
+ kind : Service
176
+ name : my-service
177
+ apiVersion : v1
178
+ fieldref :
179
+ fieldpath : metadata.name
180
+ - name : ANOTHER_DEPLOYMENTS_POD_RESTART_POLICY
181
+ objref :
182
+ kind : Deployment
183
+ name : my-deployment
184
+ apiVersion : apps/v1
185
+ fieldref :
186
+ fieldpath : spec.template.spec.restartPolicy
0 commit comments