Tuesday, June 17, 2014

Binary deployment to OpenShift Using GIT








This post is third post in series of post related to OpenShift binary deployment. Part 1 and Part 2 are available.This is third and final part.



There are two ways to use GIT with OpenShift. Even when an external GIT repository is provided OpenShift creates one for the application and initializes it with external GIT. This is same as creating a local GIT repository and cloning it with a remote GIT repository.

1.       Create an application on OpenShift and select either the Tomcat 7 (JBoss EWS 2.0) cartridges.

2.       Use the git clone command to download the source code for your application to your computer.
                                       i.      $ git clone ssh://533bfd814382ec1fcf00015e@externalgit-everest.punin.sen.symantec.com/~/git/externalgit.git/
3.       Remove the src directory and the pom.xml file from your application that you cloned to your computer.
4.       Place any WAR files that you want to deploy on your gear inside of the webapps directory.
5.       Do $ git add –all your new files, then do a $ git commit -am "committing war file" to make sure that your changes are committed
6.       $ git push to push the changes to gear

Pros:
1.       We will take full advantage of OpenShift GIT application deployment lifecycle
2.       No source code in GIT, only deployable binary file
3.       Rollback support
4.       Deployment to scaled application supported out of the box
Cons:
1.       Some traces of GIT in development lifecycle
2.       Extra overhead of cloning and committing binary artifact in GIT repository
3.       Overhead in automating and maintaining this process

Use external GIT repository
1.       Create a GIT repository
$ git init project01
2.       Add following structure to it
.openshift/markers/java7
This marker file will tell OpenShift gear to use Java 7 runtime. If this file is not present gear will use Java 6 by default.
Additionally you can add following folders. This is optional.
.openshift/action_hooks/ - this will be used to write any pre, post or build hooks
.openshift/cron -  define cron jobs to be run on application gears
.openshift/config – this will contain tomcat config files. In case of custom tomcat settings these will be used.
3.       Create application with external GIT repository
$ rhc create-app --app externalGit --from-code https://github.com/rajeevbadgujar/project01.git --type jbossews-2.0
This will create a GIT repository for the application and clone it with external GIT
4.       Do a $ git clone https://github.com/rajeevbadgujar/project01.git to get a local copy of GIT repository
5.       To be able to commit to the application GIT repository, we have to add it as remote to local GIT repository
$ git remote add openshift -f
6.       Copy the war file to /webapps
7.       Do $ git add –all
8.       Commit war file to GIT repository
$ git commit –am “committing war file”
9.       To push changes to OpenShift GIT repository
$ git push openshift HEAD
10.   This will trigger the OpenShift deploy hook and war file is deployed and activated

Pros:
              Virtually no extra pros other than mentioned in previous approach
Cons:
1.       Extra overhead of maintain external GIT repository and syncing it with OpenShift GIT repository

These are various ways of deploying binary artifacts to OpenShift. 
In the next post I will summarize pros and cons of the approaches we discussed.


 

No comments:

Post a Comment