Introduction
OpenShift (or any other Platform as a Service (PaaS)) is based on one core principle, in that it should simplify the application life cycle management, including application scaling to help developers build their business applications faster. They all help developers achieve higher productivity by provisioning, managing, and scaling the infrastructure as well as application stack for them. It enables software developers to take their ideas, write code on the local machine, and then deploy the application to the cloud in minutes. PaaS can take you a long way without requiring much work by providing a good foundation to your next big business idea. PaaS can also help enforce best practices, such as continuous integration, in your application from inception. In addition, PaaS can also help you get quick feedback from the customer, and you can iterate faster.
OpenShift provides application developers all the services and tools required to develop and deploy their applications. Apps running on OpenShift can leverage their managed stack, and they do not require system admins to manage the underlying platform in order to keep their apps secure and reliable. OpenShift provides commands that can help application developers take backups of their applications periodically. To understand how application developers can take backups, refer to the Taking and restoring application backups recipe.
The rhc
command-line tool provides all the commands required to work with your application. To view all the application-related commands, open a command-line terminal and run the following command:
$ rhc app -h Usage: rhc app <action> Creates and controls an OpenShift application. To see the list of all applications use the rhc domain show command. Note that delete is not reversible and will stop your application and then remove the application and repo from the remote server. No local changes are made.
We will cover all these commands in this chapter, so stay tuned!
Every OpenShift application runs inside a gear, which is a container built using SELinux, Control Groups, and pam_namespace Linux technologies. Let's look at all these technologies one by one:
- SELinux:SELinux (Security Enhanced Linux) is a Linux kernel security module originally developed by the United States National Security Agency. OpenShift uses SELinux to achieve gear isolation and a hardened security layer around gears. This limits application gears from accessing parts of the system they should not access, such as the lower-level system and other application gears running on the same node. In a multitenant environment, such as OpenShift, this behavior is very important to ensure security and reliability when running multiple applications on the same infrastructure.
- Control Groups: OpenShift uses Control Groups (cgroups), a Linux kernel feature, to allocate resources such as CPU time, memory, bandwidth, or a combination of these resources among process groups. The amount of RAM and disk space a gear is allocated depends on the gear size. In the free tier, you only have access to small gears, which have 512 MB RAM and 1 GB of disk space. We will look at gear size in the Creating an OpenShift application using the rhc command-line client recipe.
- pam_namespace: pam_namespace is used to allow each user or session to maintain its own namespace for directory structures, keeping them from being able to view or impede upon each other's namespace. By using this, OpenShift is able to provide the
/tmp
directory to each gear.
A gear runs different software components (or cartridges) for your application. A cartridge is what makes a gear useful, that is, it provides the software components that an application might need. Every OpenShift application requires one web cartridge and can have zero or more add-on and downloadable cartridges. There are three types of cartridges:
- Web cartridge: These are used to serve web requests. You can't create an OpenShift application without a web cartridge. You have to specify the web cartridge at application creation time. They are available for Java, PHP, Python, Ruby, Node.js, and Perl, where you can list all the web cartridges by running the following command:
$ rhc cartridges|grep web jbossas-7 JBoss Application Server 7 web jbosseap-6 (*) JBoss Enterprise Application Platform 6 web jenkins-1 Jenkins Server web nodejs-0.10 Node.js 0.10 web nodejs-0.6 Node.js 0.6 web perl-5.10 Perl 5.10 web php-5.3 PHP 5.3 web zend-5.6 PHP 5.3 with Zend Server 5.6 web php-5.4 PHP 5.4 web zend-6.1 PHP 5.4 with Zend Server 6.1 web python-2.6 Python 2.6 web python-2.7 Python 2.7 web python-3.3 Python 3.3 web ruby-1.8 Ruby 1.8 web ruby-1.9 Ruby 1.9 web jbossews-1.0 Tomcat 6 (JBoss EWS 1.0) web jbossews-2.0 Tomcat 7 (JBoss EWS 2.0) web diy-0.1 Do-It-Yourself 0.1 web
- Add-on cartridge: These are additional cartridges provided by OpenShift. You can add them depending on your requirement, that is, if you need a database in your application, you will need to add the MySQL, PostgreSQL, or MongoDB add-on cartridge. You can list all the add-on cartridges by running the following command:
$ rhc cartridges|grep addon 10gen-mms-agent-0.1 10gen Mongo Monitoring Service Agent addon cron-1.4 Cron 1.4 addon jenkins-client-1 Jenkins Client addon mongodb-2.2 MongoDB 2.2 addon mysql-5.1 MySQL 5.1 addon mysql-5.5 MySQL 5.5 addon metrics-0.1 OpenShift Metrics 0.1 addon phpmyadmin-4 phpMyAdmin 4.0 addon postgresql-8.4 PostgreSQL 8.4 addon postgresql-9.2 PostgreSQL 9.2 addon rockmongo-1.1 RockMongo 1.1 addon switchyard-0 SwitchYard 0.8.0 addon haproxy-1.4 Web Load Balancer addon
- Downloadable cartridge: This enables developers to write their own cartridges. They can write their own cartridges and make them available via a public Git repository. These can then be installed using the rhc add-cartridge command. We will cover these in the Using downloadable cartridges with OpenShift applications recipe in this chapter.
Every OpenShift application has at least a private Git repository and web cartridge. It may have zero or more add-on cartridges, with the possibility of zero or more downloadable cartridges. An OpenShift application has built-in support for the Git version control system, automated dependency management, persistent data directory for file upload or storing other files, and deployment rollback.
An application can be a scalable or nonscalable application. A scalable application runs on multiple gears and scales horizontally depending on the number of concurrent users. We will look at scalable applications in runs inside a single gear, and all the cartridges are added to that gear. These are good for development purposes, but for production, high-traffic applications, you should consider scalable applications.