Developing NodeJS microservice for an OpenShift Cluster — Part III
Abstract
This article in the series describes the demo of OpenShift customers with screen-shots of the web console. This article might simplify the starting up of the demo. For the CLI version, take a look at Part I and Part II.
This demo will cover the development and deployment of a NodeJS microservice for an OpenShift cluster.
Here is an index of the articles:
- Part I — Developing NodeJS microservice for an OpenShift Cluster — Part I — Project description
- Part II — Developing NodeJS microservice for an OpenShift Cluster — Part II — OpenShift artifacts creation with CLI and NodeJS considerations
- Part III — Developing NodeJS microservice for an OpenShift Cluster — Part III (this article) — OpenShift artifacts creation with web console and NodeJS considerations
Pre-requisites
You have a working minishift cluster (You may install minishift with instructions from here.) and can login to the console as a developer. The login is normally done using IP address from minishift ip command, user name developer and password as any string.
Steps
The following steps will be executed for a successful installation of this demo.
- Project set-up
- Service and End-point set-up for Redis service
- Configuration Map for environment variables
- Application with GitHub repository
- Application overview
- Exposing the application service with a route
- Modified deployment configuration to refer the configuration map
Project set-up
From the landing page, create a new project by clicking on Create Project.

Fill in the details as shown below and click Create. Note that, the name custdemo will serve as the name space of this project.

Redis service and end-point
I am yet to figure out how to create the service and end-point for Redis external instance from the web console. Until then, YAML and CLI is the only option.
Paste the contents below into a file openshift-demo-service.yaml.
Paste the contents below into a file openshift-demo-endpoint.yaml.
Notes:
- The
name(line 4) should be same as the name of the service in the service definition YAML file. - The
ipaddress should be the one for Redis external database. - The
nameof ports (line 10) should be same as the name in the service definition YAML file.
Once the YAML files are prepared, run the following commands to create them:
On the web console, the service can be looked up from the left navigation bar, Applications -> Services. The Endpoint can be looked up at Resources -> Other Resources and selecting Endpoints from the drop down.
Configuration map
To create a configuration, go to the left navigation bar, click on Resources -> Config Maps and click on Create Config Map. Enter details as shown below.

Application
To create a new application, go to the catalog either from the home page or from the last icon on the left navigation bar. In the catalog, locate NodeJS and click on it. Then, click Next and add https://github.com/nsubrahm/openshift-demo-customers GitHub URL for the Git Repository as shown below. Click Create.

Application Overview
After clicking create, go to the Overview page to see the results of creating this application. It should look something like this below.

- A Deployment Configuration will be seen with the status of the pod.
- Clicking on this deployment configuration will show three associated items: Builds, Networking and Containers.
- The Builds section will show the status of build. OpenShift will automatically detect the language and initiate a S2I (Source to Image) build strategy. See here for more details. A successful build will create an image that can be located from the left navigation bar as Builds -> Images.
- The Networking section shows both the service that can be resolved inside the cluster only.
- The Containers section shows the status of the container that was triggered as part of the deployment configuration. The trigger will use the image created from the build configuration. The color of the annulus will turn into blue if the launch was successful; else, it will be red. The grey color denotes that the container is still being created. The number 1 denotes the count of instances that are running.
Exposing the service with a route
The Service openshift-demo-customers (as seen in the screenshot above) is visible only within the customer. It has to be exposed with a route so that it can be accessed from outside the cluster also. To do this, either click on Create Route visible to the right of the service name in the screenshot above. Or, from the left navigation bar, go to Applications -> Routes and click Create Route. Enter the name as custdemo.apis as shown below and leave rest unchanged. Just ensure that, the name of service matches the one created above openshift-demo-customers.

Click Create and the result should look like this. Note the value under Hostname — that is the value to be used from Postman, etc. to access the service from outside the cluster.

Deployment Configuration
After a while, you will notice that the launch has failed. This is expected because the configuration map is not associated with the deployment configuration. Recall that, the NodeJS application refers to environment variables that are injected into the containers from the key in the configuration map. To associate the configuration map with the deployment configuration, go to Applications on left navigation bar and click on Deployments. Click on custdemo to open the deployment configuration and click on Environment tab to set the environment variables as shown below.

Click on Add Value from Config Map or Secret to see a row for entering details as shown below. Click Save.

Since the deployment configuration is now changed, a deployment is automatically triggered. This deployment completes successfully — note the blue color of the annulus for the pod.

Click on the pod icon and click on the Logs tab to see results of the successful launch.

Testing
To test this deployment, use the host name of the Route in the Postman scripts from here — https://github.com/nsubrahm/openshift-demo-postman
