Install Custom Drivers in NodeRed

This page describes how to install custom drivers in NodeRed.

NodeRed is running on Alpine Linux as non-root user. This means that you can’t install packages with apk. This tutorial shows you how to install packages with proper security measures.

Before you begin

You need to have a UMH cluster. If you do not already have a cluster, you can create one by using the Management Console.

Change the security context

  1. From the StatefulSets section in UMHLens / OpenLens, click on united-manufacturing-hub-nodered to open the details page.

  2. Click the Edit button to open the StatefulSet’s configuration.

    Lens StatefulSet Edit
    Lens StatefulSet Edit

  3. Press Ctrl+F and search for securityContext.

  4. Set the values of the runAsUser field to 0, of fsGroup to 0, and of runAsNonRoot to false.

    ...
           securityContext:
             runAsUser: 0
       restartPolicy: Always
       terminationGracePeriodSeconds: 30
       dnsPolicy: ClusterFirst
       securityContext:
         runAsUser: 0
         runAsNonRoot: false
         fsGroup: 0
    ...
    
  5. Click Save.

Install the packages

  1. From the Pods section in UMHLens / OpenLens, click on united-manufacturing-hub-nodered-0 to open the details page.

  2. Click the Pod Shell button to open a shell in the container.

    Lens Pod Shell
    Lens Pod Shell

  3. Install the packages with apk:

    apk add <package>
    

    For example, to install unixodbc:

    apk add unixodbc
    

    You can find the list of available packages here.

  4. Exit the shell.

Revert the security context

For security reasons, you should revert the security context after you install the packages.

  1. From the StatefulSets section in UMHLens / OpenLens, click on united-manufacturing-hub-nodered to open the details page.

  2. Click the Edit button to open the StatefulSet’s configuration.

    Lens StatefulSet Edit
    Lens StatefulSet Edit

  3. Set the values of the runAsUser field to 1000, of fsGroup to 1000, and of runAsNonRoot to true.

    ...
           securityContext:
             runAsUser: 1000
       restartPolicy: Always
       terminationGracePeriodSeconds: 30
       dnsPolicy: ClusterFirst
       securityContext:
         runAsUser: 1000
         runAsNonRoot: true
         fsGroup: 1000
    ...
    
  4. Click Save.

What’s next

Last modified April 17, 2023: build: version 0.9.13 (6cb0a01)