copyright: years: 2018, 2020 lastupdated: "2023-02-12"
Setting up a Redis caching server
In a highly available SMS Gateway environment, a Redis caching server stores session state to be shared across SMS Gateway instances. The Redis container(s) is deployed on a node with the SMS Gateway container in a Kubernetes cluster, on private or public IBM Cloud.
Before you begin
-
Deploy Redis if you have not already done so. You will need the name of the Redis deployment to complete the steps to enable Redis caching for the SMS gateway.
-
SMS Gateway uses the Redisson java client, which supports connecting to a Redis caching server in Single instance mode only
-
Familiarize yourself with SMS Gateway deployment options and try out a basic Docker deployment in Getting started with SMS Gateway.
-
Install and configure the
kubectl
CLI so that you can access your Kubernetes cluster. -
Create a redissonConfig file, in JSON format
- Replace the values of
address
andpassword
from the redis deployment. - Change the value of
dnsMonitoringInterval
to-1
For reference:
{ "singleServerConfig":{ "idleConnectionTimeout":10000, "connectTimeout":10000, "timeout":3000, "retryAttempts":3, "retryInterval":1500, "password":null, "subscriptionsPerConnection":5, "clientName":null, "address": "redis://127.0.0.1:6379", "subscriptionConnectionMinimumIdleSize":1, "subscriptionConnectionPoolSize":50, "connectionMinimumIdleSize":24, "connectionPoolSize":64, "database":0, "dnsMonitoringInterval":5000 }, "threads":16, "nettyThreads":32, "codec":{ "class":"org.redisson.codec.FstCodec" }, "transportMode":"NIO" }
- Replace the values of
Configure the SMS Gateway to use Redis
-
Provide the secret for the
redissonConfig.json
file created above:kubectl create secret generic secret-redisconfig --from-file=secret-redisconfig=/path/redissonConfig.json
-
In deployment add in volumes, map the name to the secret created above:
"volumes": [ { "name": "secret-redisconfig", "secret": { "secretName": "secret-redisconfig" } }, .. ]
-
Add in
volumeMounts
to map the secret to themountPath
in the container:"volumeMounts": [ { "name": "secret-redisconfig", "mountPath": "/resources/redisConfig/" }, .. ]
-
Add these new SMS Gateway variables for deployment:
Variable | Default | Description |
---|---|---|
REDIS_ENABLED |
false | This enables the support of REDIS caching server. |
REDISSON_CONFIG_FILE |
n/a | Provide path to the file which provides the configuration for the Redis connection |
For reference:
"env": [
{
"name": "REDISSON_CONFIG_FILE",
"value": "/resources/redisConfig/redissonConfig.json"
},
{
"name": "REDIS_ENABLED",
"value": "true"
},
..
]
Connecting securely to Redis
- Get the certificate of your Redis deployment.
- Add the self-signed certificate in the SMS Gateway's Trust store
- Use
openssl
orikeyman
tools to add the Redis certificate to your existing Truststore key. - Update the following variables, which are already available in deployment or
docker-compose
:
- Use
Variable | Default | Description |
---|---|---|
SSL_TRUST_PASSPHRASE |
n/a | Password for the truststore |
SSL_TRUST_STORE_FILE |
n/a | Path to the trust file updated for the Redis certficate |
SSL_TRUST_FILE_TYPE |
JKS |
File type |