Bundle Overrides
Bundle overrides provide a mechanism to customize Helm charts inside of Zarf packages.
Quickstart
Section titled “Quickstart”Consider the following zarf.yaml and values.yaml which deploys podinfo
with a couple of custom values:
kind: ZarfPackageConfigmetadata: name: helm-overrides-package version: 0.0.1
components: - name: helm-overrides-component required: true charts: - name: podinfo version: 6.4.0 namespace: podinfo url: https://github.com/stefanprodan/podinfo.git gitPath: charts/podinfo valuesFiles: - values.yaml images: - ghcr.io/stefanprodan/podinfo:6.4.0---# values.yamlreplicaCount: 1ui: color: blueThe bundle overrides feature allows users to override the values specified in Zarf packages. For example:
kind: UDSBundlemetadata: name: helm-overrides description: testing a bundle with Helm overrides version: 0.0.1
packages: - name: helm-overrides-package path: "path/to/pkg" ref: 0.0.1
overrides: helm-overrides-component: podinfo: valuesFiles: - values.yaml values: - path: "replicaCount" value: 2 variables: - name: UI_COLOR path: "ui.color" description: "Set the color for podinfo's UI" default: "purple"podAnnotations: customAnnotation: "customValue"This bundle will deploy the helm-overrides-package Zarf package and override the replicaCount, ui.color, and podAnnotations values in the podinfo chart. The values can’t be modified after the bundle has been created. However, at deploy time, users can override the UI_COLOR and other variables using a environment variable called UDS_UI_COLOR or by specifying it in a uds-config.yaml like so:
variables: helm-overrides-package: UI_COLOR: greenOverrides
Section titled “Overrides”Syntax
Section titled “Syntax”Consider the following bundle overrides:
packages: - name: helm-overrides-package path: "path/to/pkg" ref: 0.0.1
overrides: helm-overrides-component: # component name inside of the helm-overrides-package Zarf pkg podinfo: # chart name from the helm-overrides-component component valuesFiles: - values.yaml values: - path: "replicaCount" value: 2 variables: - name: UI_COLOR path: "ui.color" description: "Set the color for podinfo's UI" default: "purple"podAnnotations: customAnnotation: "customValue"In this example, the helm-overrides-package Zarf package has a component called helm-overrides-component which contains a Helm chart called podinfo; note how these names are keys in the overrides block. The podinfo chart has a replicaCount value that is overridden to 2, a podAnnotations value that is overridden to include customAnnotation: "customValue" and a variable called UI_COLOR that is overridden to purple.
Values Files
Section titled “Values Files”The valuesFiles in an overrides block are a list of file’s. It allows users to override multiple values in a Zarf package component’s underlying Helm chart, by providing a file with those values instead of having to include them all individually in the overrides block.
Values
Section titled “Values”The values in an overrides block are a list of path and value pairs. They allow users to override values in a Zarf package component’s underlying Helm chart. Note that values are specified by bundle authors and cannot be modified after the bundle has been created.
The path uses dot notation to specify the location of a value to override in the underlying Helm chart. For example, the replicaCount path in the podinfo chart is located at the top-level of the podinfo values.yaml, so the path is simply replicaCount, while the ui.color path is located under the ui key, so the path is ui.color.
The value is the value to set at the path. Values can be simple values such as numbers and strings, as well as, complex lists and objects, for example:
---overrides: helm-overrides-component: podinfo: values: - path: "podinfo.tolerations" value: - key: "unicorn" operator: "Equal" value: "defense" effect: "NoSchedule" - path: podinfo.podAnnotations value: customAnnotation: "customValue"Bundle Variables as Values
Section titled “Bundle Variables as Values”Bundle and Zarf variables can be used to set override values by using the syntax ${...}. For example:
variables: helm-overrides-package: replica_count: 2kind: UDSBundlemetadata: name: example-bundle description: Example for using an imported variable to set an overrides value version: 0.0.1
packages: - name: output-var repository: localhost:888/output-var ref: 0.0.1 exports: - name: COLOR
- name: helm-overrides-package path: "../../packages/helm" ref: 0.0.1
overrides: podinfo-component: unicorn-podinfo: values: - path: "podinfo.replicaCount" value: ${REPLICA_COUNT} - path: "podinfo.ui.color" value: ${COLOR}In the example above ${REPLICA_COUNT} is set in the uds-config.yaml file and ${COLOR} is set as an export from the output-var package. Note that you could also set these values with the shared key in a uds-config.yaml, environment variables prefixed with UDS_ or with the --set flag during deployment.
Value Precedence
Section titled “Value Precedence”Value precedence is as follows:
- The
valuesin anoverridesblock valuesset in the lastvaluesFile(if more than one specified)valuesset in the previousvaluesFile(if more than one specified)
Variables
Section titled “Variables”Variables are similar to values in that they allow users to override values in a Zarf package component’s underlying Helm chart; they also share a similar syntax. However, unlike values, variables can be overridden at deploy time. For example, consider the variables key in the following uds-bundle.yaml:
kind: UDSBundlemetadata: name: example-bundle version: 0.0.1
packages: - name: helm-overrides-package path: "../../packages/helm" ref: 0.0.1" overrides: podinfo-component: unicorn-podinfo: variables: - name: UI_COLOR path: "ui.color" description: "Set the color for podinfo's UI" default: "purple"There are 3 ways to override the UI_COLOR variable:
-
UDS config: you can create a
uds-config.yamlfile in the same directory as the bundle and specify the variable to override. For example, to override theUI_COLORvariable, you can create auds-config.yaml:variables:helm-overrides-package:ui_color: green # Note that the variable for `UI_COLOR` can be upper or lowercase -
Environment variables: you can create an environment variable prefixed with
UDS_and the name of the variable. For example, to override theUI_COLORvariable, you can create an environment variable calledUDS_UI_COLORand set it to the desired value. Note that environment variables take precedence overuds-config.yamlvariables. -
—set Flag: you can also override the variable using the CLI’s
--setflag. For example, to override theUI_COLORvariable, you can run one of the following commands:Terminal window # by default ui_color will apply to all packages in the bundleuds deploy example-bundle --set ui_color=green# to specify a specific package that the variable should apply to you can prepend th package name to the variableuds deploy example-bundle --set helm-overrides-package.ui_color=green:warning: Warning: Because Helm override variables and Zarf variables share the same —set syntax, be careful with variable names to avoid conflicts.
Variable Precedence
Section titled “Variable Precedence”Variable precedence is as follows:
- The
--setflag - Environment variables
uds-config.yamlvariables- Variables
defaultin theuds-bundle.yaml
Variable Types
Section titled “Variable Types”Variables can be of either type raw or file. The type will default to raw if not set explicitly.
kind: UDSBundlemetadata: name: example-bundle version: 0.0.1
packages: - name: helm-overrides-package path: "../../packages/helm" ref: 0.0.1 overrides: podinfo-component: unicorn-podinfo: variables: - name: UI_COLOR path: "ui.color" description: "variable UI_COLOR accepts a raw value (e.g. a string, int, map) like "purple", which is passed to the ui.color helm path" type: raw - name: test_secret path: "testSecret" description: "variable TEST_SECRET will resolve to the contents of a file (e.g. test.cert), which gets passed to the testSecret helm path" type: fileFile Paths
If a file path is not absolute, it will be set as relative to the uds-config.yaml directory.
e.g. the following uds-config.yaml is in src/test/bundles/07-helm-overrides/variable-files/
variables: helm-overrides: test_secret: test.certThis means when test.cert is evaluated it will first be appended to the config path like so src/test/bundles/07-helm-overrides/variable-files/test.cert.
If the file path is already set to the same relative path as the config, then no merging will take place.
Sensitive
Section titled “Sensitive”Variables can be specified as sensitive, which means their values, regardless of how they’re set, will be masked in output.
kind: UDSBundlemetadata: name: example-bundle version: 0.0.1
packages: - name: helm-overrides-package path: "../../packages/helm" ref: 0.0.1 overrides: podinfo-component: unicorn-podinfo: variables: - name: SECRET_VAL path: "testSecret" description: "should be masked in output" sensitive: trueNamespace
Section titled “Namespace”It’s also possible to specify a namespace for a packaged Helm chart to be installed in. For example, to deploy the a chart in the custom-podinfo namespace, you can specify the namespace in the overrides block:
kind: UDSBundlemetadata: name: example-bundle version: 0.0.1
packages: - name: helm-overrides-package path: "../../packages/helm" ref: 0.0.1 overrides: podinfo-component: unicorn-podinfo: namespace: custom-podinfo # custom namespace! values: - path: "podinfo.replicaCount" value: 1View All Variables
Section titled “View All Variables”When working with a local or remote bundle you can view all overrides and zarf variables by running uds inspect --list-variables BUNDLE_TARBALL|OCI_REF]