What is OpenShift?
According to Wikipedia, OpenShift is a “supported distribution of Kubernetes using Docker containers and DevOps tools for accelerated application development,” which is a good start to describing the OpenShift ecosystem — but like most software, there are several different products under the OpenShift umbrella.Let’s go over a few varieties.Built around a core of Docker container packaging and Kubernetes container cluster management, OpenShift Origin is the open source upstream community project used in OpenShift Online, OpenShift Dedicated, and OpenShift Container Platform, freely available under the Apache v2 license on GitHub.OpenShift Online is Red Hat’s public cloud application development and hosting service, supporting a variety of languages, frameworks, and databases via pre-build “cartridges” running under resource-quota “gears.”Those interested in a private, enterprise supported version of OpenShift can opt either for OpenShift Dedicated, Red Hat’s managed private cluster offering available in AWS or GCP, or OpenShift Container Platform (formerly known as OpenShift Enterprise) Red Hat’s on-premises private PaaS product. Both OpenShift Dedicated and OpenShift Container Platform are built on a core of Kubernetes and Docker application containers created on a foundation of Red Hat Enterprise Linux.Announced during a keynote at Red Hat Summit 2017 in Boston, MA, OpenShift.io is an open online development environment for planning, creating, and deploying hybrid cloud services.Minishift, which we will be using for the below dev deployment, is a fully functioning OpenShift Origin instance with an integrated Docker registry, running locally on your machine.
OpenShift is a PaaS container application platform that brings Docker and Kubernetes to the enterprise.
What’s the difference between OpenShift and OpenStack?
Good question. Both OpenStack and OpenShift are open source Cloud computing softwares under the XaaS (Everything as a Service) umbrella, initially released between 2010-2011, but that’s about where the similarities end. OpenStack is an Infrastructure as a Service (IaaS) software that virtualizes Compute, block storage, object storage, and networking, and provides management for other services like server images, DNS, and containers, to name a few. The overall goal of OpenStack is to consolidate and simplify the management of an infrastructure, greatly reducing the need for teams of sysadmins and engineers.OpenShift, on the other hand, is a Platform as a Service (PaaS) application container service that, when combined with an infrastructure such as OpenStack, permits, easily creates, and updates applications without concern for managing the underlying hardware *or* software. OpenShift eliminates the need for developers to be aware of the underlying infrastructure — whatever that may be — in the process of creating and managing applications.
OpenStack is an IaaS (Infrastructure as a Service) while OpenShift is PaaS (Platform as a Service). The two projects are both open source and work beautifully together, but fill completely different gaps in the XaaS grid.
- Configure docker-KVM support for your OS.
- Download and unpack the latest Minishift release.
minishiftexecutable to preferred
Note:This guide is written for users of Red Hat Enterprise Linux 7.3 or other Community versions of RHEL 7.3 – such as Fedora, CentOS, or Scientific Linux. Instructions for installing Minishift on Mac or Windows can be found on minishift.openshift.org.
Step 1 – Hypervisor support
Before installing Minishift, you will first need to prepare your system by installing a hypervisor to start the VM on which the OpenShift cluster is provisioned.MiniShift uses a
Docker Container Runtime Engine and it’s driver plugin architecture to provide consistent management of the OpenShift Virtual Machine. VirtualBox and VMWare Fusion drivers are automatically embedded by MiniShift, but other drivers will require manual installation and setup.As your first step, you will need to download and configure
$ sudo curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.7.0/docker-machine-driver-kvm -o /usr/local/bin/docker-machine-driver-kvm && sudo chmod +x /usr/local/bin/docker-machine-driver-kvm
Next, we will install KVM drivers for Linux:
[trilliams@rhosp ~]$ sudo yum -y install libvirt libvirt-devel qemu-kvm
If you intend to run Minishift as a non-root user (recommended), you will need to add the user to the
[trilliams@rhosp ~]$ sudo usermod -aG libvirt $USER
[root@openshift ~]# usermod -aG libvirt trilliams
In the below example, you will see my user [trilliams] has the groups
[trilliams@rhosp ~]$ id trilliamsuid=1000(trilliams) gid=1000(trilliams) groups=1000(trilliams),10(wheel),993(libvirt)
Apply the changes to your current session:
[trilliams@rhosp ~]$ newgrp libvirt
Step 2 – Installing Minishift
[trilliams@rhosp ~]$ wget https://github.com/minishift/minishift/releases/download/v1.x.x/minishift-1.x.x-linux-amd64.tgz
Note:Because Minishift is frequently updated, the URL in the example has been obscured to prevent unneeded issues due to using a deprecated version of Minishift. It is recommended that you pull the latest version directly from the official Minishift repository.Once the download completes, unpack the .tar file, which should contain 3 files:
[trilliams@rhosp ~]$ tar xvf minishift-1.x.x-linux-amd64.tgz
Next, we will need to add the
minishift executable to our
$PATH, which in my case will be
/usr/local/bin/. You can find yours by running
[trilliams@rhosp ~]$ sudo mv minishift /usr/local/bin/minishift
[trilliams@rhosp ~]$ which minishift/usr/local/bin/minishift
Next, we will run the command
minishift start to start the installation. Once complete, your terminal should have a message similar to the following:
The server is accessible via web console at:https://192.168.42.190:8443You are logged in as: User: developer Password:
To log in as administrator:
oc login -u system:admin
You’ll immediately have access to the OpenShift Origin dashboard, but if you prefer to use the
oc command-line client, run the command eval
$(minishift oc-env) to add the
oc client to your terminal:
[trilliams@rhosp ~]$ eval $(minishift oc-env)[trilliams@rhosp ~]$ which oc~/.minishift/cache/oc/v3.6.0/oc
And that’s it! Minishift has been installed in your environment!
The Good Part
Now that your computer is set up, let’s get started with creating our first OpenShift app. This can be done either with the OpenShift Origin web dashboard or with the
oc command-line client. As a soft intro, let’s create a Python 3.5 app using one of the sample
s2i configurations available in the OpenShift Github repo.First, let’s make sure we’re logged in as a non-privileged user
developer in terminal with the command,
[trilliams@rhosp ~]$ oc whoamideveloper
Once we’ve verified login, let’s list out current projects using the
oc get command:
[trilliams@rhosp ~]$ oc get projectsNAME DISPLAY NAME STATUSmyproject My Project Active
Minishift has configured a default first project named
My Project which you are free to use. If you would like to work with a customized project, you can create a new one with the command
oc new-project. For this lesson, I am going to create a new project for the
developer user named
oc new-project cloudassessments
From that, you should get a return similar to this:OpenShift is intelligent enough to switch us to the new
cloudassessments project on it’s own, so now we can proceed with creating our first app. I am going to follow the suggestion of the
oc client and create the Ruby 22 on CentOS7 app suggested in the screenshot, using the
-l flag to specify a name, which is
[trilliams@rhosp ~]$ oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git -l name=first-app--> Found Docker image c2bee74 (6 days old) from Docker Hub for "centos/ruby-22-centos7"
oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git -l name=first-app
If you’re curious how the build works, you can watch progress with the command
oc logs -f bc/ruby-ex, which will return something similar to this:
oc logs -f bc/ruby-exCloning "https://github.com/openshift/ruby-ex.git" ...Commit: 5ce019b7424ff41688d983f3a792c7788a2e71a3 (allow viewing request headers (#8))...Pushed 7/9 layers, 90% completePushed 8/9 layers, 98% completePushed 9/9 layers, 100% completePush successful
OpenShift offers a second option for verifying builds; the
oc get builds command:
[trilliams@rhosp ~]$ oc get buildsNAME TYPE FROM STATUS STARTED DURATIONruby-ex-1 Source Git@5ce019b Complete 7 minutes ago 1m27s
$ oc get pods
The command should return something similar to this:
[trilliams@rhosp ~]$ oc get podsNAME READY STATUS RESTARTS AGEruby-ex-1-3w8lc 1/1 Running 0 4mruby-ex-1-build 0/1 Completed 0 5m
Now that our app has completed building, we can add a route to it with the
oc expose command:
[trilliams@rhosp ~]$ oc expose svc/ruby-exroute "ruby-ex" exposed
Then run the following command to open the app in our web browser:
[trilliams@rhosp ~]$ minishift openshift service ruby-ex --in-browserOpening the route/NodePort https://ruby-ex-cloudassessments.192.168.42.190.nip.io in the default browser...
Cleaning up in MiniShift/OpenShift is a breeze. You can delete an unwanted application with the
oc delete command. Since we no longer need the
cloudassessments project, we can clean up everything with the following:
[trilliams@rhosp ~]$ oc delete project $name
Then log out using
oc logout.And that’s it! You have successfully created your first OpenShift application using MiniShift!
Once you’re done playing with Minishift, you can delete the entire cluster and uninstall the application from your computer with the command:
$ minishift delete
Be sure to back up any data you want to keep before running this command, as no data or state will be preserved. If you would prefer to keep your cluster, you can halt it with the command:
$ minishift stop
This will stop the OpenShift cluster and shut down the Minishift VM while preserving cluster state, which will allow you to resume the previous session by once again running the original
minishift start command.
Check out my newest course, the Linux Academy Red Hat Certificate in Expertise in Platform-as-a-Service (ex280) Prep Course to learn more cool ways to build apps using OpenShift Container Platform v3.5.Happy OpenShifting!