You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+83-20
Original file line number
Diff line number
Diff line change
@@ -111,26 +111,89 @@ For security related configuration see [SECURITY.md](SECURITY.md).
111
111
112
112
### Session Caching
113
113
114
-
The Liberty session caching feature builds on top of an existing technology called JCache (JSR 107), which provides an API for distributed in-memory caching. There are several providers of JCache implementations. One example is [Hazelcast In-Memory Data Grid](https://hazelcast.org/). Enabling Hazelcast session caching retrieves the Hazelcast client libraries from the [hazelcast/hazelcast](https://hub.docker.com/r/hazelcast/hazelcast/) Docker image, configures Hazelcast by copying a sample [hazelcast.xml](ga/latest/kernel/helpers/build/configuration_snippets/), and configures the Liberty server feature [sessionCache-1.0](https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_admin_session_persistence_jcache.html) by including the XML snippet [hazelcast-sessioncache.xml](ga/latest/kernel/helpers/build/configuration_snippets/hazelcast-sessioncache.xml). By default, the [Hazelcast Discovery Plugin for Kubernetes](https://github.com/hazelcast/hazelcast-kubernetes) will auto-discover its peers within the same Kubernetes namespace. To enable this functionality, the Docker image author can include the following Dockerfile snippet, and choose from either client-server or embedded [topology](https://docs.hazelcast.org/docs/latest-development/manual/html/Hazelcast_Overview/Hazelcast_Topology.html).
115
-
116
-
```dockerfile
117
-
### Hazelcast Session Caching ###
118
-
# Copy the Hazelcast libraries from the Hazelcast Docker image
## This script will add the requested XML snippets and grow image to be fit-for-purpose
132
-
RUN configure.sh
133
-
```
114
+
The Liberty session caching feature builds on top of an existing technology called JCache (JSR 107), which provides an API for distributed in-memory caching. There are several providers of JCache implementations. The configuration for two such providers, Infinispan and Hazelcast, are outlined below.
115
+
116
+
1.**Infinispan(Beta Feature)** - One JCache provider is the open source project [Infinispan](https://infinispan.org/), which is the basis for Red Hat Data Grid. Enabling Infinispan session caching retrieves the Infinispan client libraries from the [Infinispan JCACHE (JSR 107) Remote Implementation](https://mvnrepository.com/artifact/org.infinispan/infinispan-jcache-remote) maven repository, and configures the necessary infinispan.client.hotrod.* properties and the Liberty server feature [sessionCache-1.0](https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_admin_session_persistence_jcache.html) by including the XML snippet [infinispan-client-sessioncache.xml](/releases/latest/kernel/helpers/build/configuration_snippets/infinispan-client-sessioncache.xml).
117
+
118
+
***Setup Infinispan Service** - Configuring Liberty session caching with Infinispan depends on an Infinispan service being available in your Kubernetes environment. It is preferable to create your Infinispan service by utilizing the [Infinispan Operator](https://infinispan.org/infinispan-operator/master/operator.html). The [Infinispan Operator Tutorial](https://github.com/infinispan/infinispan-simple-tutorials/tree/master/operator) provides a good example of getting started with Infinispan in OpenShift.
119
+
120
+
***Install Client Jars and Set INFINISPAN_SERVICE_NAME** - To enable Infinispan functionality in Liberty, the Docker image author can use the Dockerfile provided below. This Dockerfile assumes an Infinispan service name of `example-infinispan`, which is the default used in the [Infinispan Operator Tutorial](https://github.com/infinispan/infinispan-simple-tutorials/tree/master/operator). To customize your Infinispan service see [Creating Infinispan Clusters](https://infinispan.org/infinispan-operator/master/operator.html#creating_minimal_clusters-start). The `INFINISPAN_SERVICE_NAME` environment variable must be set at build time as shown in the example Dockerfile, or overridden at image deploy time.
121
+
***TIP** - If your Infinispan deployment and Liberty deployment are in different namespaces/projects, you will need to set the `INFINISPAN_HOST`, `INFINISPAN_PORT`, `INFINISPAN_USER`, and `INFINISPAN_PASS` environment variables in addition to the `INFINISPAN_SERVICE_NAME` environment variable. This is due to the Liberty deployment not having the access to the Infinispan service environment variables it requires.
122
+
123
+
```dockerfile
124
+
### Infinispan Session Caching ###
125
+
FROM ibmcom/websphere-liberty:kernel-java8-openj9-ubi AS infinispan-client
126
+
127
+
# Install Infinispan client jars
128
+
USER root
129
+
RUN infinispan-client-setup.sh
130
+
USER 1001
131
+
132
+
FROM ibmcom/websphere-liberty:kernel-java8-openj9-ubi AS open-liberty-infinispan
133
+
134
+
# Copy Infinispan client jars to Open Liberty shared resources
# Instruct configure.sh to use Infinispan for session caching.
138
+
# This should be set to the Infinispan service name.
139
+
# TIP - Run the following oc/kubectl command with admin permissions to determine this value:
140
+
# oc get infinispan -o jsonpath={.items[0].metadata.name}
141
+
ENV INFINISPAN_SERVICE_NAME=example-infinispan
142
+
143
+
# Uncomment and set to override auto detected values.
144
+
# These are normally not needed if running in a Kubernetes environment.
145
+
# One such scenario would be when the Infinispan and Liberty deployments are in different namespaces/projects.
146
+
#ENV INFINISPAN_HOST=
147
+
#ENV INFINISPAN_PORT=
148
+
#ENV INFINISPAN_USER=
149
+
#ENV INFINISPAN_PASS=
150
+
151
+
# This script will add the requested XML snippets and grow image to be fit-for-purpose
152
+
RUN configure.sh
153
+
```
154
+
155
+
* **Mount Infinispan Secret** - Finally, the Infinispan generated secret must be mounted as a volume under the mount point of `/platform/bindings/secret/` on Liberty containers. The default location of `/platform/bindings/secret/` can to be overridden by setting the `LIBERTY_INFINISPAN_SECRET_DIR` environment variable. When using the Infinispan Operator, this secret is automatically generated as part of the Infinispan service with the name of `<INFINISPAN_CLUSTER_NAME>-generated-secret`. For the mounting of this secret to succeed, the Infinispan Operator and Liberty must share the same namespace. If they do not share the same namespace, the `INFINISPAN_HOST`, `INFINISPAN_PORT`, `INFINISPAN_USER`, and `INFINISPAN_PASS` environment variables can be used instead(see the dockerfile example above). For an example of mounting this secret, review the `volumes` and `volumeMounts` portions of the YAML below.
156
+
157
+
```yaml
158
+
...
159
+
spec:
160
+
volumes:
161
+
- name: infinispan-secret-volume
162
+
secret:
163
+
secretName: example-infinispan-generated-secret
164
+
containers:
165
+
- name: servera-container
166
+
image: ol-runtime-infinispan-client:1.0.0
167
+
ports:
168
+
- containerPort: 9080
169
+
volumeMounts:
170
+
- name: infinispan-secret-volume
171
+
readOnly: true
172
+
mountPath: "/config/liberty-infinispan-secret"
173
+
...
174
+
175
+
```
176
+
177
+
2. **Hazelcast** - Another JCache provider is [Hazelcast In-Memory Data Grid](https://hazelcast.org/). Enabling Hazelcast session caching retrieves the Hazelcast client libraries from the [hazelcast/hazelcast](https://hub.docker.com/r/hazelcast/hazelcast/) Docker image, configures Hazelcast by copying a sample [hazelcast.xml](/releases/latest/kernel/helpers/build/configuration_snippets/), and configures the Liberty server feature [sessionCache-1.0](https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_admin_session_persistence_jcache.html) by including the XML snippet [hazelcast-sessioncache.xml](/releases/latest/kernel/helpers/build/configuration_snippets/hazelcast-sessioncache.xml). By default, the [Hazelcast Discovery Plugin for Kubernetes](https://github.com/hazelcast/hazelcast-kubernetes) will auto-discover its peers within the same Kubernetes namespace. To enable this functionality, the Docker image author can include the following Dockerfile snippet, and choose from either client-server or embedded [topology](https://docs.hazelcast.org/docs/latest-dev/manual/html-single/#hazelcast-topology).
178
+
179
+
```dockerfile
180
+
### Hazelcast Session Caching ###
181
+
# Copy the Hazelcast libraries from the Hazelcast Docker image
export INFINISPAN_USER=$(cat ${LIBERTY_INFINISPAN_SECRET_DIR:=/platform/bindings/secret}/identities.yaml | grep -m 1 username | sed 's/username://'| sed 's/[[:space:]]*//g'| sed 's/^-//')
0 commit comments