Closed beasteers closed 1 year ago
hi @beasteers,
Had no time to check on this one. Is this still needed for you?
No worries, I ended up forking and did the install by overriding container command to install before launching node-red. It'd be a good thing to have built-in to the chart though
Hi, I think from the k8s microservice perspective the additional node modules (npm packages) should be installed when reading/refresh the flows from the k8s-sidecar. This would be insure there are no missing nodes. Check nodes requirements, install modules, reload flowrefresh.py....
The modules can be installed via API request (POST /nodes) and existing sidecar and preserves privilege escalation in the container as npm needs admin rights.
Actually, for automating this process I am missing the node module name from the GET /flows json v2 result to check if the node is installed (GET /nodes)and if not installing the corresponding node module (POST /nodes) .
Workaround would be an extra helm list value witch installs the npm modules from an extra sidecar. The modules had to declared separately and have to match with the flows nodes modules.
I am facing the same feature for my installation. Not sure witch method is the best to choose from.
I started a thread in the node-red user forum.
https://discourse.nodered.org/t/api-install-flows-and-modules-automated-via-api-requests/78962/3
But it looks like i have to declare the module names (npm packages) separately.
Most probably you have to. There's no data referencing the (e.g. npm) package name of a node in the flows json. If you try to guess the package name, you may even fall over ambiguities - as there's no mechanism to ensure that a node name may only be used once in the Node-RED universe...
This means the package module names have to be declared manually. If using the sidecar in the helm chart for import flows this have to match.
I can write a python script for installing extra node modules, same way like in the sidecar for flows. Not sure if this is the best way to do it. Declare extra NPM Module Names in a ConfigMap. Watch the ConfigMap and interate threw the module names and install each one.... Have to check if this is possible within the existing sidecar, or even within the flow_refresh script. There will be some ups and downside depending on how you use the helm chart.
@beasteers and @dirien What do you think?
Have done some testing with the flow_refresh.py script. I think it works very well....New Script
extraEnv:
- name: LOG_LEVEL
value: "DEBUG"
- name: NODE_MODULES
value: "node-red-contrib-xkeys_setunitid, node-red-contrib-microsoft-teams-tasks, node-red-contrib-json"
Node Modules will be installed shortly after pod startup. ExtraEnv is not the best place to store the node module names. This is just for a first poc or test. Maybe a configMap would be fit better.
python3 flow_refresh.py
----START PYTHON SIDECAR SCRIPT----
node-red node module install and flow refresh api call via k8s-sidecar
sidecar sleeping for 5 seconds...
----TOKEN----
node-red bearer token successfully created - 200
----INSTALL EXTRA MODULES----
extra node modules from env - ['node-red-contrib-xkeys_setunitid', 'node-red-contrib-microsoft-teams-tasks', 'node-red-contrib-json']
installed node modules - ['node-red-contrib-xkeys_setunitid', 'node-red']
node module node-red-contrib-xkeys_setunitid already installed...
node module node-red-contrib-microsoft-teams-tasks successfully installed - 200
node module node-red-contrib-json successfully installed - 200
----RELOAD FLOWS----
node-red flows successfully reloaded - 200
Hey @beasteers,
Hope the feature from @hinrichd is helping you. Closing this issue for now.
There's one issue with the current solution - this doesn't support packages that are needed in the settings.js file which will prevent nodered from starting in the first place - e.g. authentication providers, themes, etc.
I guess the best place for this to live would be in an init container?
Is your feature request related to a problem? Please describe.
Many times, people want to use custom nodes in nodered, but there isn't an obvious way to install them using the configuration. Basically, just looking for a way to do
npm i pkgA
fromvalues.yaml
.Describe the solution you'd like
Some options:
values.yaml
.startupCommands: ["npm i pkgA"]
orinstallPackages: ["pkgA"]
tovalues.yaml
Describe alternatives you've considered
I'm working on getting the right init container/sidecar setup but need to figure out the right base image, volume mounts, and other config necessary. I'm not sure I understand the difference between
/data/package.json
and/usr/src/node-red/package.json
thoSearch
Code of Conduct
Additional context
No response