Run OpenShift 3.11 Locally on CentOS Linux

In a recent post, I detailed and explained the procedure about how to install Kubernetes Locally and basic of Kubernetes’s core components. Hope so that it was interesting. With that understanding, I would like to quickly start writing the post about my day-to-day experience on OpenShift Container Platform.

As I mentioned in my earlier post, OpenShift was developed from Kubernetes Internal Components. Hence, It would be easy to understand OpenShift Concepts if you have some experience in Kubernetes. However, The continuous Red hat contribution is expanding the Kubernetes features that allow building a simplified Micro-service Production grade application on OpenShift Enterprise Platform.

In this tutorial, I would like to walk you through the procedure of installing OpenShift Locally ( a.k.a OKD) on CentOS Linux via Vagrant, deploy a simple Apache HTTP application in OKD via OpenShift Catalog, and finally verify that HTTP endpoint outside of Vagrant Machine.  This tutorial basically prepared for those who want to learn how to set up an All-in-One OpenShift Cluster.  If you are interested in learning Multiple Node OpenShift Cluster, keep reading my blog – I will cover those topics when I touch advanced OpenShift Installation. Now! Let’s start basic requirements.

To get started, You may need the following prerequisites:

  • CentOS 7 on VirtualBox
  • Docker Engine
  • OKD Binary
  • Basic knowledge about Linux Commands
  • Vagrant
  • VirtualBox

Basic about OpenShift ( OKD )

OpenShift is a Platform-as-a-Service solution that enables to quickly build, develop and deploy a Containerized application using Docker and Kubernetes.  Whether it’s on-premise, in a public cloud, or hosted service, OpenShift is fully capable of running in any platform. Due to this robust feature, it enables you to move your Containerized application easily to any Infrastructure as and when needed.

Let’s get started on installing All-in-One OpenShift Cluster. I am using Vagrant to set up this infrastructure. If you are new to Vagrant, I’d recommend you to read my earlier posts.

VagrantFile Configuration

OKD needs the following minimum system requirements which mentioned in Vagrantfile to bring up the Cluster. Ensure that you have enough CPU and Memory resource available in your system to allocate Virtual Machine. I have allowed certain ports in the configuration in order to access Apache HTTP endpoint outside of Vagrant Machine. You need to make sure those ports are not already in use. Otherwise, Vagrant will fail to bring up the Virtual Machine.

Run the below command to bring up the Vagrant VirtualBox

Once Vagrant brings up CentOS Linux on VirtualBox VM, use the below command to log in to a terminal.

You would be able to see the below-displayed output if the command is successful.

Docker Installation

Docker is the default Container Engine for OpenShift. If you are interested in learning other OpenSource Container engines like rkt, CRI-O, you can refer to this link for more details.  In this tutorial, I am not going to explain what is Docker about and its features.  If you are new to Container Engine Runtime, I’d recommend you to read my earlier posts.

Let’s get started installing Docker Engine on CentOS Linux. Ensure that your system is up to date before installing Docker Engine.

Once Docker engine installation is completed, run the docker version command to verify.

Next up, run the below command to start and enable the Docker Engine.

Ensure Docker Engine service started without any issues.

Awesome, Docker Engine is running as expected.

You need to allow insecure registry as part of the Docker installation. Make sure to edit and add the following lines in “/etc/docker/daemon.json” file.

In order to apply these changes, you need to restart the Docker Engine Service and run the docker info command to check the segment “172.30.0.0/16” added in Insecure Registries.

The following command can use to run Docker commands without a “sudo” privileges.

Installing OpenShift ( a.k.a OKD )

I am going to use the latest OpenShift Kubernetes Distribution ( a.k.a OKD 3.11 ) binary for this tutorial – so, Let’s download the latest tar file from the link. If you would like to know more about what OKD is, you can refer to this link.  Just follow the steps to download the binary.

I want to change the directory name to make it simple. So, I renamed the directory to OKD.

Let’s create a profile file under “/etc/profile.d” directory for “oc” command to include in executable $PATH variable.  In order to apply these changes, you would need to log out and log in back.

Finally!. To bring up OpenShift Cluster, just run the below command in the terminal.

The command will take a couple of minutes to set up the OpenShift cluster locally. If you are interested to know what “oc cluster up” operation is running in the background, you can add ” –loglevel=6″ option.

If there is no error on the “oc cluster up” output,  you would see the below message as OpenShift server started and will see the web console URL to get access to OpenShift Console.

In order to access OpenShift web console, type “https://127.0.0.1:8443” URL in the web browser and hit Enter button. OpenShift will ask you to key in Username and Password. Use developer/developer for username and password and hit Enter button

You would be able to see the Browser Catalog window in the OpenShift home page below like so after the successful login.

Fantastic!. Next up, Let’s deploy a simple Apache HTTP application and verify the OpenShift Cluster.

Deploy a Sample Application from Catalog

To deploy a simple application, I have chosen the Apache HTTP server (httpd) build from Browser Catalog.  A Browser Catalog is nothing but a predefined template that will enable you to easily deploy an application with a single click Button. For this demo purpose, I am choosing the predefined template now. In the future, I will cover the steps to do the same thing in “oc” command and “yaml” file. To start the deployment, Click the Apache HTTP Server from Catalog and click the Next button and continue.

Once the required configurations are given, Click Create button to continue. I am using Try sample Repository for this demo application.

Cool!, Apache HTTP server has been created successfully in “My Project” Namespace.

You may ask what is happening after httpd-ex created on My Project namespace, This is the time where  Build – > Deploy – > Run transition happens on OpenShift Platform. After the mentioned transition stage was completed, you can see two pods created on My Project Namespace. The pod which shows on completed status was created during the process of building the source code of the Apache HTTPD server. The second pod is the one actually runs the Apache HTTPD service.

Verifying the Apache HTTP server Endpoint

As a way of ensuring that the prerequisites were installed and configured correctly, let’s check the Endpoint by typing in route URL in web browser. In my case, URL endpoint is “http://httpd-ex-myproject.127.0.0.1.nip.io:8080/index.html”.

Cool!. Static Httpd application is running on OpenShift.

Conclusion

In this post, We went through the Docker and OKD installation procedure on the Single Node OpenShift Cluster on CentOS Linux within a short period of time. However, This setup will impact an application in the event of a system down. Configuring the Multi-Node OpenShift cluster will provide the best solution for high scalability and availability in OpenShift Container Platform.

Leave a Comment

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

20 − 13 =