[node-red] migrate to common library (#180)

This commit is contained in:
ᗪєνιη ᗷυнʟ 2020-11-18 13:54:50 -05:00 committed by GitHub
parent e2eca4851b
commit 0c6be064e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 76 additions and 478 deletions

View File

@ -19,5 +19,6 @@
.project .project
.idea/ .idea/
*.tmproj *.tmproj
.vscode/
# OWNERS file for Kubernetes # OWNERS file for Kubernetes
OWNERS OWNERS

View File

@ -1,8 +1,8 @@
apiVersion: v2 apiVersion: v2
appVersion: 1.0.6-12 appVersion: 1.2.5
description: Node-RED is low-code programming for event-driven applications description: Node-RED is low-code programming for event-driven applications
name: node-red name: node-red
version: 3.3.0 version: 4.0.0
keywords: keywords:
- nodered - nodered
- node-red - node-red
@ -14,5 +14,7 @@ sources:
maintainers: maintainers:
- name: billimek - name: billimek
email: jeff@billimek.com email: jeff@billimek.com
- name: batazor dependencies:
email: batazor111@gmail.com - name: common
repository: https://k8s-at-home.com/charts/
version: ^1.5.1

View File

@ -1,6 +1,4 @@
approvers: approvers:
- billimek - billimek
- batazor
reviewers: reviewers:
- billimek - billimek
- batazor

View File

@ -1,107 +1,79 @@
# Node-RED # Node-Red
Low-code programming for event-driven applications This is a helm chart for [Node-Red](https://nodered.org/).
**This chart is not maintained by the Node-RED project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new)** **This chart is not maintained by the Node-RED project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new)**
## TL;DR; ## TL;DR;
```shell ```shell
helm repo add k8s-at-home https://k8s-at-home.com/charts/ $ helm repo add k8s-at-home https://k8s-at-home.com/charts/
helm install k8s-at-home/node-red $ helm install k8s-at-home/node-red
``` ```
## Introduction
This code is adopted from the [official node-red docker image](https://hub.docker.com/r/nodered/node-red/) which runs the [Node-RED application](https://nodered.org/)
## Installing the Chart ## Installing the Chart
To install the chart with the release name `my-release`: To install the chart with the release name `my-release`:
```shell ```console
helm install --name my-release k8s-at-home/node-red helm install --name my-release k8s-at-home/node-red
``` ```
## Uninstalling the Chart ## Uninstalling the Chart
To uninstall/delete the `my-release` deployment: To uninstall/delete the `my-release` deployment:
```shell ```console
helm delete my-release --purge helm delete my-release --purge
``` ```
The command removes all the Kubernetes components associated with the chart and deletes the release. The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration ## Configuration
Read through the charts [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/node-red/values.yaml)
The following tables lists the configurable parameters of the Node-RED chart and their default values. file. It has several commented out suggested values.
Additionally you can take a look at the common library [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/common/values.yaml) for more (advanced) configuration options.
| Parameter | Description | Default |
|:------------------------------------- |:----------------------------------------------------------------------- |:------------------------- |
| `image.repository` | node-red image | `nodered/node-red` |
| `image.tag` | node-red image tag | `1.0.6-12-minimal` |
| `image.pullPolicy` | node-red image pull policy | `IfNotPresent` |
| `strategyType` | Specifies the strategy used to replace old Pods by new ones | `Recreate` |
| `serviceAccountName` | Service account to run the pod as | `` |
| `probes.liveness.enabled` | Enable/ disable livenessProbe | `true` |
| `probes.liveness.probePath` | Set livenessProbe path | `/` |
| `probes.liveness.initialDelaySeconds` | Set livenessProbe initial delay | 60 |
| `probes.liveness.failureThreshold` | Set livenessProbe failure threshold | 5 |
| `probes.liveness.timeoutSeconds` | Set livenessProbe timeout | 10 |
| `probes.readiness.enabled` | Enable/ disable readinessProbe | `true` |
| `probes.readiness.probePath` | Set readinessProbe path | `/` |
| `probes.readiness.initialDelaySeconds`| Set readinessProbe initial delay | 60 |
| `probes.readiness.failureThreshold` | Set readinessProbe failure threshold | 5 |
| `probes.readiness.timeoutSeconds` | Set readinessProbe timeout | 10 |
| `probes.startup.enabled` | Enable/ disable readinessProbe | `false` |
| `probes.startup.probePath` | Set startupProbe path | `/` |
| `probes.startup.failureThreshold` | Set startupProbe failure threshold | 30 |
| `probes.startup.periodSeconds` | Set startupProbe period | 10 |
| `flows` | Default flows configuration | `flows.json` |
| `safeMode` | Setting to true starts Node-RED in safe (not running) mode | `false` |
| `enableProjects` | setting to true starts Node-RED with the projects feature enabled | `false` |
| `nodeOptions` | Node.js runtime arguments | `` |
| `extraEnvs` | Extra environment variables which will be appended to the env | `[]` |
| `timezone` | Default timezone | `UTC` |
| `service.type` | Kubernetes service type for the GUI | `ClusterIP` |
| `service.port` | Kubernetes port where the GUI is exposed | `1880` |
| `service.nodePort` | Kubernetes nodePort where the GUI is exposed | `` |
| `service.annotations` | Service annotations for the GUI | `{}` |
| `service.labels` | Custom labels | `{}` |
| `service.loadBalancerIP` | Loadbalance IP for the GUI | `{}` |
| `service.loadBalancerSourceRanges` | List of IP CIDRs allowed access to load balancer (if supported) | None |
| `service.externalTrafficPolicy` | Set the externalTrafficPolicy in the Service to either Cluster or Local | `Cluster` |
| `ingress.enabled` | Enables Ingress | `false` |
| `ingress.annotations` | Ingress annotations | `{}` |
| `ingress.path` | Ingress path | `/` |
| `ingress.hosts` | Ingress accepted hostnames | `chart-example.local` |
| `ingress.tls` | Ingress TLS configuration | `[]` |
| `persistence.enabled` | Use persistent volume to store data | `false` |
| `persistence.size` | Size of persistent volume claim | `5Gi` |
| `persistence.existingClaim` | Use an existing PVC to persist data | `nil` |
| `persistence.storageClass` | Type of persistent volume claim | `-` |
| `persistence.accessModes` | Persistence access modes | `ReadWriteOnce` |
| `persistence.subPath` | Mount a sub dir of the persistent volume | `nil` |
| `resources` | CPU/Memory resource requests/limits | `{}` |
| `nodeSelector` | Node labels for pod assignment | `{}` |
| `tolerations` | Toleration labels for pod assignment | `[]` |
| `affinity` | Affinity settings for pod assignment | `{}` |
| `podAnnotations` | Key-value pairs to add as pod annotations | `{}` |
| `deploymentAnnotations` | Key-value pairs to add as deployment annotations | `{}` |
| `hostAliases` | Specify /etc/hosts entries | `[]` |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
```shell helm install node-red \
helm install --name my-release \ --set env.TZ="America/New_York" \
--set config.timezone="America/New_York" \
k8s-at-home/node-red k8s-at-home/node-red
``` ```
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, chart. For example,
```console
```shell helm install node-red k8s-at-home/node-red --values values.yaml
helm install --name my-release -f values.yaml k8s-at-home/node-red
``` ```
Read through the [values.yaml](values.yaml) file. It has several commented out suggested values. These values will be nested as it is a dependency, for example
```yaml
image:
tag: ...
```
---
**NOTE**
If you get
```console
Error: rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: ...`
```
it may be because you uninstalled the chart with `skipuninstall` enabled, you need to manually delete the pvc or use `existingClaim`.
---
## Upgrading an existing Release to a new major version
A major chart version change (like 4.0.1 -> 5.0.0) indicates that there is an incompatible breaking change potentially needing manual actions.
### Upgrading from 3.x.x to 4.x.x
Due to migrating to a centralized common library some values in `values.yaml` have changed.
Examples:
* `service.port` has been moved to `service.port.port`.
* `persistence.type` has been moved to `controllerType`.
Refer to the library values.yaml for more configuration options.

View File

@ -0,0 +1,2 @@
ingress:
enabled: true

View File

@ -1,19 +1 @@
1. Get the application URL by running these commands: {{- include "common.notes.defaultNotes" . -}}
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "node-red.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 the status of by running 'kubectl get svc -w {{ include "node-red.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "node-red.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
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 "node-red.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}

View File

@ -1,32 +0,0 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "node-red.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 "node-red.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 "node-red.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@ -0,0 +1 @@
{{ include "common.all" . }}

View File

@ -1,120 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "node-red.fullname" . }}
{{- if .Values.deploymentAnnotations }}
annotations:
{{- range $key, $value := .Values.deploymentAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "node-red.name" . }}
helm.sh/chart: {{ include "node-red.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: 1
strategy:
type: {{ .Values.strategyType }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "node-red.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "node-red.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.podAnnotations }}
annotations:
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
{{- if .Values.serviceAccountName }}
serviceAccountName: {{ .Values.serviceAccountName }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 1880
protocol: TCP
{{- if .Values.probes.liveness.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.probes.liveness.probePath }}
port: http
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
{{- end }}
{{- if .Values.probes.readiness.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.probes.readiness.probePath }}
port: http
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
{{- end }}
{{- if .Values.probes.startup.enabled }}
startupProbe:
httpGet:
path: {{ .Values.probes.startup.probePath }}
port: http
failureThreshold: {{ .Values.probes.startup.failureThreshold }}
periodSeconds: {{ .Values.probes.startup.periodSeconds }}
{{- end }}
env:
- name: FLOWS
value: "{{ .Values.flows }}"
- name: NODE_RED_ENABLE_SAFE_MODE
value: "{{ .Values.safeMode }}"
- name: NODE_RED_ENABLE_PROJECTS
value: "{{ .Values.enableProjects }}"
- name: NODE_OPTIONS
value: "{{ .Values.nodeOptions }}"
- name: TZ
value: "{{ .Values.timezone }}"
{{- with .Values.extraEnvs }}
{{ toYaml . | indent 12 }}
{{- end }}
volumeMounts:
- name: data
mountPath: /data
{{- if .Values.persistence.subPath }}
subPath: {{ .Values.persistence.subPath }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
volumes:
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "node-red.fullname" . }}{{- end }}
{{- else }}
emptyDir: {}
{{ end }}
{{- if .Values.hostAliases }}
hostAliases:
{{ toYaml .Values.hostAliases | indent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
securityContext:
fsGroup: 1001

View File

@ -1,38 +0,0 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "node-red.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app.kubernetes.io/name: {{ include "node-red.name" . }}
helm.sh/chart: {{ include "node-red.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}

View File

@ -1,24 +0,0 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "node-red.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "node-red.name" . }}
helm.sh/chart: {{ include "node-red.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end -}}

View File

@ -1,42 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "node-red.fullname" . }}
{{- if .Values.service.annotations }}
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "node-red.name" . }}
helm.sh/chart: {{ include "node-red.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
type: ClusterIP
{{- else if eq .Values.service.type "LoadBalancer" }}
type: {{ .Values.service.type }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end -}}
{{- else }}
type: {{ .Values.service.type }}
{{- end }}
{{- if .Values.service.externalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
{{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{.Values.service.nodePort}}
{{ end }}
selector:
app.kubernetes.io/name: {{ include "node-red.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

View File

@ -1,132 +1,28 @@
# Default values for node-red. # Default values for node-red.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
# upgrade strategy type (e.g. Recreate or RollingUpdate)
strategyType: Recreate
image: image:
repository: nodered/node-red repository: nodered/node-red
tag: 1.0.6-12-minimal
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
tag: 1.2.5
nameOverride: "" strategy:
fullnameOverride: "" type: Recreate
serviceAccountName: "" # See more environment varaibles in the node-red documentation
# https://nodered.org/docs/getting-started/docker
# Probes configuration env: {}
# ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes # TZ:
probes: # NODE_OPTIONS:
liveness: # NODE_RED_ENABLE_PROJECTS:
# Indicates whether the container is running. If the liveness probe fails, the kubelet kills the container # NODE_RED_ENABLE_SAFE_MODE:
# and the container is subjected to its restart policy. # FLOWS:
enabled: true
probePath: /
initialDelaySeconds: 60
failureThreshold: 5
timeoutSeconds: 10
readiness:
# Indicates whether the container is ready to respond to requests.
enabled: true
probePath: /
initialDelaySeconds: 60
failureThreshold: 5
timeoutSeconds: 10
startup:
# Indicates whether the application within the container is started.
# All other probes are disabled if a startup probe is provided, until it succeeds.
enabled: false
probePath: /
failureThreshold: 30
periodSeconds: 10
flows: "flows.json"
safeMode: "false"
enableProjects: "false"
# nodeOptions: ""
extraEnvs: []
timezone: "UTC"
service: service:
type: ClusterIP port:
port: 1880 port: 1880
## Specify the nodePort value for the LoadBalancer and NodePort service types.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
##
# nodePort:
## Provide any additional annotations which may be required. This can be used to
## set the LoadBalancer service type to internal only.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
##
annotations: {}
labels: {}
## Use loadBalancerIP to request a specific static IP,
## otherwise leave blank
##
loadBalancerIP:
# loadBalancerSourceRanges: []
## Set the externalTrafficPolicy in the Service to either Cluster or Local
# externalTrafficPolicy: Cluster
hostAliases: []
# Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames.
# ref: https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/
# - ip: "192.168.1.100"
# hostnames:
# - "example.com"
# - "www.example.com"
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- chart-example.local
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
persistence: persistence:
enabled: false data:
## node-red data Persistent Volume Storage Class enabled: false
## If defined, storageClassName: <storageClass> emptyDir: false
## If set to "-", storageClassName: "", which disables dynamic provisioning mountPath: /data
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"
##
## If you want to reuse an existing claim, you can pass the name of the PVC using
## the existingClaim variable
# existingClaim: your-claim
accessMode: ReadWriteOnce
size: 5Gi
## When mounting the data volume you may specify a subPath
# subPath: /configs/node-red
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
nodeSelector: {}
tolerations: []
affinity: {}
podAnnotations: {}
deploymentAnnotations: {}