Skip to content

Commit 8f827d1

Browse files
dmesserjoelanford
andcommitted
more context on the doc on override values (#2381)
* more context on the doc on override values Signed-off-by: dmesser <[email protected]> * Update doc/helm/user-guide.md Co-Authored-By: Joe Lanford <[email protected]> * Update doc/helm/user-guide.md Co-Authored-By: Joe Lanford <[email protected]> * give context on helm releases Signed-off-by: dmesser <[email protected]> Co-authored-by: Joe Lanford <[email protected]>
1 parent 5fc8835 commit 8f827d1

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

doc/helm/user-guide.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,29 @@ kubectl delete -f deploy/crds/example.com_nginxes_crd.yaml
310310

311311
## Advanced features
312312

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.
320336

321337
To configure your operator with override values, add an `overrideValues` map to your
322338
`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
337353
`quay.io/mycustomrepo` will always be used instead of the chart's default repository
338354
(`nginx`). If the CR attempts to set this value, it will be ignored.
339355

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:
341357

342358
```yaml
343359
overrideValues:
344360
image.repository: $IMAGE_REPOSITORY # or ${IMAGE_REPOSITORY}
345361
```
346362

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
349365
operator deployment. For example, in `deploy/operator.yaml` you could add the
350366
following snippet to the container spec:
351367

0 commit comments

Comments
 (0)