Getting started with Redhat OpenShift Container Platform(RHOCP)

Recently I’d completed the training from Redhat on Introduction to OpenShift Applications(DO101). So, I thought to write an article on how to get started with the Redhat OpenShift Container Platform(RHOCP).

Redhat OpenShift is an enterprise-ready Kubernetes container platform with full-stack automated operations to manage hybrid cloud and multi-cloud deployments. This platform integrates the tools required to build and run applications and manages the complete application lifecycle from initial development to production.

The workflow for the OpenShift platform starts when a developer provides a Git repository URL for an application to OpenShift. This platform is so much powerful that, it automatically retrieves the source code from Git, builds it, and then deploys the application. The developer can also set the OpenShift to automatically detect the new Git commits, and then automatically rebuild and redeploy the application.

OpenShift provides some environments for building the application with some popular languages like Java, JavaScript, .NET, Perl, Ruby, PHP, and Python. It also provides some extra services for our application like Databases, CI/CD pipeline, etc.

Let’s start with the installation of OpenShift.

Install OpenShift:

For using OpenShift on local machines, there is one program we have to used know as MiniShift. Minishift and OpenShift 4 are very different, but Minishift is nevertheless a powerful introduction to the concept of running a cluster, creating projects, monitoring tasks, and maintaining cloud infrastructure.


  1. The machine should support virtualization.
  2. The hypervisor should be installed like VirtualBox, KVM, etc.

Installing MiniShift:

  1. Download the MiniShift

Download the MiniShift installation file compatible with your OS using the following link. In my case, I’m using MiniShift version v1.32.0.

2. Unzip the downloaded file and save it. Now, add the path of the unzipped file to the environment variables so that the minishift command can be accessed through the command line.

Now, open the command line and run the command to check if the minishift command is available.

$ minishift version

3. Starting the MiniShift cluster:

If you are installing minishift in Virtualbox, then configure minishift to use vm-driver virtualbox.

$ minishift config set vm-driver virtualbox

Check if if the vm-driver is set to virtualbox.

$ minishift config get vm-driver

For the first time, we are running minishift start command, we have to specify the hypervisor name. So that it will download and set up the MiniShift cluster in the hypervisor. In my case, I’m using VirtualBox as a hypervisor.

$ minishift start --vm-driver virtualbox --network-nameserver
$ minishift start — vm-driver virtualbox
OpenShift cluster started

Now, our OpenShift cluster started and accessible via web console at:

If we open the VirtualBox, we can see that the MiniShift cluster/VM is installed there.

Using OpenShift through WebUI(Console):

To use the OpenShift through the console, open up the browser and go the URL provided by the minishift start command.

OpenShift console login page

Enter the username shown by the minishift start command, in my case, the username is a developer and in the password field enter any value you liked.

By hitting Log In button, you will be logged into the OpenShift console.

OpenShift console

Deleting the default project named “My Project”. Now, we don’t have any projects.

No Project in console

We can check the same thing using CLI:

The command to see the available projects is

$ oc get projects
no projects available

Create a new project:

For creating a new project, click on the “Create Project” button, enter the project name, and hit the create button.

Create a new project

But, let’s create a new project using the command line. Our project name will be myapp.

The command for creating a new project named myapp is

$ oc new-project myapp
Create a new project

Create a new app:

In this module, we are going to see how to create a new app using a web console as well as CLI(Command Line).

Create a new app using Console:

Go inside a project. Let’s say the myapp project.

myapp project

The catalog method allows us to choose available ready to use applications. Also, we can select the language of our application and provide the source code from the Git Repository.

As we are deploying PHP application, let’s select our app language as PHP from the catalog.

Selecting app language from the catalog
Selecting relevant version/type

In the configuration, provide the name to the app, URL of the Git Repository. In the Git Reference, the default branch to fetch the source code is selected as the master branch.

Now, our PHP application code is stored in the Web folder in the Git Repository. So, we have to provide a directory of the application code as a Context Dir. This directory is used as a context directory for the build.

As of now, we are keeping the Source Secret blank.

App configuration

In the Routing, make sure the checkbox of “Create a route to the application” is checked. When our application is deployed, we will use this Route URL to access the application.

App configuration

Select the number of replicas.

App configuration

Make sure the proper labels are given and hit the create button.

Create App

Now, go to the overview tab. We will see our app deployment is started. In the NETWORKING section, the Route URL is created. When the build is completed, we will see 1 POD is running.

App deployment

Finally, our app is accessible by using the route URL. Open the route URL in the browser and hopefully, you will see our app is up and running.

PHP app deployed using Openshift

Create a new app using CLI:

Another way to create an app is by using the command line. OpenShift provides an efficient way to create a new app using oc new-app command.

I have to create a new app for an application in PHP language and the source code is present in a Git Repository. The following command is used to launch this new app in the OpenShift project.

$ oc new-app php~
Create a new app

As the command is fired, we can see that our new app build is started.

New App build started

Once the build is completed, we can see that one POD is up and running.

New App build completed

But, we are not able to access the new app because we haven’t created the route for this application yet. So, let’s create a route for this application first.

Route for the app can be created bu using oc expose command. This command will require the name of the service we want to expose. In our case, the name of the service is the web.

$ oc expose service web --name=web
Creating a route for the new app

Let’s verify is the route is created for the new app or not from the OpenShift web console.

The route is created for the new app

The new app can be accessed from this route.

Finally, we had successfully launched a new app from the CLI.

Scaling Applications in OpenShift:

In the real world, we can’t run the applications on a single pod. It may be possible that over a night our app gets famous and the traffic comes to our app is got increased. The single pod can’t handle that much traffic. So, we need to increase the number of pods to meet the requirement. This is known as scaling up the application.

When the load/traffic from our app goes down, we don’t need lots of pods. To save the cost, we need to decrease the number of pods. This is known as scaling down the application.

Let’s take a look at how to do scale up and scale down the application from the OpenShift console.

Scale-up the application:

Open the application from the overview tab. We can see that currently, one pod is running. Click on the up arrow near the pod.

Scale up the app

After we clicked on the up arrow, we will see that the application starts scaling up by launching another pod.

Scaling up started

And finally, another pod is launched identical to the first pod. Now, the number of running pods are two. Here, we had scaled up our application.

Application is scaled up

By going into the Monitoring tab, we can see more details about the running services.

More details about running services

Scale-down the application:

Open the application from the overview tab. We can see that currently, two pods are running. Click on the down arrow near the pod.

Scale-down the app

After we clicked on the down arrow, we will see that the application starts scaling down by terminating the extra pod.

Scaling down is started

And finally, the application is scaled down as the extra pod is terminated. Now, the number of running pods are one.

The app is scaled down

Get the logs of the pod:

Logs are very important in monitoring the application. Let’s get the logs from the pods in myapp project.

First of all, we need to know the names of the pods. This can be done by using oc get pods command. This command will give us some more information like no of ready pods, the status of the pod, no. of restarts, and the age of the pod.

$ oc get pods

After we get the names of the pod, we can run the oc logs command to see the logs of the pod.

$ oc logs podName
Get logs from the pod

Thanks for reading this article. I hope it had given you some idea about how powerful the OpenShift is. If you liked this article, please applaud it.

You can also follow me on Twitter at @cankush625 or find me on LinkedIn. I’d love to hear from you if I can help you with OpenShift.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store