Deploy Applications Using OpenShift: Step-by-Step

Feature Image
DevOps

Share Post Now :

HOW TO GET HIGH PAYING JOBS IN AWS CLOUD

Even as a beginner with NO Experience Coding Language

Explore Free course Now

Table of Contents

Loading

In this blog post, I will share How to Deploy an Application on OpenShift? Various methods of OpenShift Application Deployment and the most Frequently Asked Questions about it.

Let’s go through the topics of discussion first:

What is OpenShift?

OpenShift

OpenShift is a fully managed Platform as a Service offering from RedHat/IBM specially designed for open hybrid cloud strategy. It is used to run containerized applications. It is built on top of Docker and Kubernetes that lets users build, test, deploy, manage, and run container-based applications on cloud platforms.

Check out: OpenShift Overview

Methods to Deploy Applications on OpenShift

There are two easy ways to deploy an OpenShift Application.

  • Using Console: You can directly deploy the website using the Graphical User Interface of OpenShift with just a few clicks.
  • Using CLI: OpenShift also provides a Command Line Interface where with few commands, you can deploy an Application.

How to Deploy an Application on OpenShift?

In this demo, I am using RedHat OpenShift Service, accessing from the AWS cloud computing platform. I have performed this demo in two parts using both the Console and Command Line Interface. So let’s get into OpenShift Application Deployment.

Check out: Create AWS Free Tier Account

Step 1) Make sure you have already created the OKD cluster using the AWS console.

Step 2) You need to Open All Ports in the EC2 instance as shown in the following steps:

a) Access the instance and click on Security.

Security

b) Select the Security Group.

Security Group

c) Go to Inbound rules and select the Edit Inbound Rule.

Edit Inbound Rules

d) Now, click on Add Rule.

Add Rule

e) Go to In Type, and Select All TCP. In CIDR, Select 0.0.0/0 and then click on the Save rule.

Inbound

Inbound Rules

Step 3) Let’s deploy the Application using Console first. 

a) You need to login into the OKD console.

Login

b) Go to Catalog and select NGINX to deploy the application.

Browse Catalog

C) We will make use of the Sample Repository in this demo further. Make sure to take a note of it and click on next.

Sample Repo

d) A new window will pop up. So under Project Details, Select Default Project.

Now Select the Latest Version.

Application Name: nginx-app 

Under the Git Repository path, there is a link present for Try Sample Repository. You need to click on that link to populate the Git Repository textbox.

Note: The meaning of Project in Openshift is like namespace in Kubernetes.

nginx

nginx1

nginx2

e) After this, click on the Project Overview link on the screen.

Project Overview

Step 4) Now, I will show you how to Access Nginx Application.

a) Go to Home Screen, and select the default project.

default project

b) When you click on overview, it will show the nginx application that we just deployed. Now click on the arrow button to expand it.

nginx-app

c) You can access this application externally by using the link highlighted in the image.

Link

d) Now application can be easily accessed by using this link.

Application

Check Out: Our blog post on Openshift Use Cases.

Deploy the Application using CLI

Step 1) Go to Cluster CLI.

Step 2) Here, we will create a new Project First (which is similar to the namespace in Kubernetes)

# oc new-project k21application

CLI

Step 3) The third step is to enable Dockerhub images that Require Root.

# oc adm policy add-scc-to-user anyuid -z default

CLI1

Step 4) Now, let’s deploy the httpd Application on the oc cluster.

# oc new-app --name web2 docker.io/httpd

Note: Ignore the Warning that states git is not available on the system.

Warning

Step 5) Now, you need to check the pod status on the machine.

# oc get pods

pod status

Step 6) Next step is to expose this service so that we can access this externally.

# oc expose svc/web2

Exposing Service

Step 7) Now, we will access the service that is recently exposed.

# oc status

Application Exposed

Working App

Step 8) The last step is to delete the deployment and service.

# oc delete deploymentconfig web2
# oc delete svc web2 

Delete the Service

Check out: OpenShift vs Kubernetes

FAQs

Q1) What is a deployment in OpenShift?

Ans: A deployment is a replication controller in OpenShift. It is based upon a user-defined template which is called a deployment configuration. Generally, deployments are created either manually or for responses to triggered events.

Q2) How to list all pods in OpenShift?

Ans: Let’s look at the pods in OpenShift.

a) You can list all or selected pods on one or more nodes using the following command:

$ oc describe node <node1> <node2> $ oc describe node ip-10-0-128-218.ec2.internal.

b) If you want to list all or selected pods on selected nodes, follow the command:

$ oc describe --selector=<node_selector> $ oc describe -l=<pod_selector>

Q3) What is a template in OpenShift?

Ans: A template is a set of objects. These objects can be easily processed and parameterized.

Check out: OpenShift Hands-on Labs

Conclusion

There are many ways to deploy an application on OpenShift. In this post, I discussed and showed some of the easiest methods on how to deploy an application on OpenShift? If you already have all those tools that build and store images, then you can deploy applications using container images. Hence, OpenShift is a great tool for container-based applications over the cloud. We can build, test, deploy and maintain applications using it very easily.

Related/References

Next Task for You:

Begin your journey towards becoming a Red Hat Certified Specialist in OpenShift Administrator and earning a lot more in 2021 by joining our Free Class.

Picture of mike

mike

I started my IT career in 2000 as an Oracle DBA/Apps DBA. The first few years were tough (<$100/month), with very little growth. In 2004, I moved to the UK. After working really hard, I landed a job that paid me £2700 per month. In February 2005, I saw a job that was £450 per day, which was nearly 4 times of my then salary.