Ready to dive a little deeper into understanding the Bluemix platform? Yes? Great! Let us get started by looking at what you will get to learn in this chapter. In this chapter, you will learn how to compose an extensible application by using services from the Bluemix catalog; we will take you through this using a sample application. We will also learn what continuous delivery is and how would you should be configuring your application to achieve continuous delivery using the DevOps services provided on the Bluemix platform. You will also learn how to extend this application easily to incorporate more functional capabilities.
In this chapter, we will be covering the following topics:
The delivery pipeline is the mechanism for configuring continuous delivery in the agile application development and deployment lifecycle. The delivery pipeline is a service in the DevOps category. A suite of other services are also available under the DevOps category on Bluemix. The services available in this category at the time of writing this book is as shown in the following screenshot:
Before we look at how to configure the delivery pipeline, we will need to create an application that we will use for illustration. So let us get started by creating a starter application by using a boilerplate, as we did in the previous chapter. This time, we will use the Internet of Things boilerplate to create the starter application. We have chosen this boilerplate for few reasons, as follows:
Having finished Chapter 2 , Building and Deploying Your First Application on IBM Bluemix, you will be now well-versed in creating an application using boilerplate; hence, we will not be going through all the steps of application creation in detail in this section.
URLs for accessing the new Bluemix console are as follows:
Datacenter |
URL |
United States | |
United Kingdom | |
Sydney |
Follow these steps to create the sample application; the sample application will be an Internet of Things example application:
Internet of Things
.
Your application is created and started along with the services in the boilerplate-Cloudant NoSQL DB, in this case:
Before we look at the application we just deployed, let us understand what Node-RED is and how to compose applications using the Node-RED editor.
Node-RED is a community-based tool that is used to wire APIs, services, or devices in ways that create innovative applications. Applications developed with Node-RED run on Node.js runtime.
Find out more about Node-RED by going to http://nodered.org .
Node-RED provides a browser-based editor to compose or wire applications. The components that can be wired together are displayed in the editor palette and are called nodes. The list of nodes available in the palette is extensible; you can write your own nodes, add them to your Node-RED package, and even contribute them to the community.
To find out more about how to extend your Node-RED palette, you can refer to http://nodered.org/docs/creating-nodes/ .
With this introduction to Node-RED, let us start from where we left off in our previous section:
This welcome page can be modified to suit your application, if you desire.
Since we have used the Internet of Things boilerplate to reach the Node-RED editor, you will see that a starter application has already been created by Bluemix.
This starter application reads device data using the IBM Internet of Things node. The device data is expected to push temperature readings to the flow. This is then checked for its value, and if the value is below a certain reference value, the output indicates safe limits. If the temperature is above the reference range, the output indicates it as critical. In the starter application, the output is pushed to the debug node, which can be seen in the debug window. Let us first understand this flow in detail by looking at each node and its configuration:
The ibmiot node is an input node that receives data from devices using IBM Internet of Things Foundation. The detailed information on this node can be seen in the info tab after selecting the node in the flow editor.
Configuring the ibmiot node
Double-click on the node to open its configuration window, which is as shown in the following screenshot:
You will see that you can specify the Authentication mechanism to connect to your device, define the Input type for the trigger or data that you want to listen to, configure the Device Id of the device you want to receive data from, and the node Name field, where you can specify the name of your ibmiot node in the flow.
In this starter application example, we will be using a mock device for which we will be using the quickstart facility of the IBM Internet of Things Foundation. Hence, you will see that the Authentication field is left with the value of Quickstart
, Input Type with the value of Device Event
, and Name with the value of IBM Iot App In
. To configure the Device Id field, go to
https://quickstart.internetofthings.ibmcloud.com/iotsensor/
to get a mock device.
You will be provided with a simulated sensor device that outputs temperature, humidity, and object temperature:
The identifier on the top right-hand corner, as shown in the following screenshot, is the device identifier for this simulated device. This is the identifier that you will need to input to the Device Id field in the ibmiot configuration dialog box:
Click Ok. This will enable the Deploy button. Click Deploy to deploy the change to Bluemix:
The output of any node is displayed on the debug tab of the sidebar of the flow editor by using the debug node in the flow, as shown. In this starter application flow, two debug nodes are wired, named device data and cpu status. The device data debug node outputs the device data received by the ibmiot node. The cpu status debug node outputs the final results as a result of execution of the logic written within the function nodes and formats specified within the template nodes.
The following screenshot shows the output from the two debug nodes in the flow, in the debug editor, after the Device Id field is configured in the ibmiot node:
You can use the function node to write code to manipulate the message passed as a JavaScript Object. For this starter application, the function node carries the code, as shown in the following screenshot. The temperature is extracted from the message payload and passed on to the next node:
For more information about working with the function node, you can refer to http://nodered.org/docs/writing-functions.html .
This node is used to route messages based on the value of the property in the message object. Routes are defined by defining rules on the switch node. The number of rules defined creates an equal number of output endpoints on the node, which can be wired to define individual flows paths. In this starter application, the switch node is used to check the temperature value from the input message object and define rules based on the temperature threshold value of 40 degrees:
This node is used to display the property based on the template provided. In the starter application flow, we see there are two template nodes, safe and danger. Both of these nodes display the temperature property based on the template definition; the following screenshot shows the configuration for the safe node:
The following screenshot shows the configuration for the danger node:
Let us see how we can configure the delivery pipeline for the application we just created, so that any changes to the application can reflect automatically in the deployed application. Complete the following steps to configure the delivery pipeline:
The build stage is configured to be triggered when there is a Git commit in the repository identified by the Git URL.
The available builder types are shown in the following screenshot:
You can configure multiple jobs within the same stage by clicking ADD JOB, as shown in following screenshot:
The types of jobs that you can configure within a stage are as follows:
You can use the Test job type to configure tests that need to be run once the build for your application completes.
You can also use ENVIRONMENT PROPERTIES to define properties that need to be used across your jobs from the screen, as shown in the following screenshot:
For this illustration, we will use the default pipeline configuration with one build stage using a Simple Builder type and one deploy stage, which will deploy the built application to a space within your organization on Bluemix. Go to the deploy stage configuration by clicking on the stage configuration icon, as shown in the following screenshot, and clicking Configure Stage from the pop-up menu:
The deploy stage looks like the following screenshot:
The supported deployments, as configured using the Deployer Type values, are as follows:
You can edit the push command in the deployment script of the deploy stage for your application.
You can also configure the deployment of your application to another region, organization, and space by selecting the desired Target, Organization, and Space at the deploy stage.
You can edit the application source using any of the development editors of your choice locally, or you can also edit your application code using the web editor provided by IBM DevOps services. The web editor provided on Bluemix is based on the Eclipse Orion project:
flow.json
file to illustrate the continuous delivery. Modify the template node when the temperature goes above the threshold value. Change the output from Temperature ({{payload}}) is critical
to Temperature ({{payload}}) is critical. You will need to take safety measures
. Click File | Save:
You can click Push to push your changes to the master repository:
In this section, we looked at a simple example of how to achieve continuous delivery for your application by configuring the stages in the delivery pipeline.
18.225.95.245