Getting Started with Openshift – oc cluster up

oc cluster up sets up a local Openshift cluster with configured registry, router, image streams, and default templates. This is a great way to get started with development on your local Openshift environment. Let’s get started !

Download the oc client tool from here https://www.openshift.org/download.html. The OpenShift CLI exposes commands for managing your applications on Openshift. Also the oc cli exposes lower level tools to interact with each component of your system. The oc client is a zip archive for windows that needs to be unzipped and added to your path.

Now open a cmd/gitbash/powershell window and run oc version. You should see the oc cli version as below:

pic2

Note: I do not have the latest version of oc client. I will be upgrading soon. I suggest you download the latest oc client version.

Create a Docker machine

By default the oc cluster up command will use the VirtualBox driver, when –create-machine command is used to create a new Docker machine. I will be using a different driver. So I will create my Docker machine beforehand along with –engine-insecure-registry argument with the value expected by OpenShift. Open a cmd /gitbash/powershell window as administrator and run the below command:

docker-machine create --driver hyperv --hyperv-virtual-switch "My Virtual Switch" --engine-insecure-registry 172.30.0.0/16 openshift

pic1

oc cluster up

To persist data across your Openshift cluster restart, specify a valid host directory in the  –host-data-dir argument when starting your cluster with oc cluster up. As long as the same value is specified every time, the data will be preserved across cluster restarts. If a host data directory is not specified, the data directory (etcd) used by OpenShift is discarded when the container is destroyed. A new configuration will be generated by default each time the cluster is started. To make changes to the configuration and preserve those changes, use the –use-existing-config argument when starting your cluster.Run the below command and make sure you specify –docker-machine=openshift:

oc cluster up  --docker-machine=openshift --host-data-dir=/openshift-cluster 
--use-existing-config

pic3

pic4

As you can see, the required base images for Openshift cluster v3.5 is being pulled from registry.access.redhat.com. The registry, router, image streams, default templates are also created during the cluster startup.

Now access your Openshift console via your browser. Go to https://192.168.1.7:8443 and login as developer:developer. Below is a screenshot of my Openshift Console.

pic5

Enjoy experimenting with your very own Openshift cluster !

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s