Implementing OpenShift — Save 50%
A fast-paced, practical guide for using OpenShift to deploy your own open source Platform-as-a-Service with this book and ebook
The article by Adam Miller, the author of Implementing OpenShift, covers all the different ways for WebDevs to consume OpenShift using different approaches. We will explore the command-line utilities, the OpenShift web console (including an overview of what OpenShift calls "Quickstart Applications"), as well as IDE integrations, where we walk through using JBoss dev tools that is based on the very popular Eclipse IDE (http://www.eclipse.org/).
The following are the three common ways in which we can utilize OpenShift as a user:
- Command-line utilities
- Web Console
- IDE integration
(For more resources related to this topic, see here.)
Each of these utilize the OpenShift REST API at the backend; therefore, as a user, we could potentially orchestrate OpenShift using the API with such common command-line utilities as curl to write scripts for automation. We could also use the API to write our own custom user interface, if we had the desire. In the following sections, we will explore using each of the currently supported user experiences, all of which can be intermixed as they communicate with the backend in a uniform fashion using the REST API previously mentioned.
Getting started using OpenShift
As discussed previously, we will be using the OpenShift Online free hosted service for example portions. OpenShift Online has the lowest barrier of entry from a user's perspective because we will not have to deploy our own OpenShift PaaS before being able to utilize it. Since we will be using the OpenShift Online service, the very ﬁrst step is going to be to visit their website and sign up for a free account via https://openshift.redhat.com/app/account/new.
New Account Form
Once this step is complete, we will ﬁnd an e-mail in our inbox that was provided during sign up, with a subject line similar to Conﬁrm your Red Hat OpenShift account; inside that e-mail will be a URL that needs to be followed to complete the setup and veriﬁcation step. Now that we've successfully completed the sign up phase, let's move on to exploring the different ways in which we can use and interact with OpenShift.
Due to the advancements in modern computing and the advent of mobile devices such as tablets, smart phones, and many other devices, we are often accustomed to Graphical User Interface (GUI) over Command-Line Interface (CLI) for most of our computing needs. This trend is heavier in the realm of web applications because of the rich visual experiences that can be delivered using next generation web technologies. However, those of us who are in the development and system administration circles of the world are no strangers to the CLI, and we know that it is often the most powerful way to accomplish an array of tasks pertaining to development and administration. Much of this is a credit to powerful shell environments that have their roots in traditional UNIX environments; popular examples of these are bash and zsh. Also, in more recent years, PowerShell for the Microsoft Windows platform has aimed to provide some relatively similar CLI power.
The shell, as it is referenced here, is that of a UNIX shell, which is a command interpreter that supports such features as variables, functions, pipes, I/O redirection, variable substitution, flow control, conditionals, the ability to be scripted, and more. There is also a POSIX standard for a shell that defines a standard set of features and behaviors that must be complied with, allowing for portability of complex scripts.
With this inherent power at the ﬁngertips of the person who wields the command line, the development team of the OpenShift PaaS has written a command-line utility, much in the spirit of offering powerful utilities to its users and developers. Before we get too deep into the details, let's quickly look at what a normal application creation and deployment requires in OpenShift using the following command:
$ rhc app create myawesomewebapp ruby-1.9 $ cd myawesomewebapp (Write, create, and implement code changes) $ git commit -a -m "wrote awesome code" $ git push
It will be discussed at length shortly, but for a quick rundown, the rhc app create myawesomewebapp ruby-1.9 command creates an application, which runs on OpenShift using ruby-1.9 as the programming platform. Behind the scenes, it's provisioning space, resources, and configuring services for us. It also creates a git repository that is then cloned locally—in our example named myawesomewebapp—and in order to access this, we need to change directories into the git repository. That is precisely what the next command cd myawesomewebapp does.
And you're live, running your web application in the cloud. While this is an extremely high-level overview and there are some prerequisites necessary, normal use of OpenShift is that easy. In the following section, we will discuss at length all the steps necessary to launch a live application in OpenShift Online using the rhc command-line utility and git.
This command-line utility, rhc, is written in the Ruby programming language and is distributed as a RubyGem (https://rubygems.org/). This is the recommended method of installation for Ruby modules, libraries, and utilities due to the platform-independent nature of Ruby and the ease of distribution of gems.
The rhc command-line utility is also available using the native package management for both Fedora and Red Hat Enterprise Linux (via the EPEL repository, available at https://fedoraproject.org/wiki/EPEL) by running the yum install rubygem-rhc command.
Another noteworthy proponent of RubyGems is that they can be installed to a user's home directory within their local machine's operating system, allowing them to be utilized even in environments where systems are centrally managed by an IT department. RubyGems are also installed using the gem package manager for users of GNU/Linux package managers, such as yum, apt-get, and pacman or Mac OS X's community homebrew (brew) package manager, which will be familiar with the concept. For those unfamiliar with these concepts, a package manager will track a software named "package" and its dependencies, handle installation, updates, as well as removal. We will take a short moment to tangent into the topic of RubyGems before moving on to the command-line utility for OpenShift to ensure that we don't leave out any background information.
Hopefully, we can select our preferred method of deploying on OpenShift, and developers of all backgrounds, preferences, and development platforms will feel at home working with OpenShift as a development and deployment platform.
Resources for Article:
|A fast-paced, practical guide for using OpenShift to deploy your own open source Platform-as-a-Service with this book and ebook|
eBook Price: $14.99
Book Price: $29.99
About the Author :
Adam Miller is currently employed at Red Hat Inc. as the Release Engineer for OpenShift Online, Red Hat's auto-scaling Platform-as-a-Service (PaaS) for applications. Adam has completed Bachelor's of Science in Computer Science and Master's of Science in Information Assurance and Security, both from the Sam Houston State University. He is a Red Hat Certified Engineer (Cert# 110-008-810), and is an active member of the open source community with a running history of contributions to the Fedora Project (FAS account name: maxamillion).