@@ -310,13 +310,29 @@ kubectl delete -f deploy/crds/example.com_nginxes_crd.yaml
310
310
311
311
# # Advanced features
312
312
313
- # ## Override Helm chart values
314
-
315
- As an operator developer, it is sometimes necessary to enforce that certain values
316
- provided by the chart's default `values.yaml` or by a CR spec are always overridden
317
- when templating the chart. An example of when this is useful is when your operator
318
- is being deployed in a disconnected environment where access to the chart's default
319
- image references is unavailable.
313
+ # # Passing environment variables to the Helm chart
314
+
315
+ Sometimes it is useful to pass down environment variables from the Operators `Deployment`
316
+ all the way to the helm charts templates. This allows the Operator to be configured at a global
317
+ level at runtime. This is new compared to dealing with the helm CLI
318
+ as they usually don't have access to any environment variables in the context of Tiller (helm v2)
319
+ or the helm binary (helm v3) for security reasons.
320
+
321
+ With the helm Operator this becomes possible by override values. This enforces that certain
322
+ template values provided by the chart's default `values.yaml` or by a CR spec are always set
323
+ when rendering the chart. If the value is set by a CR it gets overridden by the global override value.
324
+ The override value can be static but can also refer to an environment variable. To pass down environment
325
+ variables to the chart override values is currently the only way.
326
+
327
+ An example use case of this is when your helm chart references container images by chart variables,
328
+ which is a good practice.
329
+ If your Operator is deployed in a disconnected environment (no network access to the default images
330
+ location) you can use this mechanism to set them globally at the Operator level using environment variables
331
+ versus individually per CR / chart release.
332
+
333
+ > Note that it is strongly recommended to reference container images in your chart by helm variables
334
+ > and then also associate these with an environment variable of your Operator like shown below.
335
+ > This allows your Operator to be mirrored for offline usage when packaged for OLM.
320
336
321
337
To configure your operator with override values, add an `overrideValues` map to your
322
338
` watches.yaml` file for the GVK and chart you need to override. For example, to change
@@ -337,15 +353,15 @@ By setting `image.repository` to `quay.io/mycustomrepo` you are ensuring that
337
353
` quay.io/mycustomrepo` will always be used instead of the chart's default repository
338
354
(`nginx`). If the CR attempts to set this value, it will be ignored.
339
355
340
- It is also possible to reference environment variables in the `overrideValues` section :
356
+ It is now possible to reference environment variables in the `overrideValues` section :
341
357
342
358
` ` ` yaml
343
359
overrideValues:
344
360
image.repository: $IMAGE_REPOSITORY # or ${IMAGE_REPOSITORY}
345
361
` ` `
346
362
347
- By using an environment variable reference in `overrideValues` you make it possible to
348
- set these override values at runtime by setting the environment variable on the
363
+ By using an environment variable reference in `overrideValues` you enable these override
364
+ values to be set at runtime by configuring the environment variable on the
349
365
operator deployment. For example, in `deploy/operator.yaml` you could add the
350
366
following snippet to the container spec :
351
367
0 commit comments