Slide 1

Slide 1 text

Building cloud native applications with Node-RED Nick O’Leary IBM Open Source Developer Node-RED Project Lead @knolleary https://ibm.biz/NRWorkshop

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Part 1 Getting Started with Node-RED 10 Get a Node-RED application running locally against a CouchDB database https://ibm.biz/NRWorkshop

Slide 11

Slide 11 text

11 https://ibm.biz/NRWorkshop

Slide 12

Slide 12 text

12 https://ibm.biz/NRWorkshop

Slide 13

Slide 13 text

13 https://ibm.biz/NRWorkshop

Slide 14

Slide 14 text

14 Node-RED Editor Runtime https://ibm.biz/NRWorkshop

Slide 15

Slide 15 text

15 Node-RED Editor Runtime https://ibm.biz/NRWorkshop

Slide 16

Slide 16 text

16 flow.json : the flow configuration flow_cred.json : credentials file package.json https://ibm.biz/NRWorkshop

Slide 17

Slide 17 text

17 Node-RED Editor Runtime CouchDB https://ibm.biz/NRWorkshop

Slide 18

Slide 18 text

Part 2 Setting up your Cloud environment 18 Create an IBM Cloud account and install the ibmcloud command-line tool https://ibm.biz/NRWorkshop

Slide 19

Slide 19 text

Part 3 Deploy you application to the IBM Cloud 19 Get your application running in the IBM Cloud https://ibm.biz/NRWorkshop

Slide 20

Slide 20 text

20 Node-RED Editor Runtime https://ibm.biz/NRWorkshop

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

22 Runtime https://ibm.biz/NRWorkshop

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

24 Runtime Cloudant https://ibm.biz/NRWorkshop

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

26 Runtime Cloudant https://ibm.biz/NRWorkshop

Slide 27

Slide 27 text

Building cloud native applications with Node-RED Nick O’Leary IBM Open Source Developer Node-RED Project Lead @knolleary https://ibm.biz/NRWorkshop