How to Manage Apps in the Cloud with RHC - Archived

Lots of Tools to Manage Your Cloud Application

OpenShift provides different developer tools for the cloud so they can better manage their applications on a PaaS:

  • Web Console – Quickly create an app from any browser
  • IDE – Seamless integration with the Eclipse development platform
  • Command Line – Full control of your applications and code on any platform

The Command Line tools named rhc (stands for “Red Hat Cloud”) is what I’m going to talk about in this post.## Lots of Tools to Manage Your Cloud Application
OpenShift provides different developer tools for the cloud so they can better manage their applications on a PaaS:

  • Web Console – Quickly create an app from any browser
  • IDE – Seamless integration with the Eclipse development platform
  • Command Line – Full control of your applications and code on any platform

The Command Line tools named rhc (stands for “Red Hat Cloud”) is what I’m going to talk about in this post.
Even if you are already familiar with rhc, keep reading because we’ve made some improvements.

Get the rhc tools free and easy

After you’ve signed up for your free OpenShift account and installed the RHC Command Line Tool via gem install rhc, you are ready to go.

The rhc tools work on your OS of choice, be it Linux, Windows or OSX.

What can rhc do for me?

Let’s see what the latest rhc can do for you:

$ rhc
Usage: rhc [--help] [--version] [--debug] <command> [<args>]
 
Command line interface for OpenShift.
 
Getting started:
  setup              Connects to OpenShift and sets up your keys and domain
  app create         Create an application
  apps               List all your applications
  cartridge list     List available cartridges
  cartridge add      Add a cartridge to your application
  server             Display information about the status of the OpenShift service.
 
Working with apps:
  app restart        Restart the application
  app show           Show information about an application
  tail               Tail the logs of an application
  port-forward       Forward remote ports to the workstation
  threaddump         Trigger a thread dump for JBoss and Ruby applications.
  snapshot           Save the current state of your application locally
  git-clone          Clone and configure an application's repository locally
 
Management commands:
  account            Display details about your OpenShift account
  alias              Add or remove a custom domain name for the application
  app                Commands for creating and managing applications
  cartridge          Manage your application cartridges
  domain             Manage the domain and namespace for your applications.
  sshkey             Manage multiple keys for the registered rhcloud user.
 
See 'rhc help <command>' for more information on a specific command.  See 'rhc help options' for a list of global command-line options and information about the config file.

Quite a lot of features, right? That’s why we called that “full control”.

Of course, you can read this detailed User Guide for the official documentation of rhc features.

And rhc help will explain any command you want to know in a terminal.

Current users may have found that most commands here are quite similar. But here, I’m thrilled to introduce several important features and changes!

rhc automatically configures your environment

If you’ve never used rhc, all the necessary configurations can be done by:

$ rhc setup

That’s the only setup you need to do before creating your app.

Assume that we want to create a new online Q&A system like stackoverflow.com which contains:

As you may be familiar already, we could finish the above tasks with several commands:

$ rhc app create osqa python-2.6
$ rhc cartridge add osqa mysql-5.1
$ rhc cartridge add osqa phpmyadmin-3.4
$ cd osqa
$ git remote add upstream -m master git://github.com/openshift/OSQA-openshift-quickstart.git
$ git pull -s recursive -X theirs upstream master
$ git push

This application can also be created with a single command: rhc app create:

$ rhc app create osqa python-2.6 mysql-5.1 phpmyadmin-3.4 --from-code=git://github.com/openshift/OSQA-openshift-quickstart.git

rhc gives detailed git output during the creation. (The actual output is nicer because syntax highlighting is in color.
After a minute, a brand new OSQA app is running with the exact database and configuration!

See? How many commands have we typed before going from nothing to running a full functional + customized web app?

[sudo] gem install rhc
rhc setup
rhc app create <app_name> <cartridges> --from-code=<git_url>

Only 3!
And 1 command will be enough if you wanna create another app.

Get the details on your app with ‘rhc apps’

Whenever you need the details of your apps, try rhc apps. It’s like the previous rhc domain show command, but better:

$ rhc apps
osqa @ http://osqa-paasdragon.rhcloud.com/ (uuid: 7e22ca7aef0149a19eb8e624b3bafaa0)
-----------------------------------------------------------------------------------
  Created:         10:20 AM
  Gears:           1 (defaults to small)
  Git URL:         ssh://7e22ca7aef0149a19eb8e624b3bafaa0@osqa-paasdragon.rhcloud.com/~/git/osqa.git/
  Initial Git URL: git://github.com/openshift/OSQA-openshift-quickstart.git
  SSH:             7e22ca7aef0149a19eb8e624b3bafaa0@osqa-paasdragon.rhcloud.com
 
  python-2.6 (Python 2.6)
  -----------------------
    Gears: Located with mysql-5.1, phpmyadmin-3.4
 
  mysql-5.1 (MySQL Database 5.1)
  ------------------------------
    Gears:          Located with python-2.6, phpmyadmin-3.4
    Connection URL: mysql://127.4.98.1:3306/
    Database Name:  osqa
    Password:       cannot_tell_ya
    Username:       admin
 
  phpmyadmin-3.4 (phpMyAdmin 3.4)
  -------------------------------
    Gears:          Located with python-2.6, mysql-5.1
    Connection URL: https://osqa-paasdragon.rhcloud.com/phpmyadmin/
    Password:       cannot_tell_ya
    Username:       admin
 
You have 1 application

And also, you can now get a briefing of your account by rhc account:

$ rhc account
Login:              paas-dragon@redhat.com
Plan:               FreeShift
Gears Used:         1
Gears Allowed:      3
Allowed Gear Sizes: small

Well, we do have many other cool new stuff for rhc. Just go ahead and try them for yourself!

rhc tools are always improving

Before saying goodbye, I want to mention that rhc tools are being improved and optimized every week.

For example, when you wanna access your app now, just run rhc app ssh.
You don’t have to copy and paste the SSH URL and run ssh 7e22ca7aef0149a19eb8e624b3bafaa0@osqa-paasdragon.rhcloud.com like before.

Working with the latest RHC will always give you the best experience. All it takes to do that is:

$ gem update rhc

What’s Next?

Categories
Python
Tags
,
Comments are closed.