Eric D. Schabell: How to build your own OpenShift oc client

Friday, March 3, 2017

How to build your own OpenShift oc client

how to build openshift client
Today there was a new release of boot2docker ISO, a base image that is used to create the base container when you want to run the OpenShift Container Platform on your local machine as a developer does.

This is usually not an issue, but today it was.

When you try to use the OpenShift command line client, known as 'oc', you started to get errors. It does not matter if you are using Linux, Windows or osX, this will hit sooner or later if you client is version 3.4.1.5 or earlier.

The problem

It also seems to be effecting users of OpenShift Origin, Minishift* and OpenShift Container Platform clusters. For example, when installing OpenShift Container Platform I would run the following command:

$ oc cluster up --image=registry.access.redhat.com/openshift3/ose --version=v3.4.1.5 --create-machine'

 The output you git is a full stop and the install is no longer possible:

-- Checking OpenShift client ... OK
-- Create Docker machine ...
Creating docker-machine openshift
-- Checking Docker client ... OK
-- Checking Docker version ... FAIL
Error: Minor number must not contain leading zeroes "03"

This leaves you up the creek without a paddle, as they say in the country.

how to build openshift client
This is what the error looks like...

Open technology, always a solution

As you are using open technology it is always possible to investigate and provide a fix, so I did just that. I raised an issue with the OpenShift community after discovering that boot2docker image now includes the latest release of docker. This uses version numbering 17.03.x and there was an internal check that failed on comparing the minor version.

Cesar Wong stepped up and fixed this very quickly and showed us how to build our own new command line client with the fix.

I thought this would be nice to share with you so I put together build scenarios for each os and added a build script to my OpenShift Container Platform installation project on Red Hat Demo Central.

Here's how it works.
how to build openshift client
Deployed route for web server hosting new built oc client.

You need to have an OpenShift installation somewhere, even a friends is good enough on another operating system than yours, does not matter. Once you have this, do the following:

  1.  Download and unzip the ocp-install-demo.
  2. Run the support/os-builder.sh with a single argument for your operating system type (linux, windows or osx), in this example we build for an osX binary:
$ ./support/os-builder.sh osx


This will ask you to login to your OpenShift, then kick off a new application to build the oc client. You can login and watch the build under the project named my-project.
how to build openshift client
The oc client fixed for you to download!

Once it's done you will see a deployment, so now you can go to Applications -> Routes and see the route to your deployment web service that is hosting the newly built oc binary for you to download. Click on this link and it will open a new tab with the filesystem holding your oc client.

Now you have a fixed oc client v3.4.1.2 that will work just fine with your OpenShift cluster installations. Do note that OpenShift does not yet support running on docker v17.03 as it was just released today.

* UPDATE: Note this only effects Minishift if updating to version 17.03 of docker, they don't use boot2docker yet and control their own versions (thanks to Praveen Kumar).