All Linux HowTo's

Working with OpenShift on the CLI (Users and Admin)

This article demonstrates how to add applications, gears and cartridges to your OpenShift account using the command line tool. It’s from the point of view of both the OpenShift subscriber and the administrator. I’m sure those who are new to OpenShift will find this useful.

Some Definitions

  • Applications: An application is made up of resources, server software, and your code base. You must create your application prior to adding resources, etc. You can have many applications within your single OpenShift account.
  • Gears: A gear is associated with an application. It’s a reserved grouping of resources. Memory, CPU and Disk space are reserved for each gear. You can and likely will have several gears. The amount of resources varies between gear sizes and OpenShift servers.
  • Cartridges: A cartridge is server software such as MySQL or PHP. A cartridge fits into a gear giving it resources. In a non-scalable application, many cartridges fit into a single gear until the resources no longer allow more. In a scalable application, each cartridge has it’s own gear.

And some helpful diagrams to assist with the above definitions. The right is a non-scalable application with a single gear. The left is scalable and has multiple gears.


Install User Tools

First you need to install the RHC tool. Instructions for several platforms can be found here:

I’ve gone with the OSX version as i’m using a Mac. So i need to run:

sudo gem install rhc

The above command cane take a few minutes. Having completed that stage we must set up RHC. It’s as easy as running the following and answering the questions.

TIP: If you have an SSH key on your workstation, RHC will take your ‘.pub’ file and upload it to allow you to easily reconnect safely later. Yes, it uses SSH.

rhc setup

During the process you will be asked for important information, such as:

  • Your SSH public key. It will help if you have one. You can add it later if you like. It will look for your public key in ‘~/.ssh/’.
  • Your desired name-space. This will be included in your hostnames such as Chose something meaningful to you. This can be changed later but it’s best to get it right at the start.
  • Your OpenShift username. This is the username your OpenShift administrator gave to you along with your password.

User Commands

Now we can use the RHC command. Here are a few key commands to get you started:

We’re going to create 2 apps. The first will not be scalable while the second will be scalable. Both will have php-5.4 and (at some stage) mysql-5.5. We’ll add and remove cartridges and even a gear at the end. You can see the state of your applications, gears and cartridges by issuing the ‘rhc apps’ command.

To list your applications:

rhc apps

To get a list of the available cartridges on the OpenShift server:

rhc cartridge list

To create a non-scaling application (with php-5.4):

rhc app create myphpapp1 php-5.4

To create a scaling application (with php-5.4 and mysql-5.5):

rhc app create -s myphpapp2 php-5.4 mysql-5.5

To see details of my apps one at a time:

rhc show-app myphpapp2

To add a gear to your existing application:

rhc cartridge add mysql-5.5 --app myphpapp1

To remove a cartridge from your existing application:

rhc cartridge remove mysql-5.5 --app myphpapp1

To remove a gear from your existing application:

rhc cartridge remove mysql-5.5 --app myphpapp1

Administrative Commands

These commands can be used by the administrator to set and change user resource quotas.

Set the default disk quota for all new users by editing the “/etc/openshift/resource_limits.conf”. This is effective only before users are created:

# Disk storage quota 1GB (the default)

Set the max number of gears for all new users in “/etc/openshift/resource_limits.conf”. This is effective only before users are created:

# Max active gears at a given time

To change a current users disk quota to 10 GB per gear:

oo-admin-ctl-user -l sally --setmaxtrackedstorage 10

To change a current users max-gears quota to 20:

oo-admin-ctl-user -l sally --setmaxgears 20

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.