From 97c3659fb32471e66260fa8580dbaf6836484a05 Mon Sep 17 00:00:00 2001 From: Dmitriy Zhilyaev Date: Sat, 21 Sep 2024 20:35:31 +0300 Subject: [PATCH 01/13] fix: update yaml --- docs/flags/parallel-limit.md | 5 +++++ docs/yaml.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/flags/parallel-limit.md b/docs/flags/parallel-limit.md index e78c1f99..340833cc 100644 --- a/docs/flags/parallel-limit.md +++ b/docs/flags/parallel-limit.md @@ -4,3 +4,8 @@ Limit the number of parallel helm operations. + + +After [:material-tag: v0.39.1](https://github.com/helmwave/helmwave/releases/tag/v0.39.1) +It affected to values and manifests building process. + \ No newline at end of file diff --git a/docs/yaml.md b/docs/yaml.md index 35be80f2..4c4e19b9 100644 --- a/docs/yaml.md +++ b/docs/yaml.md @@ -913,7 +913,7 @@ You can use custom commands to change rendered manifests. > Introduced in [:material-tag: v0.31.0](https://github.com/helmwave/helmwave/releases/tag/v0.31.0) -> !!! It was renamed form `show_notes=false`, to `hide_notes=true` in [:material-tag: v0.41.1](https://github.com/helmwave/helmwave/releases/tag/v0.41.1) +!!! It was renamed form `show_notes=false`, to `hide_notes=true` in [:material-tag: v0.41.1](https://github.com/helmwave/helmwave/releases/tag/v0.41.1) If enabled, rendered [chart notes](https://helm.sh/docs/chart_template_guide/notes_files/) will be shown after successful release. From 05e9fd28cbe3591ffa27448b1f9854bf6125ba9f Mon Sep 17 00:00:00 2001 From: Dmitriy Zhilyaev Date: Sat, 21 Sep 2024 21:27:00 +0300 Subject: [PATCH 02/13] fix: ver --- .github/workflows/publish-b.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-b.yml b/.github/workflows/publish-b.yml index 6c7293cf..f1239e77 100644 --- a/.github/workflows/publish-b.yml +++ b/.github/workflows/publish-b.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: helmwave/setup-action@v0.3.0 with: - version: '0.36.0' + version: '0.41.1' - run: helmwave schema > schema.json From 25caa8368b9d1e7c3e147f2824dd982cd3b81dd0 Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Tue, 7 Jan 2025 12:49:03 +0200 Subject: [PATCH 03/13] feat: (c) 2025 --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index f075fe5f..b3d4ef2e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,7 +7,7 @@ repo_url: "https://github.com/helmwave/helmwave" edit_uri: "https://github.com/helmwave/docs/edit/main/docs/" site_url: "https://docs.helmwave.app" copyright: > - Copyright © 2020 – 2024 Dmitrii Zhiliaev + Copyright © 2020 – 2025 Dmitrii Zhiliaev nav: - Home: index.md From a7c3b8efeae70f8a6cd08e28b193b0be7bc72fe4 Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Tue, 7 Jan 2025 14:05:40 +0200 Subject: [PATCH 04/13] fix: numbering --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7f1a801e..e3cef5b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,8 +6,8 @@ This document outlines the process to help get your contribution accepted. # Branch-flow 1. Wait for new branch to appear (it is created automatically in [helmwave repository](https://github.com/helmwave/helmwave) with corresponding PR) -1. Feel free to add commits to this branch -1. Merge the PR after everything is updated +2. Feel free to add commits to this branch +3. Merge the PR after everything is updated ## Versioning From 2ee0d8e648ccbada019ab75b458ca0eb3ce7ba2c Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Tue, 7 Jan 2025 16:58:02 +0200 Subject: [PATCH 05/13] feat: remote-source #90 --- docs/examples/remote-source/README.md | 57 +++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 58 insertions(+) create mode 100644 docs/examples/remote-source/README.md diff --git a/docs/examples/remote-source/README.md b/docs/examples/remote-source/README.md new file mode 100644 index 00000000..7821f060 --- /dev/null +++ b/docs/examples/remote-source/README.md @@ -0,0 +1,57 @@ +# Remote Source + +!!! note "Experimental feature" + + This feature can change in future + +`Remote source` allows you use [go-getter](https://github.com/hashicorp/go-getter) syntax to fetch helmwave.yml form Git Mercurial, HTTP ,Amazon S3, Google GCP + + + +```shell +helmwave build --remote-source github.com/helmwave/unit-test-go-getter +``` + +**Logs** + +``` +[🙃 aka INFO]: using cache for remote source + remote source: github.com/helmwave/unit-test-go-getter + cache path: /Users/zhilyaev/Library/Caches/helmwave/remote-source/2d4e600d4fa708cb8642b0fcd7ff4597a7b435e5552adedb4bd61a75888f61b4 +[🙃 aka INFO]: 🔨 Building releases... +[🙃 aka INFO]: 🔨 Building values... +[🙃 aka INFO]: 🔨 no values provided + release: nginx@test +[🙃 aka INFO]: 🔨 Building repositories... +[🙃 aka INFO]: 🗄 repo has been added to the plan + repository: bitnami +[🙃 aka INFO]: ❎ repository already exists with the same configuration, skipping + repository: bitnami +[🙃 aka INFO]: 🔨 Building registries... +[🙃 aka INFO]: 🔨 Building charts... +[🙃 aka INFO]: 🔨 Building manifests... +[🙃 aka INFO]: ❎ skipping updating dependencies for remote chart + release: nginx@test +[🙃 aka INFO]: ❎ found chart in helm cache, using it + release: nginx@test + path: /Users/zhilyaev/Library/Caches/helm/repository/nginx-13.1.7.tgz +[🙃 aka INFO]: ✅ manifest done + release: nginx@test +[🙃 aka INFO]: 🔨 Building graphs... +[🙃 aka INFO]: show graph: +┌─────────────┐ +│ nginx@test │ +└─────────────┘ + +[🙃 aka INFO]: 🏗 Plan + releases: + - nginx@test + repositories: + - bitnami + registries: + - +[🙃 aka INFO]: 🆚 Diff manifests in the kubernetes cluster +[🙈 aka WARNING]: I can't get release from k8s: failed to get release nginx@test: release: not found +[🙃 aka INFO]: 🏗 Planfile is ready! + +``` diff --git a/mkdocs.yml b/mkdocs.yml index b3d4ef2e..99428526 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -61,6 +61,7 @@ nav: - Data sources: - examples/vault/README.md - examples/aws-sm/README.md + - examples/remote-source/README.md plugins: - search From 0ef365f1d36502c10ac4ae042d6c6ab84fd2ebbe Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Tue, 7 Jan 2025 16:59:55 +0200 Subject: [PATCH 06/13] feat: remote-source danger --- docs/examples/remote-source/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/remote-source/README.md b/docs/examples/remote-source/README.md index 7821f060..043ce165 100644 --- a/docs/examples/remote-source/README.md +++ b/docs/examples/remote-source/README.md @@ -1,6 +1,6 @@ # Remote Source -!!! note "Experimental feature" +!!! danger "Experimental feature" This feature can change in future From 5d44178c5ae08f903add9ebdb5501d1891067be6 Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Tue, 7 Jan 2025 17:00:22 +0200 Subject: [PATCH 07/13] feat: remote-source commas --- docs/examples/remote-source/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/remote-source/README.md b/docs/examples/remote-source/README.md index 043ce165..d7585b00 100644 --- a/docs/examples/remote-source/README.md +++ b/docs/examples/remote-source/README.md @@ -4,7 +4,7 @@ This feature can change in future -`Remote source` allows you use [go-getter](https://github.com/hashicorp/go-getter) syntax to fetch helmwave.yml form Git Mercurial, HTTP ,Amazon S3, Google GCP +`Remote source` allows you use [go-getter](https://github.com/hashicorp/go-getter) syntax to fetch helmwave.yml form Git, Mercurial, HTTP, Amazon S3, Google GCP From ef20bfc1561ad4d155ba34eb824789d1857396cd Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Tue, 7 Jan 2025 17:02:16 +0200 Subject: [PATCH 08/13] feat: mv docs --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 99428526..f24b7eee 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -38,7 +38,6 @@ nav: - examples/pass-git-tag/README.md - examples/built-in-release/README.md - examples/store-greeting-hello/README.md - - examples/helm-chart-as-git-repo/README.md - examples/graph/README.md - examples/tags/README.md - examples/umbrella-evil/README.md @@ -52,6 +51,7 @@ nav: - Repositories: - examples/private-github-repo/README.md - examples/private-gitlab-repo/README.md + - examples/helm-chart-as-git-repo/README.md - Values flags: - examples/values-disable-render/README.md - SOPS: examples/values-sops/README.md From b20ccbcfedb287a1fa7f090f395a9f9b7f0b4906 Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Tue, 7 Jan 2025 17:04:34 +0200 Subject: [PATCH 09/13] =?UTF-8?q?fix:=20=F0=9F=A4=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/plan.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plan.md b/docs/plan.md index 6a4cd1a2..6ae4f8d7 100644 --- a/docs/plan.md +++ b/docs/plan.md @@ -1,4 +1,4 @@ -# Deep dive to plan +# 🤿 Deep dive to plan ## Definitions From d732e9e4d5cf952ed7bdef9991603fd1c6060051 Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Tue, 7 Jan 2025 19:09:11 +0200 Subject: [PATCH 10/13] feat: add agrocd --- docs/argocd.md | 8 ++++++++ mkdocs.yml | 1 + 2 files changed, 9 insertions(+) create mode 100644 docs/argocd.md diff --git a/docs/argocd.md b/docs/argocd.md new file mode 100644 index 00000000..13a9a242 --- /dev/null +++ b/docs/argocd.md @@ -0,0 +1,8 @@ +# ArgoCD Plugin + +ArgoCD can use helmwave for rendering kubernetes manifests. +In this case, helmwave will be a template engine, not a deployment tool. +So features like kubedog and monitors will not work. + +You can find more information here: https://github.com/helmwave/argocd-plugin + diff --git a/mkdocs.yml b/mkdocs.yml index f24b7eee..f1efed94 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -18,6 +18,7 @@ nav: - install.md - 🔰 Quick Start: examples/quick-start/README.md - ci.md + - argocd.md - ide.md - pub.md From f499367e1d8016aaa058dbb872c8cfaf044dacac Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Tue, 7 Jan 2025 19:24:14 +0200 Subject: [PATCH 11/13] feat: c agrocd --- docs/argocd.md | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/docs/argocd.md b/docs/argocd.md index 13a9a242..37fbb329 100644 --- a/docs/argocd.md +++ b/docs/argocd.md @@ -2,7 +2,48 @@ ArgoCD can use helmwave for rendering kubernetes manifests. In this case, helmwave will be a template engine, not a deployment tool. -So features like kubedog and monitors will not work. +So features like [kubedog](examples/kubedog) and [monitors](examples/monitors) will not work. -You can find more information here: https://github.com/helmwave/argocd-plugin +You can find more information [:simple-github: here](https://github.com/helmwave/argocd-plugin) + +We will modify original argocd helm values + + +## Enable Config Management Plugins (CMP) + + +```yaml +configs: + cmp: + create: true +``` + +## Define plugins + +```yaml +repoServer: + extraContainers: + - name: helmwave-plugin + command: [ /var/run/argocd/argocd-cmp-server ] + args: [ --loglevel, debug ] + image: ghcr.io/helmwave/helmwave:⟨⟨ ver ⟩⟩ +``` + +Since [:material-tag: v0.40.0](https://github.com/helmwave/helmwave/releases/tag/v0.40.0) you can use special [ :octicons-container-24: gitops image](https://github.com/helmwave/helmwave/pkgs/container/gitops) + +## Command for generation manifests + +```yaml +configs: + cmp: + plugins: + helmwave-plugin: + generate: + command: [ "/bin/ash", "-c" ] + args: + - | + helmwave build &> /tmp/log.txt && find .helmwave/manifest -type f | xargs cat +``` + +[:simple-github: full example](https://github.com/helmwave/argocd-plugin) From 1de88448f897e87a4268c2e550860e21eed492fc Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Wed, 2 Apr 2025 14:08:20 +0300 Subject: [PATCH 12/13] feat: add examples Helm patch with Kustomize --- .../helm-patch-with-kustomize/README.md | 33 +++++ .../hello/.helmignore | 23 ++++ .../hello/Chart.yaml | 24 ++++ .../hello/templates/NOTES.txt | 22 ++++ .../hello/templates/_helpers.tpl | 62 +++++++++ .../hello/templates/deployment.yaml | 78 +++++++++++ .../hello/templates/hpa.yaml | 32 +++++ .../hello/templates/ingress.yaml | 43 ++++++ .../hello/templates/service.yaml | 15 +++ .../hello/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 +++ .../hello/values.yaml | 123 ++++++++++++++++++ .../helm-patch-with-kustomize/helmwave.yml | 6 + .../kustomization.yaml | 15 +++ .../helm-patch-with-kustomize/kustomize.sh | 5 + 15 files changed, 509 insertions(+) create mode 100644 docs/examples/helm-patch-with-kustomize/README.md create mode 100644 docs/examples/helm-patch-with-kustomize/hello/.helmignore create mode 100644 docs/examples/helm-patch-with-kustomize/hello/Chart.yaml create mode 100644 docs/examples/helm-patch-with-kustomize/hello/templates/NOTES.txt create mode 100644 docs/examples/helm-patch-with-kustomize/hello/templates/_helpers.tpl create mode 100644 docs/examples/helm-patch-with-kustomize/hello/templates/deployment.yaml create mode 100644 docs/examples/helm-patch-with-kustomize/hello/templates/hpa.yaml create mode 100644 docs/examples/helm-patch-with-kustomize/hello/templates/ingress.yaml create mode 100644 docs/examples/helm-patch-with-kustomize/hello/templates/service.yaml create mode 100644 docs/examples/helm-patch-with-kustomize/hello/templates/serviceaccount.yaml create mode 100644 docs/examples/helm-patch-with-kustomize/hello/templates/tests/test-connection.yaml create mode 100644 docs/examples/helm-patch-with-kustomize/hello/values.yaml create mode 100644 docs/examples/helm-patch-with-kustomize/helmwave.yml create mode 100644 docs/examples/helm-patch-with-kustomize/kustomization.yaml create mode 100755 docs/examples/helm-patch-with-kustomize/kustomize.sh diff --git a/docs/examples/helm-patch-with-kustomize/README.md b/docs/examples/helm-patch-with-kustomize/README.md new file mode 100644 index 00000000..d42a88dc --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/README.md @@ -0,0 +1,33 @@ +# Helm patch with Kustomize + +Helm charts often miss required fields, leading to frequent forking to add necessary elements. This example shows how to patch a Helm chart without forking, using the external tool kustomize. + +Suppose we have the chart `hello`. (It was created by `$ helm create hello`). The deployment doesn't have `priorityClassName` in this chart. + +For example, we'll add `priorityClassName: high` for the deployment. + +Describe your patch with Kustomize + +```yaml title="kustomization.yaml" +{% include "./kustomization.yaml" %} +``` + +Kustomize has [official](https://helm.sh/docs/topics/advanced/#usage) trick [script](https://github.com/thomastaylor312/advanced-helm-demos/tree/master/post-render) for helm. + +```bash title="kustomize.sh" +{% include "./kustomize.sh" %} +``` + +Ask helmwave use kustomize + +```yaml title="helmwave.yml" +{% include "./helmwave.yml" %} +``` + +## Result + +```bash +helmwave build +cat .helmwave/manifest/world@my-namespace.yml| grep priorityClassName + priorityClassName: high +``` \ No newline at end of file diff --git a/docs/examples/helm-patch-with-kustomize/hello/.helmignore b/docs/examples/helm-patch-with-kustomize/hello/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/docs/examples/helm-patch-with-kustomize/hello/Chart.yaml b/docs/examples/helm-patch-with-kustomize/hello/Chart.yaml new file mode 100644 index 00000000..ca381aeb --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: hello +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/docs/examples/helm-patch-with-kustomize/hello/templates/NOTES.txt b/docs/examples/helm-patch-with-kustomize/hello/templates/NOTES.txt new file mode 100644 index 00000000..1ad51b4b --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "hello.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "hello.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "hello.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "hello.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/docs/examples/helm-patch-with-kustomize/hello/templates/_helpers.tpl b/docs/examples/helm-patch-with-kustomize/hello/templates/_helpers.tpl new file mode 100644 index 00000000..782d0ebd --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "hello.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "hello.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "hello.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "hello.labels" -}} +helm.sh/chart: {{ include "hello.chart" . }} +{{ include "hello.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "hello.selectorLabels" -}} +app.kubernetes.io/name: {{ include "hello.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "hello.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "hello.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/docs/examples/helm-patch-with-kustomize/hello/templates/deployment.yaml b/docs/examples/helm-patch-with-kustomize/hello/templates/deployment.yaml new file mode 100644 index 00000000..ca5cdbef --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/templates/deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "hello.fullname" . }} + labels: + {{- include "hello.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "hello.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "hello.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "hello.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + {{- with .Values.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/docs/examples/helm-patch-with-kustomize/hello/templates/hpa.yaml b/docs/examples/helm-patch-with-kustomize/hello/templates/hpa.yaml new file mode 100644 index 00000000..474fce1d --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "hello.fullname" . }} + labels: + {{- include "hello.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "hello.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/docs/examples/helm-patch-with-kustomize/hello/templates/ingress.yaml b/docs/examples/helm-patch-with-kustomize/hello/templates/ingress.yaml new file mode 100644 index 00000000..cfe53df1 --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/templates/ingress.yaml @@ -0,0 +1,43 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "hello.fullname" . }} + labels: + {{- include "hello.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "hello.fullname" $ }} + port: + number: {{ $.Values.service.port }} + {{- end }} + {{- end }} +{{- end }} diff --git a/docs/examples/helm-patch-with-kustomize/hello/templates/service.yaml b/docs/examples/helm-patch-with-kustomize/hello/templates/service.yaml new file mode 100644 index 00000000..35c619b5 --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hello.fullname" . }} + labels: + {{- include "hello.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "hello.selectorLabels" . | nindent 4 }} diff --git a/docs/examples/helm-patch-with-kustomize/hello/templates/serviceaccount.yaml b/docs/examples/helm-patch-with-kustomize/hello/templates/serviceaccount.yaml new file mode 100644 index 00000000..35d374e4 --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "hello.serviceAccountName" . }} + labels: + {{- include "hello.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/docs/examples/helm-patch-with-kustomize/hello/templates/tests/test-connection.yaml b/docs/examples/helm-patch-with-kustomize/hello/templates/tests/test-connection.yaml new file mode 100644 index 00000000..e3ac76f3 --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "hello.fullname" . }}-test-connection" + labels: + {{- include "hello.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "hello.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/docs/examples/helm-patch-with-kustomize/hello/values.yaml b/docs/examples/helm-patch-with-kustomize/hello/values.yaml new file mode 100644 index 00000000..bd0303c7 --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/hello/values.yaml @@ -0,0 +1,123 @@ +# Default values for hello. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + repository: nginx + # This sets the pull policy for images. + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "" +fullnameOverride: "" + +# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 80 + +# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/docs/examples/helm-patch-with-kustomize/helmwave.yml b/docs/examples/helm-patch-with-kustomize/helmwave.yml new file mode 100644 index 00000000..d9c62be9 --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/helmwave.yml @@ -0,0 +1,6 @@ +releases: + - name: world + chart: ./hello + namespace: my-namespace + post_renderer: + - ./kustomize.sh diff --git a/docs/examples/helm-patch-with-kustomize/kustomization.yaml b/docs/examples/helm-patch-with-kustomize/kustomization.yaml new file mode 100644 index 00000000..2096608e --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/kustomization.yaml @@ -0,0 +1,15 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - all.yaml +patches: + - target: + group: apps + version: v1 + kind: Deployment + name: world-hello + patch: | + - op: replace + path: /spec/template/spec/priorityClassName + value: high + diff --git a/docs/examples/helm-patch-with-kustomize/kustomize.sh b/docs/examples/helm-patch-with-kustomize/kustomize.sh new file mode 100755 index 00000000..4d378fbd --- /dev/null +++ b/docs/examples/helm-patch-with-kustomize/kustomize.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cat <&0 > all.yaml + +kustomize build . && rm all.yaml From 5b332946af02eba79a002aaa8efe576d82fff096 Mon Sep 17 00:00:00 2001 From: Dmitrii Zhiliaev Date: Wed, 2 Apr 2025 14:10:06 +0300 Subject: [PATCH 13/13] feat: add links Helm patch with Kustomize --- docs/yaml.md | 2 ++ mkdocs.yml | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/yaml.md b/docs/yaml.md index a0a4be6b..905052b9 100644 --- a/docs/yaml.md +++ b/docs/yaml.md @@ -909,6 +909,8 @@ Determines if JSON schema validation is disabled You can use custom commands to change rendered manifests. +Check out [:material-duck: the example](../examples/helm-patch-with-kustomize) + ### hide_notes (ex:show_notes) > Introduced in [:material-tag: v0.31.0](https://github.com/helmwave/helmwave/releases/tag/v0.31.0) diff --git a/mkdocs.yml b/mkdocs.yml index f1efed94..a7af5e8f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -42,6 +42,7 @@ nav: - examples/graph/README.md - examples/tags/README.md - examples/umbrella-evil/README.md + - examples/helm-patch-with-kustomize/README.md - examples/private-env/README.md - examples/lifecycle/README.md - examples/monitors/README.md