Customize Your Cartridge and Achieve Support for Both Jelastic and OpenShift Platforms

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


Last time we focused on the goals and specifications of the cartridge standard usage in Jelastic’s Cloud. This is devoted to more technical details of this implementation. We are going to talk about how we adopt technology created by OpenShift, the specifics of creation, testing and implementation of the cartridges standardized for both clouds (Jelastic and OpenShift).

So here you’ll find out how to:

  • create cartridge supported in Jelastic
  • make cartridges available for users
  • install a cartridge in the cloud environment
Note that cartridge usage will be fully available starting with the next Jelastic release (2.2).

Create a Cartridge for Jelastic

To access the cartridges which can be installed in the Jelastic Cloud, you need to make additional configurations to standard OpenShift cartridges. Using this instruction, you will easily compile the needed cartridge package and make it available for your users.

So our cartridge consists of two parts:

  • A basic OpenShift cartridge
  • Jelastic configurations
You can use cartridges already prepared and tested by Jelastic. Such cartridges can be uploaded from the template repository.

Basic OpenShift Cartridge

Before creating your own cartridge, you should search the current list of Red Hat and OpenShift Community provided cartridges.

If the required cartridge is not provided in the list of existing cartridges, you can create your own using this Cartridge Developer’s Guide.

Jelastic Configurations

When you have your cartridge packed (or simply used an existing one) you need to add a jelastic directory to its content to make this cartridge appropriate for using in the Jelastic Cloud.

This directory should have the following structure:


  • icons
    • logo_16x16.png
    • logo_32x32.png
    • logo_64x64.png
  • scripts
  • configuration_manager_resources.conf
  • jelastic.conf

Let’s look through each component step-by-step.


This subdirectory should contain three logos of cartridges that will be displayed:

  • in JCA after adding the cartridge to the list


  • at the dashboard in the Environment topology


  • at the dashboard after adding this cartridge to the environment


Note: these logos should have transparent backgrounds and be the following sizes:

  • 16×16
  • 32×32
  • 64×64


Currently this directory contains three scripts:

  • is responsible for the function of password resetting;
  • implements deploy and undeploy functionality for applications;
  • is responsible for optimizing application’s configuration files for best performance based on the available system resources inside a container (amount of cloudlets stated for it).

1. The file should include function _setPassword description which implements the functionality for setting/resetting predefined system variables.

Here you can operate with the following parameters:

    This parameter is used for stating username.
    The value for this parameter is taken from Admin_App_User in the jelastic.conf file

    This parameter is used for providing randomly chosen password. The value is generated by Jelastic Core.

Here is the example of the script for Cassandra:


SED=$(which sed);
GREP=$(which grep);

# This is an example of reset password hook in Jelastic

#$J_OPENSHIFT_APP_ADM_USER        ;   Operate this variable for the username
#$J_OPENSHIFT_APP_ADM_PASSWORD    ;   Use this varible for your password

function _setPassword() {

        echo ALTER USER cassandra WITH PASSWORD \'$J_OPENSHIFT_APP_ADM_PASSWORD\'\; > $new_passwd_file;
        echo UPDATE system_auth.credentials set salted_hash=\'\$2a\$10\$vbfmLdkQdUz3Rmw.fF7Ygu6GuphqHndpJKTvElqAciUJ4SZ3pwquu\' where username=\'cassandra\'\; > $old_passwd_file;


        # Init data is needed for password auth
        $SED -i 's/authenticator: org.apache.cassandra.auth.AllowAllAuthenticator/authenticator: org.apache.cassandra.auth.PasswordAuthenticator/g'     $cassanra_conf;
        service cartridge restart > /dev/null 2>&1;

        while netstat -lnt | awk '$4 ~/:'"${OPENSHIFT_CASSANDRA_DB_PORT}"'$/ {exit 1}'; do sleep 1; done;
        sleep 10;
        $SED -i 's/authenticator: org.apache.cassandra.auth.PasswordAuthenticator/authenticator: org.apache.cassandra.auth.AllowAllAuthenticator/g'     $cassanra_conf;
        service cartridge restart > /dev/null 2>&1;
        while netstat -lnt | awk '$4 ~/:'"${OPENSHIFT_CASSANDRA_DB_PORT}"'$/ {exit 1}'; do sleep 1; done;
        [ -f "$old_passwd_file" ] && $cqlsh_app  --file $old_passwd_file;
        $SED -i 's/authenticator: org.apache.cassandra.auth.AllowAllAuthenticator/authenticator: org.apache.cassandra.auth.PasswordAuthenticator/g'     $cassanra_conf;
        service cartridge restart > /dev/null 2>&1;
        while netstat -lnt | awk '$4 ~/:'"${OPENSHIFT_CASSANDRA_DB_PORT}"'$/ {exit 1}'; do sleep 1; done;
        [ -f "$new_passwd_file" ] && $cqlsh_app -u $J_OPENSHIFT_APP_ADM_USER -p "cassandra"  --file $new_passwd_file;

2. The script is obligatory only for compute node  cartridges (with application server). It should include _deploy() and _undeploy() functions (just implemented, not called). The first one performs the deployment procedure for compute node, and the second one, respectively, performs the undeployment procedure.

While preparing this script, you can also use all available OpenShift’s environment variables that are applied in cartridge configurations and usually starts with an “OPENSHIFT_” prefix.

Here is the example of the script for JBoss7:


# Simple deploy and undeploy scenarios for JBoss 7

WGET=$(which wget);

function _deploy(){
     [ "x${context}" == "xroot" ] && context="ROOT";
     [ -f "${WEBROOT}/${context}.war" ] && { rm -f "${WEBROOT}/${context}.war"; rm -f "${WEBROOT}/${context}.war.*" ; };
     $WGET --no-check-certificate --content-disposition -O "${WEBROOT}/${context}.war" "$package_url";

function _undeploy(){
     [ "x${context}" == "xroot" ] && context="ROOT";
     [ -f "${WEBROOT}/${context}.war" ] && { rm -f "${WEBROOT}/${context}.war"; rm -f "${WEBROOT}/${context}.war.*" ; };

3. The script is not mandatory but strongly recommended. Without this script, the cartridge will be still functional, but its performance will not depend on the amount of cloudlets (resources) stated.

This script may be written in any programming language, which can be interpreted by a Jelastic container, namely: BASH, SED, AWK, Perl, Python. You can also use any other language, but in this case, you have to install your interpreter by specifying an appropriate RPM package name in the Native_Requires parameter of jelastic.conf file (described in the separate section below).

Here is the example of the script for Jetty8:


SED=$(which sed);

# config optimizer for Jetty8


[ -z "$XMS" ] && { XMS=32; }
memory_total=`free -m | grep Mem | awk '{print $2}'`;
[ -z "$XMX" ] && { let XMX=memory_total-35; }

$SED -i "s/-Xms[0-9]*m/-Xms${XMS}m/g" $JETTY_START_SCRIPT;
$SED -i "s/-Xmx[0-9]*m/-Xmx${XMX}m/g" $JETTY_START_SCRIPT;


The configuration_manager_resources.conf file should contain the path to the folders or files in your cartridge which are going to be displayed in the Jelastic dashboard while opening the Config option.


This file should have the following structure:



keyword – name of the resources group that will be displayed in the configuration manager;
versions/{version_number}/{folder_name} – full path to the folder from the root of cartridge.

Folders, specified under each of keywords, will be shown inside the appropriate directories with all their content. So, if you want to just open separate folders for users, but not all of them, then specify the paths to the particular folders.

For example, if configuration_manager_resources.conf file for Jetty 9 cartridge looks like following:


You will get the next folder’s structure displayed at the dashboard:


In such a way, all the configuration files, libraries, modules, etc, can be easily grouped into the separate directories with corresponding names.


The jelastic.conf file should include the following parameters:

  • Node_Mission

Here you need to specify where to place your cartridge in the Environment topology.

node id table

For example:


  • Engine_Type

Here, specify the main engine which is used for your cartridge.

For example:


  • Native_Requires

If you need to upload any packages from the official repo for appropriate performance of your cartridge, you just need to enumerate them, comma delimited here.

For example:


  • App_User

The value of this parameter is the same for all cartridges:


  • Admin_App_User

The value of this parameter will be used as a login to admin panel of the cartridge (it will be the same for all users).

For example:


  • Node_Type

Using this parameter, you can specify the name of your cartridge. In such a way, this cartridge will be signed in JCA and dashboard.

For example:


  • Webroot_Path

This parameter is obligatory for compute node cartridges (with application server) only. Its value defines the default location (folder), where the deployed to cartridge application package will be placed.

For example:


Add a Cartridge to the Cloud

Already created cartridges can be added to the Jelastic Cloud via JCA.

1. Navigate to JCA > Templates > Cartridges.


2. Add cartridge by specifying the URL to manifest file.


To get the URL of the required manifest:

  • open the required cartridge in the Template repository
  • navigate to the metadata folder
  • open manifest.yml file (make sure it is in Raw mode)


  • copy the link of the opened page
  • paste this link to the Add Cartridge window in JCA

In such a way you can add all the needed cartridges.

3. As a result, new cartridges will be added to the list with specified Name and logo, Version and Manifest URL.


4. Also, these cartridges will appear in the Templates list with information about their number In pool and In queue, Node Mission (the one you stated in jelastic.conf file) and Published status.


5. A newly added cartridge is not published by default. You can check its performance before providing it to your users.

Use the Preview option right from JCA in order to view added cartridges in your own dashboard:

Navigate to the Templates section and select the Preview button (or Open in popup).


A new tab (or popup) with your dashboard will be opened. All the templates listed in JCA will be available in the appropriate tabs and sections of the environment topology wizard.

6. When you are ready to make any cartridge available for users, you need to publish it.

  • Navigate to the Templates section, find the necessary cartridge and select the Publish button.


  • After that, the chosen cartridge will appear at the dashboards for all users.


7. In the same way you can Unpublish the cartridge if it is no longer necessary.

Install a Cartridge in Jelastic Cloud

Now, when the required cartridges are added, you can proceed to their installation in your Jelastic environment:

1. Go to the Jelastic dashboard and create an environment with the required cartridge.

Note that a cartridge can be located among app servers or databases, together with Memcached, balancer or VDS depending on the Node Mission stated while preparing a cartridge source.


As a result you’ll get a usual Jelastic environment and can proceed to deploying your app.


In this way, you can integrate various middleware, databases, and services into Jelastic with no need to repackage your technology for different cloud platforms. As a result, a much wider range of technologies can be easily added to the cloud and become available to PaaS users and developers. No need for additional coding! You can use both Jelastic and OpenShift platforms without any entry restrictions.

Stay tuned to try this out soon! Jelastic cartridge support will be available for all users in our  next release (2.2). Create your own cartridges, use already prepared, configure more complex functionality – with Jelastic you always get more!

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

Leave a Reply

Subscribe to get the latest updates