Tutorial: Getting to grips with OpenShift
Tired of requesting a new development machine for your application? Sick of setting up a new test environment? Have no fear OpenShift is here!
This article will walk you through the simple steps it takes to set up OpenShift. In minutes you will be off and back to focusing on your application development, deploying to test it in OpenShift. When finished you will just discard your test machine and move on. After this you will be fully capable of ascending into the OpenShift Cloud when you chose, where you need it and at a moments notice. This is how development is supposed to be, development without stack distractions.ornia, providing solutions to enable organizations to deploy, manage, monitor and scale their applications on both private or public clouds. Red Hat acquired Makara in November of 2010, and in the following year they merged Red Hat technologies into a new project called OpenShift.
Just recently the OpenShift team has announced the launch of their Open Source project called OpenShift Origin, making the entire code base available online. You can even take it for a spin with the liveCD they offer, but this is outside the scope of this article. What makes this merging of technologies interesting for a Java developer is that Red Hat has included the next generation application platform based on JBoss AS 7 in OpenShift. This brings a lightning fast application platform for all your development needs.
OpenShift
The OpenShift website states, “OpenShift is a free, cloud-based application platform for Java, Perl, PHP, Python, and Ruby applications. It’s super-simple—your development environment is also your deployment environment: and you’re in the cloud.” This piques the interest so lets give it a try and see if we can raise our web application into the clouds. For this we have our jBPM Migration web application which we will use as a running example for the rest of this exercise.
Getting started in OpenShift is well documented on the website as a quick start, their things to get an OpenShift instance setup for hosting our Java application, beginning with a domain.
# We need to create the domain for OpenShift access) (required) -p|–password password RHLogin password (optional, will prompt) -a|–alter Alter namespace (will change urls) and/or ssh key -d|–debug Print Debug info -h|–help Show Usage info
# So we setup one for our Java application. Note that we already have # setup my ssh keys for OpenShift, if you have not yet done that, # then it will walk you through it. #
$ rhc-create-domain -n inthe -l [rhcloud-user] -p [mypassword]
OpenShift key found at /home/[homedir]/.ssh/libra_id_rsa. Reusing…
Contacting
Creation successful
You may now create an application. Please make note of your local config file in /home/[homedir]/.openshift which has been created and populated for you.
Create your application
Next we want to create our application, which means we want to tell OpenShift which stack we need. This is done with the rhc-create-app client tool.
# Let’s take a look at the options available before we setup a Java # instance for our application. #
$ rhc-create-app –help
Contacting to obtain list of cartridges… (please excuse the delay)
Usage: /usr/bin/rhc-create-app Create an OpenShift app.
-a|–app application Application name (alphanumeric – max 16 chars) (required) -t|–type type Type of app to create (perl-5.10, jbossas-7.0, wsgi-3.2, rack-1.1, php-5.3) (require) -l|–rhlogin rhlogin Red Hat login (RHN or OpenShift login)  jboss-as7.0 # stack (called a cartridge). Provide a user, password and location # for the git repo to be created called ‘j ‘jbpmmigration-inthe.rhcloud.com,50.17.167.44′  ‘git push’ to update your OpenShift Openshift
Conclusion
As you can see, it is really easy to get started with the five free instances you have to play with for your application development.
This completes our tour of the OpenShift project where we provided you with a glimpse of the possibilities that await you and your applications. It was a breeze to create your domain, define your applications needs and import your project into the provided git project. After pushing your changes to the new instance you are off and testing your application development in the cloud. This is real. This is easy. Now get out there and raise your code above the cloud hype.