Four creative ways to create an OpenShift/Kubernetes dev environment
Developers have a lot of choices when deciding how to start using OpenShift and Kubernetes locally — without going through a native OS installation.
We all need to have a development environment as close as possible to production (to prevent defects caused by environmental differences), but ideally we need to do this without spending a lot of time to setup and a lot of computational resources (cpu, memory and disk space). This post will present four alternatives to create a local OpenShift cluster easily.
1 – oc cluster up
There’s a new feature that was introduced in OpenShift Origin 1.3 and Enterprise 3.3 that has become one of my favorite ways to start an OpenShift cluster. This option downloads a containerized version of OpenShift and execute it locally.
Given that it executes OpenShift in a container, the only requirement needed, besides the oc 1.3.x+ command itself, is to have a docker daemon executing (locally or via docker-machine) and the following command will do the rest:
$ oc cluster up --create-machine=true \ --use-existing-config \ --host-data-dir=/mydata \ --metrics=true
“oc cluster up” also allows you to try Openshift Container Platform (previously called OpenShift Enterprise) by specifying Red Hat registry and the proper image and version. Example:
$ oc cluster up --create-machine=true \ --use-existing-config \ --host-data-dir=/mydata \ --metrics=true \ --image=registry.access.redhat.com/openshift3/ose \ --version=latest
Both methods creates a ~/.kube/config file that allows you also to use the kubectl command to interact with the Kubernetes cluster that runs together with OpenShift.
2 – Minishift
To provide a seamless experience to people who are already familiarized with Minikube, Jimmi Dyson from Red Hat, created a project called Minishift.
Just like Minikube, it uses drivers (xhyve, hyperv, virtualbox, vmware fusion, and kvm) to create a virtual machine. Minishift allows you to specify cpu, memory, disk and some other customization parameters for the virtualized Openshift daemon. Example:
$ minishift start --cpus=2 --deploy-router=true --memory=2048
Once your OpenShift cluster is running, you can run “$ oc minshift console” and the OpenShift console will be opened in the default browser.
3 – All-In-One Virtual Machine
The OpenShift community also provides a “All-In-One Virtual Machine”. It’s essentially a Vagrant file that will automatically download and execute a VirtualBox VM image. Two commands and you will have an Openshift cluster running:
$ vagrant init openshift/origin-all-in-one $ vagrant up --provider=virtualbox
Note that this option only supports VirtualBox at this moment.
4 – CDK / ADB
CDK means Container Development Kit. Just like the “All-In-One Virtual Machine”, it’s a Vagrant file that support different providers (VirtualBox, HyperV and libvirt). The provided image runs OpenShift Enterprise (OSE) running on Red Hat Enterprise Linux (RHEL) with a no-cost developer subscription. It can be very useful for developers that want to have your development environment as close as possible to the production environment.
You can download CDK from http://developers.redhat.com/products/cdk/download/. You can use your Red Hat Developers portal registration to have access to this product. If you are not yet registered, don’t loose more time and register now.
Once you have all the requirenments of CDK installed (Vagrant, the virtualization provider and its proper image), just execute “vagrant up” and you will have OpenShift Enterprise running in a VM.
$ vagrant up
Update: CDK is based on the upstream project called ADB (Atomic Developer Bundle) that allows you to get any version of OpenShift Origin.
Update: Windows users can automate the installation of a complete Development environment through Red Hat Development Suite. If you have a brand new Windows machine, the Red Hat Development Suite will not only install CDK/OpenShift and its dependencies (vagrant and VirtualBox), but it will also install OpenJDK, JBoss Development Studio (JBDS).
Among these options, CDK and “oc cluster up” are the only two options that allow the developer to execute the enterprise version of Openshift.
Once the developers have a local cluster running with OpenShift, they can use the kubectl command line to interact with the Kubernetes API Server managed by OpenShift, or use the oc command line to have full access to all features provided by OpenShift like Role based access control (RBAC), Source to image (S2I), Security context constraints (SCC), ImageStreams, builds, etc.
OpenShift also provides an awesome web console that allows Kubernetes users to graphically visualize and manage almost all cluster objects.
With all these options, developers are encouraged to choose one method and run a an application inside OpenShift to try it. Read the “Creating an Application Using the CLI” chapter and see how it’s easy to deploy an application.
UPDATE (5 – Fabric8 plugin)
If you are a Java Developer, I would like to suggest the blog post: Installing Kubernetes from Copenhagen Airport in one command from Claus Ibsen. The blog post shows how a simple Maven command can be used to create a Kubernetes/OpenShift cluster for you.
Join Red Hat Developers, a developer program for you to learn, share, and code faster – and get access to Red Hat software for your development. The developer program and software are both free!