Install Custom Drivers in NodeRed
less than a minute
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 following the Getting Started guide.
You also need to access the system where the cluster is running, either by logging into it or by using a remote shell.
Change the security context
From the instance’s shell, execute this command:
sudo $(which kubectl) patch statefulset united-manufacturing-hub-nodered -n united-manufacturing-hub -p '{"spec":{"template":{"spec":{"securityContext":{"runAsUser":0,"runAsNonRoot":false,"fsGroup":0}}}}}' --kubeconfig /etc/rancher/k3s/k3s.yaml
Install the packages
Open a shell in the united-manufacturing-hub-nodered-0 pod with:
sudo $(which kubectl) exec -it united-manufacturing-hub-nodered-0 -n united-manufacturing-hub --kubeconfig /etc/rancher/k3s/k3s.yaml -- /bin/sh
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 by typing
exit
.
Revert the security context
For security reasons, you should revert the security context after you install the packages.
From the instance’s shell, execute this command:
sudo $(which kubectl) patch statefulset united-manufacturing-hub-nodered -n united-manufacturing-hub -p '{"spec":{"template":{"spec":{"securityContext":{"runAsUser":1000,"runAsNonRoot":true,"fsGroup":1000}}}}}' --kubeconfig /etc/rancher/k3s/k3s.yaml