Deploying Node-RED via Helm
Relevant source files
The following files were used as context for generating this wiki page:
The deployment of Node-RED in the swimctl project provides a centralized automation controller for swimming pool management. This implementation leverages Helm to manage the Node-RED lifecycle, integrating it with hardware interfaces on a Raspberry Pi via a Kubernetes cluster (k3s).
The deployment is characterized by a specialized OCI-based Helm chart that configures Node-RED with custom environment variables, security contexts for hardware access, and an automated git-based flow synchronization mechanism.
Infrastructure Prerequisites
Before deploying the Helm chart, the target hardware—typically a Raspberry Pi—must be prepared to support containerized workloads and hardware I/O. This involves enabling cgroups for memory management and configuring the I2C interface.
The diagram shows the sequential steps required to prepare the environment for the Node-RED deployment.
Sources: README.md:5-52
Hardware and Cluster Configuration
The deployment relies on specific host configurations and Kubernetes resources to function:
- Cgroups: Required for memory resource limiting in k3s.
- I2C: Enabled on the host to allow the container to interface with pool hardware.
- Secrets: A generic secret named
swimctlmust exist, containinggh_token,gh_owner,gh_repo_name, andmqtt_password.
Sources: README.md:7-41, values.yml:45-70
Helm Deployment Configuration
The deployment utilizes the schwarzit/charts/node-red Helm chart, customized via a local values.yml file.
Image and Resource Limits
The deployment uses a custom image bgshacklett/swimctl:latest. It requests and limits specific smarter-devices/i2c resources to ensure exclusive access to I2C buses.
| Resource Key | Type | Value |
|---|---|---|
image.repository | String | bgshacklett/swimctl |
resources.limits.smarter-devices/i2c-1 | Integer | 1 |
resources.limits.smarter-devices/i2c-20 | Integer | 1 |
resources.limits.smarter-devices/i2c-21 | Integer | 1 |
Sources: values.yml:1-17
Security and Hardware Access
To interact with the Raspberry Pi's physical hardware, the pod runs with specific UID/GIDs and supplemental groups. Specifically, group 994 is included to provide I2C access.
Sources: values.yml:20-28
Automated Flow Management
Node-RED is configured to use its Projects feature, which is synchronized with a GitHub repository during pod initialization.
Initialization Sequence
An init container named clone-repo performs the initial synchronization. It clones the flow repository and sets up a post-commit hook.
This sequence illustrates how flow data is retrieved from GitHub before the main Node-RED process begins.
Sources: values.yml:95-135
Git Integration and Webhooks
The values.yml defines a post-commit hook that automatically triggers a GitHub Action (apply-patch.yml) whenever a commit is made within the Node-RED UI. This uses the GITHUB_TOKEN_FLOWS and other environment variables derived from Kubernetes secrets.
Sources: values.yml:45-68, values.yml:120-135
Network and Service Discovery
The deployment includes specialized components for service discovery and external access.
Ingress and mDNS
Node-RED is exposed via an Ingress resource at swimctl.local. To support local network discovery without complex DNS, the project deploys an external-mdns service in the kube-system namespace. This service watches Ingress and Service resources to broadcast their presence over mDNS.
Sources: values.yml:73-80, external-mdns.yaml:47-65
Device Management
The smarter-device-manager is deployed as a DaemonSet in the device-manager namespace. It facilitates the mapping of host devices (like /dev/i2c-*) into the Kubernetes pod environment, controlled by a ConfigMap that defines device matching patterns.
The relationship between the device manager and the hardware access required by Node-RED.
Sources: smarter-device-manager.yaml:1-60, configMaps.yaml:1-8, 00-namespaces.yaml:1-6
Summary of Configuration
The system is finalized through a combination of environment variables and ConfigMaps that define the Node-RED settings.
| Config Element | Source | Description |
|---|---|---|
NODE_RED_ENABLE_PROJECTS | Environment | Enables the built-in git projects feature |
node-red-settings | ConfigMap | Merges custom activeProject with default Node-RED settings |
node-red-projects-settings | ConfigMap | Defines swimctl-flows as the active project without credential secrets |
Sources: values.yml:41-45, configMaps.yaml:11-39