Are you at the Jenkins conference this week? We’re excited to be there as a sponsor and meet many of you who work on continuous deployments (CD). Our goal is to help you achieve CD without writing scripts or doing manual grunt work. To that end, we want to showcase full CD automation for your use-cases using Jenkins and ElasticBox. A simple Todo Node.js application tutorial demonstrates the CD automation in this post.
Before we get to the demo, let’s quickly review some basics. ElasticBox, as you may know, enables self-service deployments. It’s where DevOps define app automation as microservices so that developers and QA can self-service deployments in development, staging, and production on any cloud. For end-to-end CI/CD, ElasticBox integrates with Jenkins and your choice of SCM like GitHub. To get started, install Jenkins server with the ElasticBox plugin from the free public box catalog.
Without further ado, let’s jump into the demo.
Node.js tutorial overview
I’m going to demonstrate the most challenging parts of continuous deployments for multi-tier applications. They are often the roadblocks to most continuous deployments in an enterprise:
- Defining multi-tier app automation as reusable microservices. Without component level microservice automation, preserving change history and managing updates even on a small scale quickly becomes a macro nightmare.
- Setting up hybrid cloud continuous deployments. Most of the time, plugins for a cloud service only support deployments to that particular cloud whereas you want the flexibility to deploy anywhere.
- Automating continuous deployments. Continuous deployments are hard because of the level of complex automation involved at every stage. Automation doesn’t have to be so hard. It can be simple, and we show how.
Defining multi-tier app automation as reusable microservices
To demonstrate full CD automation, I use Todo, a simple Node.js multi-tier app for managing tasks. It has three layers. Each layer is defined in ElasticBox box automation as independent, reusable components.
- Nginx load balancer Bastion. It forwards HTTP client traffic to the application and acts as a Bastion host to route traffic securely from the outside. This box can launch Nginx to any cloud on a Linux machine. It configures Nginx to listen on port 80 and then forward requests to the app instances in a load balancing pool.
- Todo task application built on top of Node.js. This box first installs Node.js, then installs the Todo app from a Git repo, and finally links the app to a MongoDB database through a binding. It’s the binding that helps generate a connection string to be able to connect to the database.
- MongoDB as the database. This box pulls MongoDB from Git, then installs and configures it using Puppet.
Setting up hybrid cloud continuous deployments with Jenkins and ElasticBox
To setup a hybrid cloud deployment that ties together all the components of the multi-tier Node.js application, I rely on two things: Jenkins integration with ElasticBox plus bindings. Let’s go ahead and set up the continuous deployment flow.
In Jenkins, I first add my ElasticBox account with an authentication token.
Next, I create a Jenkins job to deploy in production a particular sequence of steps. Each step deploys a layer of our multi-tier application stack. In the Jenkins job, ElasticBox build steps let me pull up any box automation from my account.
Step 1: Launch the MongoDB server
A deploy build step in the ElasticBox plugin allows me to select the MongoDB box. Here I tag the instance mongodb-production because it’s the glue that will let me bind to other components later. I also select a deployment policy that lets me deploy the database more securely in a vSphere private datacenter, a scenario that a lot of enterprises desire.
Step 2: Launch the Todo Node.js application
Again, I use the deploy ElasticBox plugin build step in Jenkins to set up the Node.js app launch. Here also I use tags (todoapp, production) for binding purposes. And I bind to the database by simply entering the mongodb-production tag from the previous step. Because this is a hybrid cloud deployment, I will host the Node.js app on AWS. Accordingly, I select an AWS deployment policy.
Step 3: Launch the Nginx Bastion load balancer
Finally, I ask Jenkins to deploy the Nginx Bastion load balancer from the box. And I bind it to the Todo Node.js application instances tagged todoapp and production from the previous build step. When an instance matching the tags launches from my ElasticBox workspace, it gets added to the load balancing pool. Remember how we configured the Nginx box to loadbalance Todo instances?
As you can see, in just a few minutes I was able to set up the full continuous deployment of a simple Node.js multi-tier application using Jenkins plus ElasticBox.
Automating continuous deployments
Of course to make all this magic happen, I used some box automation help:
- IT Ops made it easy for me not to worry about all the murky infrastructure details or instance types, storage, VPCs, and networking. They simply enabled the clouds for my ElasticBox account, carved out AWS and vSphere infrastructure resources through the deployment policy boxes, and shared them with me.
- Secondly, we saw that binding tags associate components together; however we still need to leverage connection data from a binding to establish connectivity. Here again, my IT Ops configured bindings in the box definition.
See continuous deployment in action
At last, it’s time to deploy! Watch the entire deployment and get a peek at the box setup. It only takes me one click to kick off the entire deployment end to end. And voila, I have an Nginx Bastion loadbalancing two Node.js Todo app instances both pointing to the same MongoDB instance.
Did you try out the Node.js tutorial? Tell us what you think. It’s easy to extend this same flow to any of your large-scale application deployments. Start with a FREE account in ElasticBox today. We’re excited to see what we can help you deploy next!