Skip to content

Commit

Permalink
Data Grid scenario fixes and updates (openshift-labs#1198)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesfalkner authored Jun 18, 2021
1 parent 8fe55ba commit b154a68
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 36 deletions.
Binary file added assets/middleware/dg/dgdev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/middleware/dg/entries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/middleware/dg/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/middleware/dg/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 17 additions & 7 deletions middleware/rhoar-getting-started-rhdg/01-op.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,34 @@ An [Operator](https://www.openshift.com/learn/topics/operators) is a method of p

Operators can be installed using the OpenShift web console, or via the command line and YAML. For simplicity we'll use the CLI for now, and the web console later.

### Create namespace
**1. Create namespace**

For this scenario, let's create a project that you will use to house your application. Click:

`oc new-project dgdemo --display-name="Data Grid Demo"`{{execute}}

### Create OperatorGroup
**2. Create OperatorGroup**

Operators need an OperatorGroup to give it the necessary context and permissions to operator, so create it by clicking this command:

`oc apply -f - << EOF
```
oc apply -f - << EOF
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: datagrid
spec:
targetNamespaces:
- dgdemo
EOF`{{execute}}
EOF
```{{execute}}
### Create Subscription
**3. Create Subscription**
And now we can install the Data Grid Operator by creating a _Subscription_ to it. Click here to do that:
`$ oc apply -f - << EOF
```
oc apply -f - << EOF
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
Expand All @@ -55,7 +58,14 @@ spec:
name: datagrid
source: redhat-operators
sourceNamespace: openshift-marketplace
EOF`{{execute}}
EOF
```{{execute}}
Wait for the Operator to be installed using this command:
`oc rollout status -w deployment/infinispan-operator-new-deploy`{{execute}}
> **NOTE**: If this command reports **Error from server (NotFound)**, it may take a few moments to download and deploy the operator. Just wait a few seconds and click the command again until it reports success.
Verify the Operator is installed and fully armed and operational:
Expand Down
22 changes: 14 additions & 8 deletions middleware/rhoar-getting-started-rhdg/02-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ then log in:

![Web Console Login](/openshift/assets/middleware/dg/login.png)

Click **Skip Tour** to skip the new user introduction.

You'll see the operator pod deployed:

![Operator](/openshift/assets/middleware/dg/opover.png)

### Create Data Grid Cache
Select the _Developer View_ using the selector on the left and click **Skip Tour** to skip the new user introduction:

![Operator](/openshift/assets/middleware/dg/dgdev.png)

### Create Data Grid Cache service

With the Operator installed, we can now start creating instances of Data Grid.

Expand All @@ -41,11 +43,13 @@ Change the name to `datagrid-service` and set the number of _replicas_ to `2`:

![Operator](/openshift/assets/middleware/dg/opconfig.png)

Finally, scroll to the bottom and click **Create**. You'll now see your new Data Grid cluster and its 2 replicas spin up. When you see the solid blue circles you'll know its done.
Finally, scroll to the bottom and click **Create**. You'll now see your new Data Grid cluster and its 2 replicas spin up. Click the following command to wait for it to finish:

`oc rollout status -w statefulset/datagrid-service`{{execute}}

> **NOTE**: It may take a minute or so to fully spin up, as the container images must be downloaded the first time.
Click on the box for `datagrid-service` to see its details:
Now click on the box for `datagrid-service` to see its details:

![Operator](/openshift/assets/middleware/dg/dgdeploy.png)

Expand All @@ -55,7 +59,8 @@ Here you can see the two replicas running in 2 separate pods.

Data Grid has a built in single-port endpoint for all network access, including an administrative console for displaying cache configuration, statistics, and creating/changing data in the grid. The console is accessed over the same networking port as the grid itself. To get to it in this environment, we'll need to create a specialized Route to it. Click the following command to create this Route:

`$ oc apply -f - << EOF
```
oc apply -f - << EOF
kind: Route
apiVersion: route.openshift.io/v1
metadata:
Expand All @@ -71,15 +76,16 @@ spec:
termination: reencrypt
insecureEdgeTerminationPolicy: Allow
wildcardPolicy: None
EOF`{{execute}}
EOF
```{{execute}}
You'll also need to get the default username/password to use when logging into the console. Retrieve them by clicking this command:
`oc get secret datagrid-service-generated-secret -o jsonpath="{.data.identities\.yaml}" | base64 --decode`{{execute}}
> **NOTE**: These are default autogenerated credentials that can be disabled or reconfigured when for production use.
You should now be able to click here to [connect to the Data Grid Console](https://my-dg-dgdemo-[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com).
You should now be able to click here to [connect to the Data Grid Console](https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com).
> **NOTE**: You may need to accept browser warnings about self-signed insecure connections. We are not using real security certificates here for this demo!
Expand Down
39 changes: 24 additions & 15 deletions middleware/rhoar-getting-started-rhdg/03-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,42 @@ You might have noticed that in our first exercise we created the Cache service (

Let's create a simple cache in our cache service using the command line. Click on the following to create a new Cache custom resource (this could also be done via the web console):

`oc apply -f - << EOF
```
oc apply -f - << EOF
apiVersion: infinispan.org/v2alpha1
kind: Cache
metadata:
name: mycachedefinition
spec:
clusterName: datagrid-service
name: mycache
EOF`{{execute}}
EOF
```{{execute}}
This creates a basic cache called `mycache`. There are [many](https://access.redhat.com/documentation/en-us/red_hat_data_grid/8.2/html-single/configuring_data_grid/index#cache_modes), _many_ options for configuring caches but we'll just stick with the defaults for now.
You can see it in the [Data Grid Admin console](https://my-dg-dgdemo-[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com), you can see the new cache:
You can see it in the [Data Grid Admin console](https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/console), you can see the new cache:
> **NOTE**: You may need to reload the browser page to see it!
![Operator](/openshift/assets/middleware/dg/dgnewcache.png)
## Adding data
Let's add some data! Click this command to add some random data to the `mycache` cache:
Let's add some data! We'll use the Data Grid REST interface to add it. Click this command to add some random data to the `mycache` cache:
```
for i in {1..100} ; do
curl -H 'Content-Type: text/plain' -k -u developer:$PASSWORD -X POST -d "myvalue$i" https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey$i
echo "Added mykey$i:myvalue$i"
done
```{{execute}}
`for i in {1..200} ; do
curl -k -u developer:$PASSWORD -X POST -d "myvalue$i" https://my-dg-dgdemo-[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey$i
done`{{execute}}
This will add 100 entries under keys `mykey1`, `mykey2`, ... with values `myvalue1`, `myvalue2`...
This will add 200 entries under keys `mykey1`, `mykey2`, ... with values `myvalue1`, `myvalue2`...
You can see the entries in the [cache overview in the admin console](https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/console/cache/mycache):
You can see the entries in the [cache overview in the admin console](https://my-dg-dgdemo-[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/console/cache/mycache):
> You may need to click on the **Entries** tab.
![Operator](/openshift/assets/middleware/dg/entries.png)
Expand All @@ -57,25 +66,25 @@ The URLs through which you invoke cache operations contain cache and key names.
Let's retrieve one of our cache entries. Click the following command:
`curl -k -u developer:$PASSWORD https://my-dg-dgdemo-[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`{{execute}}
`curl -k -u developer:$PASSWORD https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`{{execute}}
You should see its value returned `myvalue22`.
Now update it:
`curl -k -u developer:$PASSWORD -X PUT -d "mynewvalue22" https://my-dg-dgdemo-[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`
`curl -H 'Content-Type: text/plain' -k -u developer:$PASSWORD -X PUT -d "mynewvalue22" https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`{{execute}}
This updates the value to `mynwvalue22`. Retrieve it to verify:
`curl -k -u developer:$PASSWORD https://my-dg-dgdemo-[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`{{execute}}
`curl -k -u developer:$PASSWORD https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`{{execute}}
Now lets delete it:
`curl -k -u developer:$PASSWORD -X DELETE https://my-dg-dgdemo-[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`{{execute}}
`curl -k -u developer:$PASSWORD -X DELETE https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`{{execute}}
And retrieve it (it will fail with `HTTP 404`):
`curl -i -k -u developer:$PASSWORD https://my-dg-dgdemo-[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`{{execute}}
`curl -i -k -u developer:$PASSWORD https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/rest/v2/caches/mycache/mykey22`{{execute}}
This demonstrates basic RESTful access to Data Grid.
Expand All @@ -85,6 +94,6 @@ The admin console has built in metrics about each cache. Click the _Metrics_ tab
![Operator](/openshift/assets/middleware/dg/adminmetrics.png)
You can also visit the **Global Metrics** screen to see more info about the Data Grid service as a whole, and confirm cluster status on the **Cluster Membership** screen.
You can also visit the [Global Metrics](https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/console/global-stats) screen to see more info about the Data Grid service as a whole, and confirm cluster status and the 2 replicas on the [Cluster Membership](https://my-dg-dgdemo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/console/cluster-membership) screen.
7 changes: 7 additions & 0 deletions middleware/rhoar-getting-started-rhdg/99-outro.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
In this tutorial, you got an overview of Red Hat Data Grid and learned how easy it is to invoke basic cache operations over REST.

More information on Data Grid can be found below:

* [Red Hat Data Grid product page](https://www.redhat.com/en/technologies/jboss-middleware/data-grid)
* [Official Documentation](https://access.redhat.com/documentation/en-us/red_hat_data_grid/)
* [Infinispan community](https://infinispan.org/)


2 changes: 1 addition & 1 deletion middleware/rhoar-getting-started-rhdg/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"intro": {
"text": "00-intro.md",
"courseData": "env-init.sh",
"courseData": "run-init.sh",
"code": "set-env.sh"
},
"finish": {
Expand Down
13 changes: 9 additions & 4 deletions middleware/rhoar-getting-started-rhdg/run-init.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/env bash
#rm -rf ~/projects/rhoar-getting-started
ssh root@host01 "mkdir -p /root/projects && cd /root/projects
#ssh root@host01 "yum install tree -y"
mkdir -p /root/projects

echo "-w \"\n\"" >> ~/.curlrc

curl -sL -w '' https://raw.githubusercontent.com/openshift-labs/learn-katacoda/master/assets/middleware/install-openjdk.sh > /tmp/jdk.sh

chmod a+x /tmp/jdk.sh
/tmp/jdk.sh

14 changes: 13 additions & 1 deletion middleware/rhoar-getting-started-rhdg/set-env.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
~/.launch.sh
#!/bin/bash
export JAVA_HOME="/usr/local/jdk-11.0.10+9"
export PATH=$JAVA_HOME/bin:$PATH
echo "export JAVA_HOME=$JAVA_HOME" >> ~/.bashrc
echo "export PATH=$JAVA_HOME/bin:\$PATH" >> ~/.bashrc
clear
echo 'echo Installing the latest Java runtime..' > /tmp/launch.sh
echo 'until ${JAVA_HOME}/bin/java --version >& /dev/null ; do sleep 1; echo -n .; done' >> /tmp/launch.sh
echo 'echo' >> /tmp/launch.sh
echo 'echo "Ready!"' >> /tmp/launch.sh
chmod a+x /tmp/launch.sh
cd ~/projects/
clear
/tmp/launch.sh

0 comments on commit b154a68

Please sign in to comment.