Wednesday, March 9, 2016

Deploy WSO2 products on OpenShift v3

What is OpenShift ?
Simply it's a open-source platform as a service product. It allows to manage, deploy, monitor the applications.

What's new ?
OpenShift v3 is the latest version it also called as OpenShift origin. Mainly new version allows to deploy containers and orchestrate using help of  kubernetes.
OpenShift supports
  • Source-To-Image (S2I)
  • Template (JSON)
  • Container (Docker)
deployments. For this I'm using container based deployment.

Installing OpenShift

There is a openshift all in one vm  or It's available as a docker all in one container. I'm using the docker container for this. I'm using ubuntu 15.04v because ubuntu 14.04 have some known issues and the docker client and server versions are 1.9.1v.
Note: If you decided to use vagrant openshift all in one vm you can directly jump to "Deploying WSO2 products" step

To pull the origin image and start the container use
sudo docker run -d --name "origin" \
       --privileged --pid=host --net=host \
       -v /:/rootfs:ro -v /var/run:/var/run:rw -v /sys:/sys -v /var/lib/docker:/var/lib/docker:rw \
       -v /var/lib/origin/openshift.local.volumes:/var/lib/origin/openshift.local.volumes \
       openshift/origin start

Start the container
sudo docker exec -it origin bash

Configuring OpenShift

Before proceeding to next step there are some configurations need to be done. Openshift latest version use oc CLI.

First need to login as administrator, can use any password
oc login -u system:admin

OpenShift ships with a built in docker registry image, to configure and start a registry container use
oadm registry --credentials=./openshift.local.config/master/openshift-registry.kubeconfig

Deploying WSO2 products
Again you should login as a different user, in this case i will use noelyahan, can use any password you want
oc login -u noelyahan

Now we may need to create a project before add new applications
oc new-project wso2-products

Now it's time to deploy docker containers from image, I have pushed some docker images to my docker hub profile so you can simply use
oc new-app noelyahan/wso2-esb-openshift
oc new-app noelyahan/wso2-jaggery-openshift

You can use the openshift management console to monitor or control from ui, but still openshift cli allows to control everything such as scale up, scale down, log view, deployment status etc ..

To pull a container and start, it took several minutes for me but for spin up new pod it took less than a minute.

WSO2 ESB and WSO2 Jaggery running with multiple nodes

Overview of the deployment

One running container instance

Running container terminal log

Apply routing for service
Now service is running it's own private IP address, to access the service from the outside world we need to create a route.The docker containers exposing some ports 9443, 9763 that means we can map these target ports and create a new domain name that route to running services.

  • Go to Browse > Routes there's a option to create a route
  • WSO2 products are running on https that means when we need to create a secured route

Routing figure 1

Routing figure 2 : Adding a passthrough routing type

Accessing the service url through the routed url