Skip to content

Commit

Permalink
#22 Update for latest Coherence Operator (#23)
Browse files Browse the repository at this point in the history
* #22 Update for latest Coherence Operator
  • Loading branch information
tmiddlet2666 authored Jan 28, 2021
1 parent c3b31bd commit eefc946
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 60 deletions.
73 changes: 38 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ The `target` directory contains a list of files:
Run the JAR file in the `target` directory:

```bash
java -jar target/coherence-demo-4.0.0-SNAPSHOT.jar
java -jar target/coherence-demo-4.0.1-SNAPSHOT.jar
```

The following screenshot shows the application running with 5 cache servers started.
Expand All @@ -125,12 +125,12 @@ The following screenshot shows the application running with 5 cache servers star
You can use the following to run the application with the `Metrics` endpoint enabled:

```bash
java -Dcoherence.metrics.http.enabled=true -jar target/coherence-demo-4.0.0-SNAPSHOT.jar
java -Dcoherence.metrics.http.enabled=true -jar target/coherence-demo-4.0.1-SNAPSHOT.jar
```

Use the following argument to start the VisualVM while running the JAR file:
```bash
java -Dvisualvm.executable=/u01/oracle/product/visualvm/visualvm_143/bin/visualvm -jar target/coherence-demo-4.0.0-SNAPSHOT.jar
java -Dvisualvm.executable=/u01/oracle/product/visualvm/visualvm_143/bin/visualvm -jar target/coherence-demo-4.0.1-SNAPSHOT.jar
```
`-Dvisualvm.executable=/u01/oracle/product/visualvm/visualvm_143/bin/visualvm` in the command points to the path of the VisualVM executable.

Expand Down Expand Up @@ -167,7 +167,7 @@ To shut down the application, select **Shutdown** option from the **Tools** menu
The default HTTP hostname is 127.0.0.1 and default port is 8080. To modify these you can add the `http.hostname` or `http.port` properties on startup:

```bash
java -Dhttp.hostname=myhostname -Dhttp.port=9000 -jar coherence-demo-4.0.0-SNAPSHOT.jar
java -Dhttp.hostname=myhostname -Dhttp.port=9000 -jar coherence-demo-4.0.1-SNAPSHOT.jar
```
By changing the `http.hostname` you can access the application outside of
your local machine.
Expand All @@ -177,7 +177,7 @@ your local machine.
When starting up the application, the timezone is analyzed and default names are selected for the primary and secondary cluster (see [Launcher.java](https://github.com/coherence-community/coherence-demo/tree/master/src/main/java/com/oracle/coherence/demo/application/Launcher.java)). If you want to customize the name, do the following:

```bash
java -Dprimary.cluster=NewYork -Dsecondary.cluster=Boston -jar coherence-demo-4.0.0-SNAPSHOT.jar
java -Dprimary.cluster=NewYork -Dsecondary.cluster=Boston -jar coherence-demo-4.0.1-SNAPSHOT.jar
```
If you want to use a cluster name with a space, you must enclose it in quotes.

Expand Down Expand Up @@ -208,23 +208,23 @@ The steps to run the application on Kubernetes comprises the following:

1. **Create Namespace**

Run the application using the Oracle Coherence Operator in a namespace called `coherence-demo-ns`. Create the demonstration namespace:
Run the application using the Oracle Coherence Operator in a namespace called `coherence-example`. Create the demonstration namespace:
```bash
kubectl create namespace coherence-demo-ns
kubectl create namespace coherence-example
namespace/sample-coherence-ns created
```

1. **Build and Push Docker Image**

Ensure that you have Docker running locally and execute the following command which will
used the `jib-maven-plugin` to build a Docker time.
used the `jib-maven-plugin` to build a Docker image.

```bash
mvn clean install -P docker
```

This creates an image named `coherence-demo:4.0.0-SNAPSHOT` which contains everything needed to run the demo.
This creates an image named `coherence-demo:4.0.1-SNAPSHOT` which contains everything needed to run the demo.

> Note: If you are running against a remote Kubernetes cluster, you need to push the Docker image to your repository accessible to that cluster. You also need to prefix the image name in your `helm` commands below.

Expand All @@ -233,18 +233,18 @@ The steps to run the application on Kubernetes comprises the following:
Install the operator using `helm`:

```bash
helm install --namespace coherence-demo-ns coherence-operator coherence/coherence-operator
helm install --namespace coherence-example coherence-operator coherence/coherence-operator
```

Confirm the creation of the chart:

```bash
helm ls --namespace coherence-demo-ns
helm ls --namespace coherence-example
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
coherence-operator coherence-demo-ns 1 2021-01-12 15:25:04.409346768 +0800 AWST deployed coherence-operator-3.1.1 3.1.1
coherence-operator coherence-example 1 2021-01-12 15:25:04.409346768 +0800 AWST deployed coherence-operator-3.1.1 3.1.1
kubectl get pods --namespace coherence-demo-ns
kubectl get pods --namespace coherence-example
NAME READY STATUS RESTARTS AGE
coherence-operator-cd9b646d5-p5xk8 1/1 Running 0 2m12s
Expand All @@ -253,7 +253,7 @@ The steps to run the application on Kubernetes comprises the following:
For `helm` version 2.X:

```bash
helm install --namespace coherence-demo-ns --name coherence-operator coherence/coherence-operator
helm install --namespace coherence-example --name coherence-operator coherence/coherence-operator
helm ls
```
Expand All @@ -271,10 +271,10 @@ The steps to run the application on Kubernetes comprises the following:
Issue the following command to install the Coherence cluster using the above yaml:

```bash
kubectl create --namespace coherence-demo-ns -f yaml/demo-cluster.yaml
kubectl create --namespace coherence-example -f yaml/demo-cluster.yaml
```

Use `kubectl get pods --namespace coherence-demo-ns` to ensure that the pod is running.
Use `kubectl get pods --namespace coherence-example` to ensure that the pod is running.
The pod primary-cluster-storage-0 must be running and ready as shown:

```bash
Expand All @@ -287,13 +287,13 @@ The steps to run the application on Kubernetes comprises the following:
If the pod does not show as `Running`, you can use the following command to diagnose and troubleshoot the pod:

```bash
kubectl describe pod primary-cluster-storage-0 --namespace coherence-demo-ns
kubectl describe pod primary-cluster-storage-0 --namespace coherence-example
```

1. **Port Forward the HTTP Port**

```bash
kubectl port-forward --namespace coherence-demo-ns primary-cluster-http-0 8080:8080
kubectl port-forward --namespace coherence-example primary-cluster-http-0 8080:8080
```

1. **Access the Application**</br>
Expand All @@ -310,27 +310,27 @@ The steps to run the application on Kubernetes comprises the following:
the `replicas` value for the `storage` role to 3. Then apply using

```bash
kubectl apply --namespace coherence-demo-ns -f yaml/demo-cluster.yaml
kubectl apply --namespace coherence-example -f yaml/demo-cluster.yaml
```

You can also use the following to scale the cluster:

```bash
kubectl scale --namespace coherence-demo-ns coherence coehrence/primary-cluster-storage --replicas=6
kubectl scale --namespace coherence-example coherence coehrence/primary-cluster-storage --replicas=6
```

Use `kubectl --namespace coherence-demo-ns rollout status sts/primary-cluster-storage` to view the progress.
Use `kubectl --namespace coherence-example rollout status sts/primary-cluster-storage` to view the progress.

1. **Scale the Application down**

Scale the application to one node by editing `demo-cluster.yaml` and changing
the `replicas` value for the `storage` role to 1. Then apply using

```bash
kubectl apply --namespace coherence-demo-ns -f yaml/demo-cluster.yaml
kubectl apply --namespace coherence-example -f yaml/demo-cluster.yaml
```

Use `kubectl -n coherence-demo-ns rollout status coherence/primary-cluster-storage` to view the progress.
Use `kubectl -n coherence-example rollout status coherence/primary-cluster-storage` to view the progress.

> Note: The Coherence Operator ensures that all scale operations are
> carried out in a safe manner (checking service statusHA values) to ensure no data is lost.
Expand All @@ -341,7 +341,7 @@ The steps to run the application on Kubernetes comprises the following:
Use the following to uninstall the Coherence cluster.

```bash
kubectl delete --namespace coherence-demo-ns -f yaml/primary-cluster.yaml
kubectl delete --namespace coherence-example -f yaml/demo-cluster.yaml
```

## Enable Federation on Kubernetes (Grid Edition Only)
Expand All @@ -359,9 +359,9 @@ The setup for this example uses two Coherence clusters in the same Kubernetes cl

1. **Create Namespace**

Run the application using the Oracle Coherence Operator in a namespace called `coherence-demo-ns`. Create the demonstration namespace:
Run the application using the Oracle Coherence Operator in a namespace called `coherence-example`. Create the demonstration namespace:
```bash
kubectl create namespace coherence-demo-ns
kubectl create namespace coherence-example
namespace/sample-coherence-ns created
```
Expand All @@ -382,10 +382,10 @@ The setup for this example uses two Coherence clusters in the same Kubernetes cl
Issue the following command to install the Coherence cluster using the above yaml:

```bash
kubectl create --namespace coherence-demo-ns -f yaml/primary-cluster.yaml
kubectl create --namespace coherence-example -f yaml/primary-cluster.yaml
```

Use `kubectl get pods --namespace coherence-demo-ns` to ensure that the pods are running.
Use `kubectl get pods --namespace coherence-example` to ensure that the pods are running.

```bash
NAME READY STATUS RESTARTS AGE
Expand All @@ -397,7 +397,7 @@ The setup for this example uses two Coherence clusters in the same Kubernetes cl
5. Port forward the Primary Cluster - Port **8088**

```bash
kubectl port-forward --namespace coherence-demo-ns primary-cluster-http-0 8080:8080
kubectl port-forward --namespace coherence-example primary-cluster-http-0 8080:8080
```
Use the following URL to access the application home page:

Expand All @@ -411,10 +411,10 @@ The setup for this example uses two Coherence clusters in the same Kubernetes cl
Issue the following command to install the Coherence cluster using the above yaml:

```bash
kubectl create --namespace coherence-demo-ns -f yaml/secondary-cluster.yaml
kubectl create --namespace coherence-example -f yaml/secondary-cluster.yaml
```

Use `kubectl get pods --namespace coherence-demo-ns` to ensure that the pods are running.
Use `kubectl get pods --namespace coherence-example` to ensure that the pods are running.

```bash
NAME READY STATUS RESTARTS AGE
Expand All @@ -430,7 +430,7 @@ The setup for this example uses two Coherence clusters in the same Kubernetes cl
7. Port forward the Secondary Cluster - Port **8090**

```bash
kubectl port-forward --namespace coherence-demo-ns secondary-cluster-http-0 8090:8080
kubectl port-forward --namespace coherence-example secondary-cluster-http-0 8090:8080
```
Use the following URL to access the application home page:

Expand All @@ -446,9 +446,9 @@ The setup for this example uses two Coherence clusters in the same Kubernetes cl
10. Uninstall the Coherence Clusters

```bash
kubectl delete --namespace coherence-demo-ns -f yaml/primary-cluster.yaml
kubectl delete --namespace coherence-example -f yaml/primary-cluster.yaml
kubectl delete --namespace coherence-demo-ns -f yaml/secondary-cluster.yaml
kubectl delete --namespace coherence-example -f yaml/secondary-cluster.yaml
```

Before starting another sample, ensure that all the pods are removed from the previous sample.
Expand All @@ -458,7 +458,7 @@ Before starting another sample, ensure that all the pods are removed from the pr
To remove the `coherence-operator`, the use the following:

```bash
helm delete coherence-operator --namespace coherence-demo-ns
helm delete coherence-operator --namespace coherence-example
```

For `helm` version 2.X:
Expand Down Expand Up @@ -539,6 +539,9 @@ If you wish to view metrics via Grafana, please carry out the steps
[here](https://github.com/oracle/coherence-operator/tree/master/examples/deployment#view-cluster-metrics-via-grafana)
before you install any of the examples above.

> Note: Before you run the above, you must change the namespace in `src/main/yaml/prometheus-rbac.yaml` in the coherence-operator cloned repository
> from `coherence-example` to `coherence-example`.

The following screenshot shows the application running within Oracle's Cloud Infrastructure (OCI) under Kubernetes.
![Coherence Demo - Grafana](assets/coherence-demo-grafana.png "Coherence Demo - Grafana")
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<groupId>com.oracle.coherence</groupId>
<artifactId>coherence-demo</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.1-SNAPSHOT</version>

<properties>
<!-- The groupId of the Coherence product -->
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/web/fragments/addOrRemoveServerK8s.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
</pre>
Then apply this change using
<pre>
$ kubectl apply --namespace coherence-demo-ns -f yaml/demo-cluster.yaml
$ kubectl apply --namespace coherence-example -f yaml/demo-cluster.yaml
</pre>
<p>
You can also scale the cluster using
<pre>
$ kubectl scale coherence --namespace coherence-demo-ns primary-cluster-storage --replicas=6
$ kubectl scale coherence --namespace coherence-example primary-cluster-storage --replicas=6
</pre>
<p>
You can use <strong>kubectl get pods</strong> to view the status of the apply command and the number of replicas.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</pre>
Then apply this change using
<pre>
$ kubectl apply --namespace coherence-demo-ns -f yaml/primary-cluster.yaml
$ kubectl apply --namespace coherence-example -f yaml/primary-cluster.yaml
</pre>
<p><strong>Secondary</strong><p>
To scale the number of replicas to 2, update the secondary-cluster.yaml used to create the cluster and change the replicas to 2 under the storage role:
Expand All @@ -19,9 +19,9 @@
</pre>
Then apply this change using
<pre>
$ kubectl apply --namespace coherence-demo-ns -f yaml/secondary-cluster.yaml
$ kubectl apply --namespace coherence-example -f yaml/secondary-cluster.yaml
</pre>
You can also scale the cluster using the following for the primary-cluster.
<pre>
$ kubectl scale coherence --namespace coherence-demo-ns primary-cluster-storage --replicas=6
$ kubectl scale coherence --namespace coherence-example primary-cluster-storage --replicas=6
</pre>
2 changes: 1 addition & 1 deletion src/main/resources/web/fragments/shutdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<br/>
Delete the Coherence cluster using the following <strong>kubectl</strong> command:<p>
<pre>
$ kubectl delete --namespace coherence-demo-ns -f primary-cluster.yaml
$ kubectl delete --namespace coherence-example -f primary-cluster.yaml
6 changes: 3 additions & 3 deletions src/main/resources/web/fragments/shutdownFederationInK8s.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<br/>
Delete both of the Coherence clusters using the following <strong>kubectl</strong> command:<p>
<pre>
$ kubectl delete --namespace coherence-demo-ns -f primary-cluster.yaml
$ kubectl delete --namespace coherence-example -f primary-cluster.yaml

$ kubectl delete --namespace coherence-demo-ns -f secondary-cluster.yaml
</pre>
$ kubectl delete --namespace coherence-example -f secondary-cluster.yaml
</pre>
8 changes: 3 additions & 5 deletions yaml/demo-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ spec:
args:
- "-Dwith.http=false"
- "-Dprimary.cluster=primary-cluster"
- "-Dcoherence.metrics.legacy.names=false"
ports:
- name: metrics
port: 9612
Expand All @@ -21,7 +20,7 @@ spec:
cacheConfig: cache-config.xml
metrics:
enabled: true
image: coherence-demo:4.0.0-SNAPSHOT
image: coherence-demo:4.0.1-SNAPSHOT
imagePullPolicy: Always
replicas: 2
---
Expand All @@ -37,7 +36,6 @@ spec:
heapSize: 512m
args:
- "-Dprimary.cluster=primary-cluster"
- "-Dcoherence.metrics.legacy.names=false"
ports:
- name: http
port: 8080
Expand All @@ -51,6 +49,6 @@ spec:
metrics:
enabled: true
port: 9612
image: coherence-demo:4.0.0-SNAPSHOT
image: coherence-demo:4.0.1-SNAPSHOT
imagePullPolicy: Always
replicas: 1
replicas: 1
8 changes: 3 additions & 5 deletions yaml/primary-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ spec:
- "-Dsecondary.cluster=secondary-cluster"
- "-Dsecondary.cluster.port=40000"
- "-Dsecondary.cluster.host=secondary-cluster-storage-wka"
- "-Dcoherence.metrics.legacy.names=false"
ports:
- name: federation
port: 40000
Expand All @@ -29,9 +28,9 @@ spec:
metrics:
enabled: true
port: 9612
image: coherence-demo:4.0.0-SNAPSHOT
image: coherence-demo:4.0.1-SNAPSHOT
imagePullPolicy: Always
replicas: 9
replicas: 3
---
apiVersion: coherence.oracle.com/v1
kind: Coherence
Expand All @@ -48,7 +47,6 @@ spec:
- "-Dprimary.cluster.host=primary-cluster-storage-wka"
- "-Dsecondary.cluster=secondary-cluster"
- "-Dsecondary.cluster.host=secondary-cluster-storage-wka"
- "-Dcoherence.metrics.legacy.names=false"
ports:
- name: http
port: 8080
Expand All @@ -62,6 +60,6 @@ spec:
metrics:
enabled: true
port: 9612
image: coherence-demo:4.0.0-SNAPSHOT
image: coherence-demo:4.0.1-SNAPSHOT
imagePullPolicy: Always
replicas: 1
Loading

0 comments on commit eefc946

Please sign in to comment.