Chapter 8. Using Data Grid Deployment Configuration Templates

8.1. Data Grid Deployment Configuration Templates

Data Grid provides a set of templates that can help you deploy Data Grid for OpenShift with different configurations.

Important

As of Data Grid 7.3, these deployment configuration templates are deprecated. You should use cache-service or datagrid-service service templates instead.

TemplateDescription

datagrid73-basic

Run Data Grid for OpenShift without authentication or encryption.

datagrid73-https

Run Data Grid for OpenShift with an HTTPS route to securely access caches. Requires an OpenShift secret for encrypting network traffic.

datagrid73-mysql

Run Data Grid for OpenShift with a MySQL database as an ephemeral cache store. Requires an OpenShift secret for encrypting network traffic.

datagrid73-mysql-persistent

Run Data Grid for OpenShift with a MySQL database as a persistent cache store. Requires an OpenShift secret for encrypting network traffic.

datagrid73-postgresql

Run Data Grid for OpenShift with a PostgreSQL database as an ephemeral cache store. Requires an OpenShift secret for encrypting network traffic.

datagrid73-postgresql-persistent

Run Data Grid for OpenShift with a PostgreSQL database as a persistent cache store. Requires an OpenShift secret for encrypting network traffic.

datagrid73-partition

Run Data Grid for OpenShift with a partitioned data directory that preserves metadata for cache entries when the pod restarts.

8.2. Importing Deployment Configuration Templates

Import the Data Grid for OpenShift deployment configuration templates into OpenShift as follows:

  1. Log in to your OpenShift cluster.
  2. Import a specific template or all templates.

    • Import a specific template:

      $ oc create -f \
      https://raw.githubusercontent.com/jboss-container-images/jboss-datagrid-7-openshift-image/7.3-v1.8/templates/datagrid73-mysql.json
    • Import all templates:

      $ for resource in datagrid73-image-stream.json \
        datagrid73-basic.json \
        datagrid73-https.json \
        datagrid73-mysql-persistent.json \
        datagrid73-mysql.json \
        datagrid73-partition.json \
        datagrid73-postgresql.json \
        datagrid73-postgresql-persistent.json
      do
        oc create -f \
        https://raw.githubusercontent.com/jboss-container-images/jboss-datagrid-7-openshift-image/7.3-v1.8/templates/${resource}
      done
      Tip

      Use oc create to import new templates. Use oc replace --force to overwrite existing templates.

      Specify the namespace into which to import the templates with the -n option. For example, -n openshift imports resources into the global openshift namespace and requires administrative permissions.

  3. Import the Data Grid image.

    $ oc -n openshift import-image jboss-datagrid73-openshift:1.8
  4. Verify the templates are available on OpenShift.

    $ oc get templates -n openshift | grep datagrid73

8.3. Importing OpenShift Secrets

Some Data Grid for OpenShift deployment configuration templates require HTTPS and JGroups keystores.

Data Grid for OpenShift provides HTTPS and JGroups keystores that you can import for evaluation purposes. However, you should not use this secret in production environments.

Import the secret with the keystores into your project namespace as follows:

$ oc create \
  -f https://raw.githubusercontent.com/jboss-openshift/application-templates/master/secrets/datagrid-app-secret.json

For more information, see:

8.4. Deploying Data Grid for OpenShift

  1. Create a new deployment with the new-app command.
  2. Specify a template with the --template option.
  3. Set environment variables to configure the deployment with the -e option.

    For example, to create a deployment with the datagrid73-basic template that includes a cache named mycache that starts eagerly, run the following command:

    $ oc new-app --template=datagrid73-basic \
      -p USERNAME=${USERNAME} \
      -p PASSWORD=${PASSWORD} \
      -p CACHE_NAMES=mycache \
      -e MYCACHE_CACHE_START=EAGER

    See Environment Variables for information about supported environment variables.

8.5. Configuring Data Grid for OpenShift

After you create a Data Grid for OpenShift deployment, you can configure it with environment variables.

For example, you have a deployment configuration (dc) named datagrid-app with a cache named mycache. Configure mycache to start lazily as follows:

$ oc env dc/datagrid-app -e MYCACHE_CACHE_START=LAZY

When you modify a deployment configuration, the replication controller deploys a new version. Get the updated deployment configuration as follows:

$ oc get pods

NAME                    READY     STATUS    RESTARTS   AGE
datagrid-app-2-<id>     0/1       Running   0          58s
datagrid-app-2-deploy   1/1       Running   0          59s

Verify configuration changes as follows:

$ oc env pods/datagrid-app-2-<id> --list

# pods datagrid-app-2-<id>, container datagrid-app
CACHE_NAMES=mycache
MYCACHE_CACHE_START=LAZY
PASSWORD=${PASSWORD}
USERNAME=${USERNAME}
...