Redis Enterprise on Openshift to Manage Distributed Chase in Microservices

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. In this blog we describe how to use Radis chase to manage distributed chase between microservices.

Install Redis Enterprise Clusters Using Operators on Openshift

Redis Enterprise Software is distributed, in-memory NoSQL database server. Redis Enterprise Software extends open source Redis and delivers stable high performance, zero-downtime linear scaling and high availability cluster.

Prerequisites

A minimum of 3 nodes which support the following requirements:

  • RAM - At least 3GB with 4GB recommended

  • Persistent Storage - At least 10GB of free space with 20GB recommended.

  • A kubernetes version of 1.9 or higher

  • oc adm policy add-scc-to-group redis-enterprise-scc system:serviceaccounts:my-project


Install the Redis Operator
  1. Log in to your Openshift account as a cluster admin or super admin (so you have access to all the default projects in openshift). Create a new project, fill in the name and other details for the project and hit “Create” or you can use oc create project my-redis-project


2.    Install the Redis Operator form the OperatorHub. Before install the redis run the
    oc adm policy add-scc-to-group redis-enterprise-scc system:serviceaccounts:my-redis-project

    Search the redis on operator hub
    
    Intstall the redis operator


After install the operator we can see following instance ,RedisEnterpriseDatabase and RedisEnterpriseCluster.

3.    Create Redis Enterprise cluster instance.
Keep the name and rest of the things as default .Later we can change the values. (Login username and Password.)

    When the installation is completed, there are 5 pods including 3 Redis nodes. Each nodes        are distributed in Openshift worker nodes automatically.

    Also RedisEnterpriceCluster should be up and running.

** Note if your redis cluster not running , pods are still creating (You can see in the status column shows "Status:BootstrappingFirstPod"). Please check the Prerequisites.

4. Setup Redis UI
Create route -Secure route option is required, TLS termination-passthrough and Insecure Traffic-Redirect.


5. Login to the Redis UI
You can find UserID and Password at secrets “rec”.
Also we can create our own user once login to Redis cluster, navigate "access control" and create user with assign role.
6. Create Database
     Login to the Redis cluster ,Navigate to the databases. Then create database.
    
Provide database Name , Memory limit ,Data Persistence type and Password.

In redis there are two type of database persistence RDB and AOF.

RDB
  • The RDB persistence performs point-in-time snapshots of your dataset at specified intervals.
  • Period - 1 Hr , 6 Hr , 12 Hr
  • RDB is for Redis Database File. It's the snapshot style persistence format.
AOF
  • AOF which provides significantly higher persistence, but has some other disadvantages like higher disk utilization and slower server startup.
  • stands for Append Only File. It's the change-log style persistent format.
After create Database it will provide endpoint URL to access the database.

7. Create Load balancer

When you created redis-db, service will be created automatically. Use following command to see the service.
oc get svc
We can see in the openshiftUI.

Then we need to expose the service to the outside and create load balancer.

kind: Service apiVersion: v1 metadata: name: redis-service-lb namespace: my-project spec: ports: - protocol: TCP port: 12037 targetPort: 12037 #check the service pod selector: redis.io/bdb-6: '6' # check the pod selector value type: LoadBalancer 

 

port: this port should be equal to redis clusterIP ,and also selector should be equal to cluterIP service.

Check the service oc get svc then it will show the external IP endpoint to connect redis-db.

8 Access Database.

First we need to install redis-cli on your remote server. For my remote server, I am using AWS ubuntu EC2 instance then install the redis-client using following command.

The easiest way is to use “apt install redis”

logon to redis server
Host IP adress and Port number is defined at route above.
redis-cli -h <EXTERNAL-IP> -p <Portnumber(12037)> -a <redis-db password>

Then we can set the values and get the values ,we can use following commands.

set <Key> <Value> Ex <expiration time>

get <Key>

Redis Cluster on Openshift

















** Note

  1. Redis cache enterprise version provide 1month subscription
  2. The keys with no expiration time set will not expire. Other wise we need to set the expire the time.



Comments

Popular posts from this blog

Implement an event bus on Kubernetes with RabbitMQ using MassTransit in Microservice Architecture Part - 2

Provision Red Hat OpenShift Cluster On AWS