Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node-RED in Production

Node-RED in Production

These slides accompany the Node-RED in Production workshop I delivered at NodeConf EU 2019.

See https://ibm.biz/NRWorkshop for more information

Nick O'Leary

November 12, 2019
Tweet

More Decks by Nick O'Leary

Other Decks in Programming

Transcript

  1. Building cloud native applications with Node-RED Nick O’Leary IBM Open

    Source Developer Node-RED Project Lead @knolleary https://ibm.biz/NRWorkshop
  2. What is Node-RED? 2 Many applications we build today, from

    Integration to IoT, often require pulling together different APIs, online services and hardware devices in new and interesting ways. Time spent figuring out how to access a Serial port, or to complete an OAuth flow against Twitter is not time spent on creating the real value of a solution. We need tools that make it easier for developers at all levels to create applications and allow them to focus on what is important. https://ibm.biz/NRWorkshop
  3. What is Node-RED? 3 The Node-RED editor runs in a

    browser and allows you to create applications by drawing flows of events. Each node in a flow represents a well-defined piece of functionality, such as updating a value, making a database query or sending a tweet. The developer configures each node as required, focused on what it does, not how it does it. When the flow is deployed to the Node-RED runtime, each node becomes a running piece of code and messages start passing through the flow. “Flow-based programming for event-driven applications” https://ibm.biz/NRWorkshop
  4. Technical Overview architecture 4 There are two logical parts to

    Node-RED. The Runtime is a node.js application. It is responsible for running the deployed flows. The Editor is a web application where the user can edit their flows. The main installable package includes both components, with a web-server to provide the Editor as well as a REST Admin API for administering the runtime. Internally, these components can be installed separately and embedded into existing Node.js applications. node-red runtime editor HTTP Admin API @node-red/editor-api Client-side Editor @node-red/editor-client Flow Runtime @node-red/runtime Core Nodes @node-red/nodes Node Registry @node-red/registry Common Utils @node-red/util https://ibm.biz/NRWorkshop
  5. Technical Overview flows 5 A flow is a collection of

    nodes that are wired together. A node can have multiple output ports and a single port can have multiple wires connected to it. The flow is stored as a JSON object – providing the configuration for all of its nodes and how they are connected. The flow JSON can be imported and exported between Node-RED instances, making it easy to share flows. https://ibm.biz/NRWorkshop
  6. Technical Overview messages 6 The messages that pass through a

    flow are JavaScript Objects. By convention they will have a payload property that contains the ‘interesting’ information. This is the property most nodes will operate on by default. topic: “weather/uk” payload: “sunny!” … … https://ibm.biz/NRWorkshop
  7. Technical Overview nodes 7 Nodes are the basic building blocks

    of a flow. Nodes that sit at the start of a flow will be waiting for some external event to occur, such as an incoming HTTP request, a timer event or a hardware IO event. They then pass messages onto the nodes they are connected to. Nodes receive those messages, do some work, and then pass them on down the flow. payload: “Jedi are totally amazing!” payload: “Jedi are totally amazing!” sentiment: { score: 4 } In this example, a Sentiment analysis node has examined the ’payload’ property of the message, assessed its sentiment and added its result as a new property of the message. https://ibm.biz/NRWorkshop
  8. Technical Overview nodes 8 Nodes also represent the main way

    Node-RED can be extended by the community. They consist of two parts: - A node.js module that defines the runtime behavior of the node. - An HTML file that provides its appearance, edit dialog and help text for the Editor These are packaged as a Node.js module and distributed via the NPM package repository. The project hosts https://flows.nodered.org that automatically indexes the available Node-RED modules on npm https://ibm.biz/NRWorkshop
  9. Part 1 9 https://ibm.biz/NRWorkshop Part 2 Part 3 Part 4

    Part 5 Getting Started with Node-RED Setting up your Cloud environment Deploy you application to the Cloud Connect your app to a cloud-hosted db Setup a deployment pipeline to Cloud
  10. Part 1 Getting Started with Node-RED 10 Get a Node-RED

    application running locally against a CouchDB database https://ibm.biz/NRWorkshop
  11. Part 2 Setting up your Cloud environment 18 Create an

    IBM Cloud account and install the ibmcloud command-line tool https://ibm.biz/NRWorkshop
  12. Part 3 Deploy you application to the IBM Cloud 19

    Get your application running in the IBM Cloud https://ibm.biz/NRWorkshop
  13. 21 flow.json : the flow configuration flow_cred.json : credentials file

    package.json settings.js : runtime settings manifest.yaml : deployment manifest https://ibm.biz/NRWorkshop
  14. Part 4 Connect your application to a cloud-hosted db 23

    Create a cloud-hosted Cloudant instance and configure the application to use it with separate development and production databases https://ibm.biz/NRWorkshop
  15. Part 5 Setup a deployment pipeline to IBM Cloud 25

    Create a deployment pipeline use TravisCI to automatically deploy your application when pushing updates to a GitHub repository https://ibm.biz/NRWorkshop
  16. Building cloud native applications with Node-RED Nick O’Leary IBM Open

    Source Developer Node-RED Project Lead @knolleary https://ibm.biz/NRWorkshop