SchwarzIT / node-red-chart

Node-red Helm Chart
Apache License 2.0
36 stars 24 forks source link

Updated flow-refresh.py to install node modules from sidecar extraEnv… #253

Closed hinrichd closed 1 year ago

hinrichd commented 1 year ago

Thank you for making node-red ⚙ better

Please reference the issue this PR is fixing. npm install from values file

New Feature: Install extra node modules via flow_refresh.py script

If your flows from the sidecar depend on nodes from modules that are not preinstalled in the node-red server, you can install them by declaring sidecar.extraEnv: NODE_MODULES (Comma separated list of node-modul names.)

  1. Put NODE_MODULES variable in sidecar.extraEnv, e.g.
    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"
  2. Script will check if this modules are already installed and install missing ones.
  3. Script will reload flows

Also verify you have:

hinrichd commented 1 year ago

Hey @dirien,

like mentioned in the npm issue i have switched from extraEnV to configMap to install extraNodeModules. When upgrading the helm values extraNodeModules the node modules will be also updated. This was not the case with the extraEnv.

Also tried to update the readme docs with this new behaviour (..gotmpl).

The k8s-sidecar can also call the node-red api to install additional node modules (npm packages) before refreshing or importing the flow.json. You need to list your flows requiert 'NODE_MODULES' in the sidecar.extraNodeModules: e.g.

sidecar:
 extraNodeModules:
    - node-red-contrib-xkeys_setunitid
    - node-red-contrib-microsoft-teams-tasks
    - node-red-contrib-json

To install the node modules successfully, the node red pod needs access to the npmrc.registry to download the declaired modules/packages.

I hope this will help ✌️

dirien commented 1 year ago

Hey @hinrichd,

Thanks for the contribution! Let me have a look into the code!