Exercise 1.2 - Deploy OpenShift

Return to Workshop

openshift ocp

OpenShift v3 is a layered system designed to expose underlying Docker-formatted container image and Kubernetes concepts as accurately as possible, with a focus on easy composition of applications by a developer. For example, install Ruby, push code, and add MySQL.


Step 1:

Use the oc command

These instances have been preconfigured with docker and the oc command. The oc command makes deploying OpenShift for development purposes incredibly easy. The oc cluster up command starts a OpenShift all-in-one cluster with a configured registry, router, image streams, and default templates.

switch to root
sudo -i
make a /data dir
mkdir /data

Next use the following command to bring up the cluster on your local machine.

But first! export your student number to sync up with the wildcard DNS mapped to your instance. For example below, if you are student 0 then export STUDENT=0.

Change the number to your student number
export STUDENT=0
Run the oc command (you can cut & paste this)
oc cluster up --public-hostname=$(curl -s --routing-suffix=apps.ose.$STUDENT.redhatgov.io --host-pv-dir=/data--host-data-dir=/data  --image=registry.access.redhat.com/openshift3/ose --version=v3.5
Successful Build (example)
-- Login to server ... OK
-- Creating initial project "myproject" ... OK
-- Removing temporary directory ... OK
-- Checking container networking ... OK
-- Server Information ...
   OpenShift server started.
   The server is accessible via web console at:  (1)

   You are logged in as:
       User:     developer
       Password: developer

   To login as administrator:
       oc login -u system:admin
1 OpenShift Web Console, Example: (open in browser)

Step 2:

Launch your first application.

see what user you are loged in as
oc whoami

You should be logged in as developer

Create a new Project for your first app.

create new project
oc new-project flask --description="Python Flask App" --display-name="Flask App"

Now use the new-app command to create the new app from a simple Python flask repository on GitHub. By using the --strategy=source we can pass it the type of container to build and launch the app. In this case we are using python:3.3.

create the app
oc new-app --strategy=source python:3.3~https://github.com/RedHatGov/OCP-App.git --name=flask-app

Now follow the logs as its being built.

follow the logs
oc logs -f bc/flask-app

Open a browser next to the terminal so you can see the app get created

Step 3:

Login to OpenShift

Login as developer
Username:  developer

Password:  developer
login ocp
Figure 1. OpenShift Main Login

Click on the new project you created Flask App.

flask app
Figure 2. Flask App

Now we need to create a route to see the app.

Click Create Route in the top right corner. Accept the defaults and click create.

create route
Figure 3. create route

Now lets see your first app. Click the new route. It should look similar to this http://http://flask-app-flask.apps.ose.0.redhatgov.io.

Congratulations! You have launched your first app in OpenShift!

To recap:

  • You just launched OpenShift on AWS

  • You launched a containerized python app

Extra credit

Details on the oc command (Informational Only)
oc cluster up \
   --public-hostname=$(curl -s \ (1)
   --routing-suffix=apps.ose.$STUDENT.redhatgov.io \ (2)
   --host-pv-dir=/data \ (3)
   --host-data-dir=/data  (4)
   --image=registry.access.redhat.com/openshift3/ose (5)
   --version=v3.5 (6)
1 This sets OpenShift’s public name to the public ip of the AMI, via the AWS metadata service (
2 This sets the wildcard domain for all of the applications you provision in OpenShift.
3 Cluster up creates a set of persistent volumes by default. It exposes a new flag that allows setting the directory on the host for these volumes.
4 To persist data across restarts, specify a valid host directory when starting your cluster with oc cluster up.
5 Pull from the Red Hat registry to run OpenShift Container Platform. Default is to use Origin.
6 Get the latest version of OCP 3.5.

Return to Workshop