diff --git a/README.md b/README.md index f358eea..1de71f2 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ A collection of helm charts. ## Available charts * [listmonk](./charts/listmonk) +* [node-red](./charts/node-red) ## Sponsor diff --git a/charts/listmonk/README.md b/charts/listmonk/README.md index 62928a0..1efde8d 100644 --- a/charts/listmonk/README.md +++ b/charts/listmonk/README.md @@ -8,12 +8,12 @@ High performance, self-hosted, newsletter and mailing list manager with a modern ```shell $ helm upgrade \ - --create-namespace \ - --install listmonk listmonk \ - --namespace listmonk \ - --repo https://th0th.github.io/helm-charts \ - --values values.yaml \ - --version 0.1.0 + --create-namespace \ + --install listmonk listmonk \ + --namespace listmonk \ + --repo https://th0th.github.io/helm-charts \ + --values values.yaml \ + --version 0.1.0 ``` ## Uninstall diff --git a/charts/node-red/Chart.yaml b/charts/node-red/Chart.yaml new file mode 100644 index 0000000..5e65b53 --- /dev/null +++ b/charts/node-red/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +appVersion: "4.0.2" +name: node-red +description: Low-code programming for event-driven applications. +type: application +version: 0.1.0 diff --git a/charts/node-red/README.md b/charts/node-red/README.md new file mode 100644 index 0000000..66d6878 --- /dev/null +++ b/charts/node-red/README.md @@ -0,0 +1,44 @@ +# node-red + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 4.0.2](https://img.shields.io/badge/AppVersion-4.0.2-informational?style=flat-square) + +Low-code programming for event-driven applications. + +## Install + +> [!WARNING] +> You won't be able to authenticate without setting `nodeRed.settings.adminAuth.users` properly. + +```shell +$ helm upgrade \ + --create-namespace \ + --install node-red node-red \ + --namespace node-red \ + --repo https://th0th.github.io/helm-charts \ + --values values.yaml \ + --version 0.1.0 +``` + +## Uninstall + +```shell +$ helm uninstall --namespace node-red node-red +``` + +## Values + +| Key | Type | Default | Description | +|----------------------------------|--------|---------------------------------------------------|----------------------------------------| +| ingress.annotations | object | `{}` | annotations for the ingress | +| ingress.enabled | bool | `false` | enable the ingress | +| ingress.host | string | `"node-red.local"` | host for the ingress | +| ingress.tls | list | `[]` | tls configuration for the ingress | +| nodeRed.image.repository | string | `"nodered/node-red"` | node-red image repository | +| nodeRed.image.tag | string | `"latest"` | node-red image tag | +| nodeRed.persistence.enabled | bool | `true` | enable persistence | +| nodeRed.resources | object | `{}` | resources for the node-red statefulset | +| nodeRed.settings | object | `{"adminAuth":{"type":"credentials","users":[]}}` | node-red settings | +| nodeRed.settings.adminAuth | object | `{"type":"credentials","users":[]}` | admin authentication config | +| nodeRed.settings.adminAuth.users | list | `[]` | list of users | +| nodeRed.timeZone | string | `"America/New_York"` | time zone | | time zone | + diff --git a/charts/node-red/templates/_helpers.tpl b/charts/node-red/templates/_helpers.tpl new file mode 100644 index 0000000..d8f8e95 --- /dev/null +++ b/charts/node-red/templates/_helpers.tpl @@ -0,0 +1,42 @@ +{{- define "nodeRed.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "nodeRed.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 }} + +{{- define "nodeRed.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "nodeRed.labels" -}} +helm.sh/chart: {{ include "nodeRed.chart" . }} +{{ include "nodeRed.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "nodeRed.selectorLabels" -}} +app.kubernetes.io/name: {{ include "nodeRed.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{- define "nodeRed.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "nodeRed.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/node-red/templates/configmap-node-red.yaml b/charts/node-red/templates/configmap-node-red.yaml new file mode 100644 index 0000000..8ba20c1 --- /dev/null +++ b/charts/node-red/templates/configmap-node-red.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "nodeRed.fullname" . }}-node-red + labels: + {{- include "nodeRed.labels" . | nindent 4 }} +data: + settings.js: | + module.exports = { + adminAuth: { + type: "{{ required "A valid .Values.nodeRed.settings.adminAuth.type is required!" .Values.nodeRed.settings.adminAuth.type }}", + users: [ + {{- range (.Values.nodeRed.settings.adminAuth.users | default list) }} + { + password: "{{ .password }}", + permissions: "{{ .permissions }}", + username: "{{ .username }}", + }, + {{- end }} + ], + }, + }; diff --git a/charts/node-red/templates/ingress-node-red.yaml b/charts/node-red/templates/ingress-node-red.yaml new file mode 100644 index 0000000..55de24a --- /dev/null +++ b/charts/node-red/templates/ingress-node-red.yaml @@ -0,0 +1,24 @@ +{{ if .Values.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "nodeRed.fullname" . }}-node-red + labels: + {{- include "nodeRed.labels" . | nindent 4 }} + annotations: + {{- toYaml .Values.ingress.annotations | nindent 4 }} +spec: + rules: + - host: {{ .Values.ingress.host}} + http: + paths: + - backend: + service: + name: '{{ include "nodeRed.fullname" . }}-node-red' + port: + name: http + path: / + pathType: Prefix + tls: + {{- toYaml .Values.ingress.tls | nindent 4 }} +{{ end }} diff --git a/charts/node-red/templates/service-node-red.yaml b/charts/node-red/templates/service-node-red.yaml new file mode 100644 index 0000000..0f40ce6 --- /dev/null +++ b/charts/node-red/templates/service-node-red.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "nodeRed.fullname" . }}-node-red + labels: + {{- include "nodeRed.labels" . | nindent 4 }} +spec: + type: ClusterIP + selector: + statefulSet: node-red + {{- include "nodeRed.selectorLabels" . | nindent 4 }} + ports: + - name: http + port: 1880 + protocol: TCP + targetPort: 1880 diff --git a/charts/node-red/templates/statefulset-node-red.yaml b/charts/node-red/templates/statefulset-node-red.yaml new file mode 100644 index 0000000..0df90db --- /dev/null +++ b/charts/node-red/templates/statefulset-node-red.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "nodeRed.fullname" . }}-node-red + labels: + {{- include "nodeRed.labels" . | nindent 4 }} +spec: + persistentVolumeClaimRetentionPolicy: + whenDeleted: Retain + whenScaled: Retain + replicas: 1 + selector: + matchLabels: + statefulSet: node-red + {{- include "nodeRed.selectorLabels" . | nindent 6 }} + serviceName: node-red-hl + template: + metadata: + labels: + statefulSet: node-red + {{- include "nodeRed.selectorLabels" . | nindent 8 }} + name: node-red + spec: + containers: + - env: + - name: TZ + value: {{ .Values.nodeRed.timeZone }} + image: {{ .Values.nodeRed.image.repository }}:{{ .Values.nodeRed.image.tag }} + name: node-red + resources: {{- toYaml .Values.nodeRed.resources | nindent 12 }} + volumeMounts: + - mountPath: /data + name: data + subPath: node-red-data + - mountPath: /data/settings.js + name: configmap-node-red + subPath: settings.js + volumes: + - configMap: + name: {{ include "nodeRed.fullname" . }}-node-red + name: configmap-node-red + volumeClaimTemplates: + - kind: PersistentVolumeClaim + apiVersion: v1 + metadata: + name: data + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + volumeMode: Filesystem diff --git a/charts/node-red/values.yaml b/charts/node-red/values.yaml new file mode 100644 index 0000000..4b03104 --- /dev/null +++ b/charts/node-red/values.yaml @@ -0,0 +1,32 @@ +ingress: + # -- annotations for the ingress + annotations: { } + # -- enable the ingress + enabled: false + # -- host for the ingress + host: node-red.local + # -- tls configuration for the ingress + tls: [ ] +nodeRed: + image: + # -- node-red image repository + repository: nodered/node-red + # -- node-red image tag + tag: latest + persistence: + # -- enable persistence + enabled: true + # -- resources for the node-red statefulset + resources: { } + # -- node-red settings + settings: + # -- admin authentication config + adminAuth: + type: credentials + # -- list of users + users: [ ] + # - password: "$2y$08$q7DQYqhJrLC0.NnLelnre.IUaE2wQX3/xBiQ1cyAuNva8i5A6760q" + # permissions: "*" + # username: admin + # -- time zone + timeZone: America/New_York