From b7e49573f58fe3bad6d1d6227467a6fba8c8ee11 Mon Sep 17 00:00:00 2001 From: Engin Diri Date: Tue, 25 Apr 2023 17:56:54 +0200 Subject: [PATCH] feat: add "helm.sh/resource-policy" annotation (#234) Signed-off-by: Engin Diri --- .github/workflows/lint-and-test.yml | 4 ++-- charts/node-red/Chart.yaml | 4 ++-- charts/node-red/README.md | 7 ++++--- charts/node-red/templates/pvc.yaml | 6 +++++- charts/node-red/tests/flow_refresh_cm_test.yaml | 2 +- charts/node-red/values.yaml | 2 ++ 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 22b150b7..e0158ed9 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -67,8 +67,8 @@ jobs: - name: Run helm unittest run: | - helm plugin install https://github.com/quintush/helm-unittest - helm unittest charts/node-red -3 + helm plugin install https://github.com/helm-unittest/helm-unittest + helm unittest charts/node-red - name: Create kind cluster uses: helm/kind-action@d8ccf8fb623ce1bb360ae2f45f323d9d5c5e9f00 # v1.5.0 diff --git a/charts/node-red/Chart.yaml b/charts/node-red/Chart.yaml index b317a7bd..c4f99333 100644 --- a/charts/node-red/Chart.yaml +++ b/charts/node-red/Chart.yaml @@ -9,7 +9,7 @@ icon: https://nodered.org/about/resources/media/node-red-icon-2.png type: application -version: 0.22.8 +version: 0.23.1 appVersion: 3.0.2 keywords: @@ -29,7 +29,7 @@ maintainers: annotations: artifacthub.io/containsSecurityUpdates: "false" artifacthub.io/changes: | - - update quay.io/kiwigrid/k8s-sidecar to 1.23.1 + - add "helm.sh/resource-policy" annotation to prevent helm from deleting the PVC artifacthub.io/images: | - name: node-red image: docker.io/nodered/node-red:3.0.2 diff --git a/charts/node-red/README.md b/charts/node-red/README.md index 3dfdb1d3..1558ea3b 100644 --- a/charts/node-red/README.md +++ b/charts/node-red/README.md @@ -1,6 +1,6 @@ # node-red ⚙ -![Version: 0.22.8](https://img.shields.io/badge/Version-0.22.8-informational?style=for-the-badge) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=for-the-badge) ![AppVersion: 3.0.2](https://img.shields.io/badge/AppVersion-3.0.2-informational?style=for-the-badge) +![Version: 0.23.1](https://img.shields.io/badge/Version-0.23.1-informational?style=for-the-badge) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=for-the-badge) ![AppVersion: 3.0.2](https://img.shields.io/badge/AppVersion-3.0.2-informational?style=for-the-badge) [![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/node-red&style=for-the-badge)](https://artifacthub.io/packages/search?repo=node-red) [![SIT](https://img.shields.io/badge/SIT-awesome-blueviolet.svg?style=for-the-badge)](https://jobs.schwarz) @@ -16,7 +16,7 @@ A Helm chart for Node-Red, a low-code programming for event-driven applications To install the chart using the OCI artifact, run: ```bash -helm install node-red oci://ghcr.io/schwarzit/charts/node-red --version 0.22.8 +helm install node-red oci://ghcr.io/schwarzit/charts/node-red --version 0.23.1 ``` ## Usage @@ -32,7 +32,7 @@ helm repo update To install the chart with the release name node-red run: ```bash -helm install node-red node-red/node-red --version 0.22.8 +helm install node-red node-red/node-red --version 0.23.1 ``` After a few seconds, node-red should be running. @@ -98,6 +98,7 @@ The command removes all the Kubernetes components associated with the chart and | npmrc.registry | string | `"https://registry.npmjs.org"` | Configuration to use any compatible registry | | persistence.accessMode | string | `"ReadWriteOnce"` | Persistence access mode | | persistence.enabled | bool | `false` | Use persistent volume to store data | +| persistence.keepPVC | bool | `false` | ## Keep a created Persistent volume claim when uninstalling the helm chart (default: false) | | persistence.size | string | `"5Gi"` | Size of persistent volume claim | | podAnnotations | object | `{}` | Pod annotations | | podLabels | object | `{}` | Labels to add to the node-red pod. default: {} | diff --git a/charts/node-red/templates/pvc.yaml b/charts/node-red/templates/pvc.yaml index cc0e6586..9f0274a4 100644 --- a/charts/node-red/templates/pvc.yaml +++ b/charts/node-red/templates/pvc.yaml @@ -8,6 +8,10 @@ metadata: helm.sh/chart: {{ include "node-red.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- if .Values.persistence.keepPVC }} + annotations: + helm.sh/resource-policy: keep + {{- end }} spec: accessModes: - {{ .Values.persistence.accessMode | quote }} @@ -21,4 +25,4 @@ spec: storageClassName: "{{ .Values.persistence.storageClass }}" {{- end }} {{- end }} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/node-red/tests/flow_refresh_cm_test.yaml b/charts/node-red/tests/flow_refresh_cm_test.yaml index 13626c07..19379998 100644 --- a/charts/node-red/tests/flow_refresh_cm_test.yaml +++ b/charts/node-red/tests/flow_refresh_cm_test.yaml @@ -27,4 +27,4 @@ tests: - ./values/sidecar_values.yaml asserts: - isNotEmpty: - path: data.flow_refresh\.sh + path: data diff --git a/charts/node-red/values.yaml b/charts/node-red/values.yaml index 1e018031..5752df86 100644 --- a/charts/node-red/values.yaml +++ b/charts/node-red/values.yaml @@ -136,6 +136,8 @@ persistence: accessMode: ReadWriteOnce # -- Size of persistent volume claim size: 5Gi + # -- ## Keep a created Persistent volume claim when uninstalling the helm chart (default: false) + keepPVC: false # -- containers which are run before the app containers are started initContainers: []