-
Notifications
You must be signed in to change notification settings - Fork 0
OpenShift
Deployment instructions for OpenShift by RedHat
OpenShift provides a free tier, making it a good place to start your PaaS journey!
- Create an OpenShift account.
- Install the RHC command line tool.
- OpenShift uses Git to push applications, so you'll need that too.
The following steps will create the services we need; a Java web server and MongoDB. It will also create a default application that we will later replace with our own Notes! application.
Execute the following commands from the command line:
-
rhc setup
to connect to OpenShift and setup the tooling. Pick your own "domain" when requested, this will be part of the application's URI and must be globally unique. - Create the directory where you want your local git repo created for pushing to OpenShift PaaS:
mkdir /home/<user>/project/openshift
- Change directory:
cd /home/<user>/project/openshift/
-
rhc create-app -a notes -t jbossews-2.0
to create the application with a Tomcat 7 web cartridge. This will also create a local Git repo in anotes
directory. You will be prompted to provide the password to your key as part of this step. This can take some time, be patient. -
rhc add-cartridge -c mongodb-2.4 -a notes
to add the MongoDB service. Again, this could take some time. -
rhc app show notes
to see some info about the created application and services. This will give you an http URL to the application, try it out in your favorite browser now!
Allright, the services are up and running! Now it is time to deploy our app. In open shift you do this by pushing the app to the remote Git repo created for you on OpenShift. OpenShift is capable of building some types of applications for you, but below we will deploy the ready packaged app.
If you look into the notes
directory created for you in the previous step, you'll see a clone of the Git repo containing the OpenShift default application. Will call this directory <notes-os>
from now on.
Build and package the application.
To deploy our application on OpenShift, do the following:
- Copy our
ROOT.war
from above to<notes-os>/webapps
, overwriting the default war file already there. - Delete the file
<notes-os>/pom.xml
:git rm pom.xml
. - Delete the directory
<notes-os>/src
and its contents:git rm -r src
. - Stage the new (modified)
ROOT.war
file:git add .
. - Commit:
git commit -m 'Deploying Notes'
. - Deploy:
git push
.
At this point the application will be uploaded and the services restarted, watch console output to track progress.
BOOM! And you're done!
Reload the page in your web browser to view the application, and then, take some notes.
For further details of the platform, see the OpenShift User Guide.
- Use
rhc ssh
to log into the app and look around. - Recreate the application as a scaled app. Watch how the gear distribution is different.
- Create some load (be nice!), and see the application scale. Watch the HAProxy status page:
http://<your-app-name>.rhcloud.com/haproxy-status/
. You should also see the Node name change at the bottom of the Notes web GUI. - Try the built-in rollback mechanism, making it possible to quickly rollback a bad release.
- Enable support for Jenkins if deploying the Java version of Notes.
- Try a couple of builds (some good, some bad) using the Java version of Notes (building Clojure apps are not supported out of the box) and see how that works.
- Go to the OpenShift Marketplace, get and configure the New Relic add-on to see live metrics of your app. Get things to work requires jumping through some hopes, inspiration for the final magic setup steps can be found here and here.