From 3f3f0cf929d8597e8ab6caae4765a88c83499610 Mon Sep 17 00:00:00 2001 From: Blake Burkhart Date: Mon, 20 Apr 2026 12:42:21 -0500 Subject: [PATCH 1/2] Add example of patching a helm chart This is a simple method to apply modifications to a helm chart that is not under your control, if value overrides are not sufficient. *.patch files are stored beside the zarf.yaml and applied in an onCreate action that clones the chart's git repository, applies the patches and then loads the patched chart from the local filesystem with localPath in the component definition. Signed-off-by: Blake Burkhart --- examples/helm-charts/.gitignore | 1 + examples/helm-charts/0001-example-patch.patch | 25 +++++++++++++++++ examples/helm-charts/readme.md | 6 +++- examples/helm-charts/zarf.yaml | 28 +++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 examples/helm-charts/.gitignore create mode 100644 examples/helm-charts/0001-example-patch.patch diff --git a/examples/helm-charts/.gitignore b/examples/helm-charts/.gitignore new file mode 100644 index 0000000000..256f93352c --- /dev/null +++ b/examples/helm-charts/.gitignore @@ -0,0 +1 @@ +podinfo/ diff --git a/examples/helm-charts/0001-example-patch.patch b/examples/helm-charts/0001-example-patch.patch new file mode 100644 index 0000000000..076351d371 --- /dev/null +++ b/examples/helm-charts/0001-example-patch.patch @@ -0,0 +1,25 @@ +From 6a7f74a9717d63033810d0ca3fa96fb8c41f5323 Mon Sep 17 00:00:00 2001 +From: Blake Burkhart +Date: Mon, 20 Apr 2026 12:13:53 -0500 +Subject: [PATCH] example patch + +--- + charts/podinfo/templates/deployment.yaml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/charts/podinfo/templates/deployment.yaml b/charts/podinfo/templates/deployment.yaml +index 87ed373..4385fb8 100644 +--- a/charts/podinfo/templates/deployment.yaml ++++ b/charts/podinfo/templates/deployment.yaml +@@ -31,7 +31,7 @@ spec: + serviceAccountName: {{ template "podinfo.serviceAccountName" . }} + {{- end }} + containers: +- - name: {{ .Chart.Name }} ++ - name: {{ .Chart.Name }}-patched + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.securityContext }} +-- +2.50.1 (Apple Git-155) + diff --git a/examples/helm-charts/readme.md b/examples/helm-charts/readme.md index aba6af6be7..c6dc8d0eab 100644 --- a/examples/helm-charts/readme.md +++ b/examples/helm-charts/readme.md @@ -1 +1,5 @@ -This example shows the many ways you can deploy Helm Charts with Zarf. To learn more about how `charts` work in Zarf, see the [Helm Charts section](/ref/components/#helm-charts) of the package components documentation. \ No newline at end of file +This example shows the many ways you can deploy Helm Charts with Zarf. To learn more about how `charts` work in Zarf, see the [Helm Charts section](/ref/components/#helm-charts) of the package components documentation. + +The `demo-patched-helm-chart` component shows how patches can be applied to a Helm chart. If possible, you should utilize Helm value overrides or consider upstreaming required modifications to Helm charts. But if these options are insufficient, you may need to make custom modifications to a Helm chart. Typically, you might fork the upstream Helm chart's git repository and periodically rebase or merge in new upstream changes. + +`demo-patched-helm-chart` demonstrates an alternative method using a [Zarf `onCreate` action](/ref/actions/), which performs a `git clone` of the upstream git repository and applies patch files with `git am`. This is conceptually equivalent to rebasing a set of changes onto the upstream repository, and is a useful technique to apply some minor changes to an upstream repository. If more complexity is required, or if you need to make changes to the patches frequently, maintaining a fork of the upstream repository may be more appropriate. To create patches, clone the upstream repository, commit your changes locally and use [`git format-patch`](https://git-scm.com/docs/git-format-patch) to generate patches. diff --git a/examples/helm-charts/zarf.yaml b/examples/helm-charts/zarf.yaml index ed0617852a..d7950b0bd6 100644 --- a/examples/helm-charts/zarf.yaml +++ b/examples/helm-charts/zarf.yaml @@ -55,10 +55,38 @@ components: releaseName: cool-release-name valuesFiles: - values.yaml + images: - ghcr.io/stefanprodan/podinfo:6.4.0 # This is the cosign signature for the podinfo image for image signature verification - ghcr.io/stefanprodan/podinfo:sha256-57a654ace69ec02ba8973093b6a786faa15640575fbf0dbb603db55aca2ccec8.sig + - name: demo-patched-helm-chart + required: true + images: + - ghcr.io/stefanprodan/podinfo:6.4.0 + - ghcr.io/stefanprodan/podinfo:sha256-57a654ace69ec02ba8973093b6a786faa15640575fbf0dbb603db55aca2ccec8.sig + charts: + - name: podinfo-patched + version: 6.4.0 + namespace: podinfo-from-git-patched + # In this case `localPath` will load the local podinfo chart which is created by the `onCreate` action + localPath: podinfo/charts/podinfo + valuesFiles: + - values.yaml + # git clone podinfo/ for podinfo-patched chart and apply patches (typically created with `git format-patch`) + # This is a simple method to apply modifications to a Helm chart that is not under your control, if value overrides are not sufficient + actions: + onCreate: + before: + - cmd: | + # Clone and apply patches to git repo + rm -rf podinfo + git clone -b 6.4.0 --depth 1 -c advice.detachedHead=false https://github.com/stefanprodan/podinfo.git + cd podinfo + export GIT_COMMITTER_NAME="zarf" + export GIT_COMMITTER_EMAIL="zarf@invalid" + git am --3way ../*.patch # will error if the patch does not apply cleanly + documentation: readme: readme.md From a0a50a3eac23f9303f4a766927603fba74bf3d76 Mon Sep 17 00:00:00 2001 From: Blake Burkhart Date: Mon, 20 Apr 2026 14:20:07 -0500 Subject: [PATCH 2/2] Apply suggestion from @bburky Signed-off-by: Blake Burkhart --- examples/helm-charts/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/helm-charts/readme.md b/examples/helm-charts/readme.md index c6dc8d0eab..76b293b379 100644 --- a/examples/helm-charts/readme.md +++ b/examples/helm-charts/readme.md @@ -1,5 +1,5 @@ This example shows the many ways you can deploy Helm Charts with Zarf. To learn more about how `charts` work in Zarf, see the [Helm Charts section](/ref/components/#helm-charts) of the package components documentation. -The `demo-patched-helm-chart` component shows how patches can be applied to a Helm chart. If possible, you should utilize Helm value overrides or consider upstreaming required modifications to Helm charts. But if these options are insufficient, you may need to make custom modifications to a Helm chart. Typically, you might fork the upstream Helm chart's git repository and periodically rebase or merge in new upstream changes. +To customize Helm charts you should utilize Helm value overrides or consider upstreaming any required modifications to Helm charts. But if these options are insufficient, you may need to make custom modifications to a Helm chart. Typically, you might fork the upstream Helm chart's git repository and periodically rebase or merge in new upstream changes. -`demo-patched-helm-chart` demonstrates an alternative method using a [Zarf `onCreate` action](/ref/actions/), which performs a `git clone` of the upstream git repository and applies patch files with `git am`. This is conceptually equivalent to rebasing a set of changes onto the upstream repository, and is a useful technique to apply some minor changes to an upstream repository. If more complexity is required, or if you need to make changes to the patches frequently, maintaining a fork of the upstream repository may be more appropriate. To create patches, clone the upstream repository, commit your changes locally and use [`git format-patch`](https://git-scm.com/docs/git-format-patch) to generate patches. +The `demo-patched-helm-chart` component an alternative method using a [Zarf `onCreate` action](/ref/actions/), which performs a `git clone` of the upstream git repository and applies patch files with `git am`. This is conceptually equivalent to rebasing a set of changes onto the upstream repository, and is a useful technique to apply some minor changes to an upstream repository. If more complexity is required, or if you need to make changes to the patches frequently, maintaining a fork of the upstream repository may be more appropriate. To create patches, clone the upstream repository, commit your changes locally and use [`git format-patch`](https://git-scm.com/docs/git-format-patch) to generate patches.