OpenShift provides a convenient abstraction over the concept of containers in the form of a PaaS (Platform as an application Service). At its core it utilises familiar container concepts provided by the likes of Docker and Kubernetes. This typically consists of an Orchestration Framework which can be used to scale applications on-demand based on usage but it also incorporates internal routing and firewall control via the use of application configuration files.
As part of this blog entry we will provide a quick overview of the OpenShift features and how to get this up and running on your own development machine using the Open Sourced MiniShift implementation.
The open sourced organisation
OpenShift originhave provided a simple setup in the form of
MiniShift. They have detailed instructions on how to install MiniShift but in an attempt to stream line this I will be focusing on the MacOS installation guide.
MacOS Installation quick guide
- OS X 10.10.3 Yosemite or later
- Homebrew - convenient package installer for MacOS
- VirtualBox - choose the latest
OS X hostunder VirtualBox platform packages. This should download the latest DMG binary to your machine where you can install it.
- xhyve - a hypervisor required to start the virtual machine.
At the time of writing you can install and setup MiniShift with all the requirements on MacOS for the first time using a basic script like the following:
minishift start minishift ip # Get the MiniShift IP Address oc login -u system:admin # Login as admin
Interaction with OpenShift is with the command line tool oc. To configure and set this up execute the following:
eval $(minishift oc-env) # Setup the OpenShift command line tool
oc new-app https://github.com/openshift/nodejs-ex -l name=myapp # Deploy a sample app oc expose svc/nodejs-ex # Expose a route to the service minishift openshift service nodejs-ex --in-browser # Open the app in your browser oc status # View project status
If you encounter issues loading the sample application in your browser its is possible that the DNS is not resolving correctly. In my case the url “http://dev-python3-myproject.192.168.XX.XX.nip.io” was not resolving due to an issue with
nip.io which provides wildcard support for DNS names. After some investigation it turns out the problem for me was my router which was blocking DNS resolution.
If you encounter this specific issue you can resolve it by updating your machine to use the google DNS server (i.e. 22.214.171.124). In my case all I had to do was edit “/etc/resolv.conf” and replace the nameserver line with “nameserver 126.96.36.199”. You may need to reset this value if it is overwritten so its worth creating a small script to update it. Finally you will probably need to expose the route again in order to get it working.
When your finished playing with MiniShift you can stop it easily with the following command:
Ok so whats next?
Ok so installing a sample app is fairly straightforward but what do we do if we want to take our applications and use a real OpenShift instance in the Cloud. Well luckily cloud providers have started to provide convenient guides on how to set all this up. For instance AWS provides a quick overview on their technical blog covering this very topic.