Fetching contributors…
Cannot retrieve contributors at this time
79 lines (49 sloc) 2.65 KB

Kubernetes and Openshift tutorial

This tutorial contains instructions on how to run Infinispan library mode (as a microservice) in Kubernetes/OpenShift.

Prerequisites: Maven and Docker daemon running in the background.

Setting up OpenShift

OpenShift Origin has a command line client called oc (it can be downloaded here).

The client allows you to spin up a local cluster (of course this is not recommended for production but for testing, it’s perfect). In order to do that you need to invoke:

oc cluster up

Setting up Kubernetes

It is also possible to run this tutorial on Kubernetes. Installing a local cluster requires downloading and installing Minikube (detailed instruction might be found here).

Unfortunately Kubernetes installation does not use have installed any Docker registry by default. The easiest way to overcome this problem is to use Minikube’s Docker environmental variables:

eval $(minikube docker-env)

Configuring Service Account for KUBE_PING

Since KUBE_PING Discovery Protocol requires viewing all Pods in the OpenShift Project, you need to add additional privileges to the OpenShift:

oc login -u system:admin
oc policy add-role-to-user view system:serviceaccount:myproject:default -n myproject

Switch to a normal user

After the OpenShift is running, you need to login as a developer. That’s the standard role you should always be using:

oc login -u developer -p developer

Building this tutorial

This tutorial is built using maven command:

mvn install

Note that target/ directory contains additional directories like docker (with generated Dockerfile) and classes/META-INF/fabric8 with Kubernetes and OpenShift deployment templates.

If the Docker Daemon is down, the build will omit processing Dockerfiles. Use docker profile to turn it on manually.

Deploying this tutorial to the Kubernetes/OpenShift

This is handles automatically by Fabric8 maven plugin, just invoke:

mvn fabric8:run

Viewing and scaling out

Everything should be up and running at this point. Now login into the OpenShift or Kubernetes web console and scale the application our or in.

Just in case you were looking for Kubernetes scaling command:

kubectl scale --replicas=3  rs/$(kubectl get rs --namespace=myproject | grep infinispan | awk '{print $1}') --namespace=myproject

And the one for OpenShift:

oc scale --replicas=3  dc/$(oc get dc --namespace=myproject | grep infinispan | awk '{print $1}') --namespace=myproject