DevOps Tools for Continuous Delivery in Jelastic Private Cloud. Part 1: Workloads Distribution and Jenkins Installation

By June 30, 2015 HowTo No Comments
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

image26

The vast majority of software development companies have to place a great emphasis on the process of continuous integration and rapid delivery of new versions of their product. Obviously, when supplying enterprise-level projects, such processes need to be automated as much as possible. And this is when the cloud DevOps tools come in handy.

Thus, in today’s article we’d like to pay a special attention to the DevOps tools that automate the continuous integration and delivery within the Jelastic PaaS that can be installed on any bare metal or cloud infrastructure as Virtual Private Cloud or Hybrid Cloud.

This is a pretty complex example of enterprise application life cycle with continuous integration and seamless migration throughout DevOps Pipeline from development to several productions (you can use simplified process if you have less complex project).

The instruction below will be useful for Jelastic cluster administrators such as systems integrators, hosting service providers, enterprises, and ISV customers, who can easily implement it at their Jelastic Cloud installations. Nevertheless, this guide contains plenty of features and continuous integration tips described, which can be interesting for different developers.image29

So, let’s get started with the first part of the instruction!

Setting Up Dedicated User Groups

First of all, you need to allocate separate hardware sets for all your project teams (one per each development phase, i.e. development > testing > production) and adjust the access permissions to make them completely isolated and not influenced by others. The Multi-Regions for a Hybrid Cloud option, that became available within the recently released Jelastic 3.3 version, is optimally suited for this task.

  1. To start with, create three hardware node groups (within one region) and name them after the corresponding stages for more convenience (e.g. dev, test, production).

image23

  1. The next step is to prepare three user groups and attach them to the corresponding hardware – in our case the dev group has access to the dev hardware node group only, qa – to the test one, and ops should work specifically with the production set.

image24

In such a way, users from the appropriate groups can use the specified sets of hardware only, but at the same time – they have a possibility to transfer their environments throughout the whole platform, between different teams’ accounts.

Jenkins Continuous Integration Server Configuration

Now we need the integration tool, that will control and perform all of the required operations automatically, i.e. build the cloud DevOps pipeline. Our choice fell on Jenkins as one of the most popular solutions used for this goal –  it can be easily installed from our Marketplace either at the corresponding site page or directly via the dashboard.

image01

As a result, you’ll get the pure Jenkins installed, which should be properly adjusted before you start organizing your application life cycle. Thus, select the Open in browser button and proceed with the following configurations steps:

  1. While at the home page, click on the Manage Jenkins option at the left-hand menu and select the Manage Plugins link within the appeared list.

image19

  1. After you’ve been redirected to the Plugin Manager, switch to the Available tab, find the following plugins using the search Filter field above and tick them for installation:
  • Git Plugin – is required for building our project’s source (stored at the GitHub repository)
  • Envfile Plugin – is used for storing system environment variables (its necessity is driven by security restrictions, implemented at Jelastic, which forbid the direct exporting of environment variables from the Tomcat server)

image15

Click Install without restart when ready.

During the installation process, tick the Restart Jenkins when installation is complete and no jobs are running option to automatically restart Jenkins for enabling the chosen plugins.

  1. Then, you also need to install Maven, which will be used for building the project. For that, navigate to the Manage Jenkins > Configure System menu, scroll down to the Maven section and click Add Maven.

image08

  1. Within the expanded section, type the desired name for your Maven installation (e.g. Maven) and Save the changes using the same-named button at the bottom of the page.

image21

In such a way, this tool will be also automatically installed when required (i.e. during the first app build).

Now your Jenkins server is well-staffed for the further work.

Add Deployment Process Scripts to the Jenkins Container

The next step is to upload the scripts that you are going to use for automating different organizational actions, required to be applied to your application at the intermediate development life cycle phases (like deploying, placing it to the appropriate hardware according to the stage, running auto-test, etc).

The easiest way to do this is to access your Jenkins container via the Jelastic SSH-gateway.

In the case you haven’t performed similar operations before, you need to:

  1. Once inside, create a new folder for your project (we’ll use demo) and move in there:

mkdir /opt/tomcat/demo

cd /opt/tomcat/demo

image05

This location can be used for storing your scripts, variables, logs etc.

  1. Here, you can upload the required scripts using the command of the following type:

curl -fsSL {link_to_script} -o {file_name}

We also provide the set of script examples, which can be used as templates for your own ones:

  • install.sh – gets a user session and creates a new environment via the Jelastic API according to the specified manifest file. It also defines, that the name of this environment will be equal to its creation date and time (as a unique name is required for every script execution, but you won’t be able to set it manually as this operation would be run automatically). However, you can set your own dynamic name pattern to be used here
  • migrate.sh – physically moves an environment to another hardware set (hardnode group)

Note: that before the appliance, each of the script templates, presented above, have to be additionally adjusted to make them work properly within a particular Jelastic installation. Thus, the list of parameters below should be obligatory substituted according to your platform’s settings:

  • /path/to/scripts/ – the full path to your scripts folder (created in the previous step)
  • {cloud_domain} – your Jelastic Platform domain name
  • {JCA_dashboard_appID} – your dashboard ID, that could be seen within the Platform.DASHBOARD_APPID parameter at the JCA > About section
  • {JCA_appstore_appID} – appstore ID, listed within the same section (at the Platform.APPSTORE_APPID parameter)
  • {url_to_manifest} – link to the manifest file created according to our documentation (you may also use this one as an example – it sets up two Tomcat application servers with the NGINX load-balancer in front of them)

image31

Note: Above you can see one more runtest.sh script uploaded – it simulates the testing activities for demonstration purposes, thus we don’t provide its code in this tutorial. If required, create your own one according the specifics of your application and upload it alongside the rest of the scripts.

  1. In addition, you need to create a separate file for storing the variable with environment name (as it needs to be dynamically changed each time a new environment is created):

echo ENV_NAME= > /opt/tomcat/demo/variables

image27

These are the main steps of preparation to achieve automatic continuous integration and delivery of your web application with a help of Jenkins within Jelastic Cloud platform. In the second part of these blog series, we’ll configure the set of jobs at the Jenkins server, which represents the core of our automation. Each of them will be devoted for a particular operation, required to be run at the corresponding application life cycle phase:

Create Environment > Build and Deploy > Dev Tests > Migrate to QA > QA Tests > Migrate to Production

Stay tuned to see the next steps. If you still don’t have Jelastic installation, contact us to get access to our free demo for cloud platform evaluation or just start with trial registration at one of our hosting partners.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Leave a Reply

Subscribe to get the latest updates