Friday, September 8, 2017

Minishift - Single Node Redhat OpenShift Container Cloud Cluster for Development Purpose

Recently I am involved into lot of DevOps and MicroServices related work, remember the OpenVZ Virtuozzo, LXC Containers which I was working on during 2010-2011, at that time concept of light-weight containers was very niche and conservative, we used that for High Performance Computing Clusters Partitioning. Fast forward 4-5 years, there is explosion of Docker/Container Keywords. The shift towards Cloud Enablement triggered DevOps ecosystem which in-turn triggered Microservices architecture which gives a methodology to develop Service-Based Architectures. 

One thing Docker did right as compared to OpenVZ is the use of Images (More like Binary Blobs) and stateless Containers concept as oppose to the Open View Filesystems (More like Virtual Machines). Docker wave also introduced the need of Container Management Platform. i.e. Kubernetes & eventually Redhat offering solution as OpenShift.

Redhat OpenShift has launched MiniShift project to help OpenShift PaaS developers to deploy a small single node OpenShift cluster quickly on development machines. This is available on mainstream personal virtualization platforms such as VirtualBox and KVM, so that without disturbing the existing setup, one can try out the cluster. (This is very similar to Vagrant). It uses libmachine library from docker-machine toolchain to provision the bare OS.
It is forked from minikube.

I recently attended a Redhat Meetup for Minishift launch, slides can be found here. It describes more details about the interfaces available for various Virtualization platforms like Hyper-V, for enterprise customers, I think it will make much more sense if Redhat can provide an official plugin for vSphere. So developers can create their own Openshift Sandbox in vSphere datacenters.

I have Xubuntu 16.04 on my home server with Virtualbox installed, so I have started with the minishift-1.0.0-rc.1-linux-amd64.tgz from the MiniShift Github Project here.

I would recommend KVM to everybody, but I needed portability, I am choosing Virtualbox.

For some use cases OpenShift Origin Upstream and OpenShift Container Platform will be more suitable, for some cases MiniShift would suffice, so depending upon the development needs, one should choose.

So I have downloaded the Minishift source code as well as binary from Github.

Extracted the 1.0.1 version & add the minishift binary to system path and you are done with installation. Its great! Thanks Redhat.

Now to start minishift and use Virtualbox, I used following -
(Make sure to run this under sudo privilege)

root@ninja:/home/ninja/Development/minishift/minishift-binary# ./minishift start --vm-driver=virtualbox
Starting local OpenShift cluster using 'virtualbox' hypervisor...
Downloading ISO 'https://github.com/minishift/minishift-b2d-iso/releases/download/v1.0.2/minishift-b2d.iso'
 13.51 MiB / 40.00 MiB [==============>----------------------------]  33.78% 3m8s

If there is stale VM, please check via "minishift status" and do "minishift delete".
To remove all stale files of minishift, remove /root/.minishift folder.

Complete output -

root@ninja:/home/ninja/Development/minishift/minishift-binary# ./minishift start --vm-driver=virtualbox
Starting local OpenShift cluster using 'virtualbox' hypervisor...
Downloading ISO 'https://github.com/minishift/minishift-b2d-iso/releases/download/v1.0.2/minishift-b2d.iso'
 40.00 MiB / 40.00 MiB [=============================================] 100.00% 0s
Downloading OpenShift binary 'oc' version 'v1.5.0'
 19.96 MiB / 19.96 MiB [=============================================] 100.00% 0s
-- Checking OpenShift client ... OK
-- Checking Docker client ... OK
-- Checking Docker version ... OK
-- Checking for existing OpenShift container ... OK
-- Checking for openshift/origin:v1.5.0 image ... 
   Pulling image openshift/origin:v1.5.0
   Pulled 0/3 layers, 3% complete
   Pulled 0/3 layers, 7% complete
   Pulled 0/3 layers, 11% complete
   Pulled 0/3 layers, 15% complete
   Pulled 0/3 layers, 19% complete
   Pulled 0/3 layers, 23% complete
   Pulled 0/3 layers, 27% complete
   Pulled 0/3 layers, 31% complete
   Pulled 0/3 layers, 35% complete
   Pulled 0/3 layers, 40% complete
   Pulled 0/3 layers, 44% complete
   Pulled 0/3 layers, 48% complete
   Pulled 0/3 layers, 52% complete
   Pulled 0/3 layers, 55% complete
   Pulled 0/3 layers, 59% complete
   Pulled 0/3 layers, 64% complete
   Pulled 0/3 layers, 68% complete
   Pulled 0/3 layers, 72% complete
   Pulled 1/3 layers, 75% complete
   Pulled 1/3 layers, 78% complete
   Pulled 1/3 layers, 82% complete
   Pulled 1/3 layers, 86% complete
   Pulled 1/3 layers, 89% complete
   Pulled 1/3 layers, 93% complete
   Pulled 1/3 layers, 96% complete
   Pulled 2/3 layers, 98% complete
   Pulled 3/3 layers, 100% complete
   Extracting
   Image pull complete
-- Checking Docker daemon configuration ... OK
-- Checking for available ports ... OK
-- Checking type of volume mount ... 
   Using Docker shared volumes for OpenShift volumes
-- Creating host directories ... OK
-- Finding server IP ... 
   Using 192.168.99.100 as the server IP
-- Starting OpenShift container ... 
   Creating initial OpenShift configuration
   Starting OpenShift using container 'origin'
   Waiting for API server to start listening
   OpenShift server started
-- Adding default OAuthClient redirect URIs ... OK
-- Installing registry ... OK
-- Installing router ... OK
-- Importing image streams ... OK
-- Importing templates ... OK
-- 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:
       https://192.168.99.100:8443

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

   To login as administrator:
       oc login -u system:admin

root@ninja:/home/ninja/Development/minishift/minishift-binary# 

As you can see, it has pulled the Openshift Origin image, this image will run inside the Virtualbox VM, so your host OS doesn't have any Docker engine running.

The Web Console is accessible via Host OS. The headless VM runs in the backend something like this -

/usr/lib/virtualbox/VBoxHeadless --comment minishift --startvm 6a9c8393-62c4-41b3-a57d-ed1aa2fb6796 --vrde config

Get libmachine logs to see what is happening behind the scene -

--show-libmachine-logs

Happy mini-shifting!