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

Minikube is a tool created by the Kubernetes community that “runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day” 

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).

Conclusion

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.

mvn io.fabric8:fabric8-maven-plugin:3.1.62:cluster-start

For more information, you can read the plugin documentation provided by  the Fabric8 community.

Rafael Benevides

About the author:

Rafael Benevides is a Director of Developer Experience at Red Hat. With many years of experience in several fields of the IT industry, he helps developers and companies all over the world to be more effective in software development. Rafael considers himself a problem solver who has a big love for sharing. He is a member of Apache DeltaSpike PMC – a Duke’s Choice Award winner project, and a speaker in conferences like JavaOne, Devoxx, TDC, DevNexus and many others. Twitter | LinkedIn | rafabene.com


Join the Red Hat Developer Program (it’s free) and get access to related cheat sheets, books, and product downloads.

Take advantage of your Red Hat Developers membership and download RHEL today at no cost.


For more information about Red Hat OpenShift and other related topics, visit: OpenShift, OpenShift Online.

Share
  • Or even easier as a Java developer to just run a single fabric8 maven command and it download and installs what you need, and you can have a beer/coffee at the same time. I recorded a video and blogged about this: https://blog.fabric8.io/installing-kubernetes-from-copenhagen-airport-in-one-command-while-having-a-drink-5ff42d12e692#.xs308tsad

    • Hi Claus. Thanks. I just updated the blog to mention this option.

  • Aurélien Pupier

    I see a 5th variant which requires no command-line action: use the Development Suite Installer http://developers.redhat.com/products/devsuite/overview/

  • Lalatendu Mohanty

    The list should mention Atomic Developer Bundle (ADB). Upstream project of CDK. You can get latest origin or any version of OpenShift Origin through ADB https://github.com/projectatomic/adb-atomic-developer-bundle

  • Daniel Dumitriu

    OpenShift without Vagrant, please ?!?

    (though it may seem so, this is not just nagging…)
    What would be the best option for someone (like me) who does NOT want to install Vagrant ? At all !
    Somehow, the concept of “Red Hat Developer” suggests that the development platform IS RHEL or Fedora.
    We do, already, have a virtualization environment – with all the necessary tools: “libvirt & the tools”

    Personally, I do not see the reason to install Vagrant (with all the Ruby baggage) just to be able to create and use a VM (even with the “libvirt driver”).

    Daniel
    (Yes, I know of – and working on – “openshift-ansible”. even had some minor contributions. But the “libvirt” version is “not quite there”, yet)

    • Mike Guerette

      Thanks for your comment. This (removing the need for Vagrant) is something that’s being evaluated.