X

An Oracle blog about Oracle Coherence

Updated Coherence Demo now runs on Kubernetes

Tim Middleton
Solution Architect

Introduction

Coherence Demo

We are happy to announce that a new version of the Coherence Demo has just been released which can run against a Kuberenetes environment. This demo utilizes a new open source project the Coherence Operator which helps you deploy and manage Coherence within a Kubernetes environment.

The Coherence Operator is available on GitHub at https://github.com/oracle/coherence-operator while the Coherence Demo is available at https://github.com/coherence-community/coherence-demo.

While updating the Coherence Demo, we've ensured that it still runs stand-alone, or on a single machine as it did before.

Pre-Requisites

The full set of pre-requisites are available in the Coherence Demonstration README, but as a quick guide I've included main requirements below:

  • Kubernetes 1.11.5+, 1.12.3+, 1.13.0+
  • Docker 18.03.1-ce 
  • Helm 2.12.3 
  • Coherence 12.2.1.3.2+ or 12.2.1.4.0+ (for Federation support)

If you wish to run the Coherence Demo on your Mac, you can with Docker Desktop version 2.0.0.3 and above.

Building and Running the Coherence Demo

The instructions below are summarised, with the assumption of all Coherence Demo pre-requisites met and using Docker Desktop on a MacBook Pro.

Note: You can follow the full instructions which includes pre-requisites and instructions how to enable Federation, in the README.md for the coherence-demo project.

Clone the repository using the following command:

$ git clone https://github.com/coherence-community/coherence-demo.git

Once you have your build environment set and Docker running, then build the Maven project using:

$ mvn clean install -P docker

The above command, will create a docker image which contains the cache configuration and java classes to run the demo application.

Install the Coherence Operator Chart

Issue the following to install the Coherence Operator chart:

helm install \
    --namespace coherence-demo-ns \
    --set imagePullSecrets=coherence-demo-secret \
    --name coherence-operator \
    --set "targetNamespaces={coherence-demo-ns}" \
    coherence/coherence-operator

Install the Coherence Chart

$ helm install \
    --namespace coherence-demo-ns \
    --name coherence-demo \
    --set clusterSize=1 \
    --set cluster=primary-cluster \
    --set imagePullSecrets=coherence-demo-secret \
    --set store.cacheConfig=cache-config.xml \
    --set store.pof.config=pof-config.xml \
    --set store.javaOpts="-Dprimary.cluster=primary-cluster"  \
    --set userArtifacts.image=coherence-demo-sidecar:3.0.0-SNAPSHOT \
    coherence/coherence

Once installed, ensure that the pods are all running by using the following. Once the coherence-demo-0 pod has READY of 1/1, you can continue.

$ kubectl get pods --namespace coherence-demo-ns
 NAME                             READY   STATUS    RESTARTS   AGE
 coherence-demo-0                 1/1     Running   0          54s
 coherence-operator-dc7867dbc-n   1/1     Running   0          54m

Port-forward the application HTTP port (8080) so that we can access the application via localhost (127.0.0.1).

$ kubectl port-forward --namespace coherence-demo-ns coherence-demo-0 8080:8080

Open the following URL to access the application home page - http://127.0.0.1:8080/application/index.html.

When running the stand-alone version of the Coherence Demo (See here), you could change the cluster size by adding or removing servers from the UI. When running under Kubernetes, you must the the kubectl command to scale the cluster.

For example, to scale the Coherence Demo cluster to 3 servers, you would use the following:

$ kubectl scale statefulsets coherence-demo --namespace coherence-demo-ns --replicas=2

You can use the following, (or view the application page), to see when the cluster has been scaled.

$ kubectl get statefulsets coherence-demo --namespace coherence-demo-ns
 NAME             DESIRED   CURRENT   AGE
 coherence-demo   2         2         16m

The application should show 2 members as below.

Coherence Demonstration Application Scales

To shutdown the Coherence Demo and Coherence Operator you use following helm command:

$ helm delete coherence-demo coherence-operator --purge

See the following links for more information on the Coherence Operator and Coherence Demo:

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.