Install Custom Drivers in NodeRed
2 minute read
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
From the StatefulSets section in UMHLens / OpenLens, click on united-manufacturing-hub-nodered to open the details page.
Click the Edit button to open the StatefulSet’s configuration.
Press
Ctrl+F
and search forsecurityContext
.Set the values of the
runAsUser
field to 0, offsGroup
to 0, and ofrunAsNonRoot
to false.... securityContext: runAsUser: 0 restartPolicy: Always terminationGracePeriodSeconds: 30 dnsPolicy: ClusterFirst securityContext: runAsUser: 0 runAsNonRoot: false fsGroup: 0 ...
Click Save.
Install the packages
From the Pods section in UMHLens / OpenLens, click on united-manufacturing-hub-nodered-0 to open the details page.
Click the Pod Shell button to open a shell in the container.
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.
Exit the shell.
Revert the security context
For security reasons, you should revert the security context after you install the packages.
From the StatefulSets section in UMHLens / OpenLens, click on united-manufacturing-hub-nodered to open the details page.
Click the Edit button to open the StatefulSet’s configuration.
Set the values of the
runAsUser
field to 1000, offsGroup
to 1000, and ofrunAsNonRoot
to true.... securityContext: runAsUser: 1000 restartPolicy: Always terminationGracePeriodSeconds: 30 dnsPolicy: ClusterFirst securityContext: runAsUser: 1000 runAsNonRoot: true fsGroup: 1000 ...
Click Save.