Deploy a Scalable Redis Cluster on VMware Tanzu Mission Control with Bitnami and Helm
Introduction
Redis is an open source in-memory remote database that supports many different data structures: strings, hashes, lists, sets, sorted sets, and more. It can be used as a database, a cache, and a message broker. Redis is ideal for building platforms that need support in communication between components and languages.
Bitnami has released a Helm chart that allows you to deploy a Redis Cluster configured with six nodes by default: three Redis masters and three replicas ensuring the data persistence. The topology of this chart allows both external and internal access to the cluster and also ensures failover.
This guide shows you how to deploy the Bitnami Redis Cluster Helm chart on a Kubernetes cluster managed through VMware Tanzu Mission Control, access it both externally and internally, and scale it up and down. In addition, you will learn how the disaster recovery works in this solution ensuring the availability of the cluster at any time under any circumstances.
Differences between Redis and Redis Cluster Helm chart
Bitnami offers two different ways to deploy a Redis Cluster, using the Redis Helm chart or the Redis Cluster Helm chart. Both solutions provide a simply and reliable way to run Redis in a production enevironment. Keep reading to discover the differences between them and check which one better suits your needs.
- The Redis Cluster Helm chart configures a cluster with six nodes by default with multiple writing points (three masters) and three slave nodes. The Redis Helm chart deploys three nodes by default in which there is only one writing point (one master) and two nodes for replicas (slaves).
- The Redis Cluster Helm chart will deploy a Redis Cluster topology with sharding while the Redis Cluster will deploy a master-slave cluster using Redis Sentinel.
- The Redis Cluster supports only one database - indicated if you have a big dataset - and Redis supports multiple databases.
- The Redis Cluster client must support redirection, while the client used for Redis doesn't need it.
- The topology of the Redis Cluster Helm chart allows users to access the cluster both externally and internally and you can both scale up and scale down the cluster in both accesses.
- The Bitnami Redis Cluster Helm chart also includes an additional feature: disaster recovery and failover. If the master node or even all the nodes are down, the cluster is automatically recovered and new master nodes are promoted to maintain the balance of the cluster and ensure that read/write operations continue without interruption.
Assumptions and prerequisites
This guide makes the following assumptions:
- You have a Kubernetes cluster running on Tanzu Kubernetes Grid and managed through Tanzu Mission Control. Learn how to start creating and managing your Kubernetes clusters with Tanzu Mission Control.
- You have the kubectl command line (kubectl CLI) and the Helm v3.x package manager installed and configured to work with your Kubernetes cluster. Learn how to install kubectl and Helm v3.x.
- You have the redis-cli command line installed. If you are running Docker in your machine, you can alternatively use the Bitnami Redis Dcoker container which bundles the redis-cli by default.
This guide explains how to deploy a Redis Cluster Helm chart on a Kubernetes cluster managed through VMware Tanzu Mission Control, but you can follow these steps for deploying Redis Cluster on the Kubernetes platform of your choice. Learn how to get started with Kubernetes.
Step 1: Deploy the Bitnami Redis Cluster Helm chart
The first step is to deploy the chart in your running cluster. The following example shows how to deploy the chart with the internal access mode that comes by default. Follow the instructions below:
The Redis Cluster deployment can be configured in either internal or external access mode. This configuration must be specified at deployment time and cannot be modified post-deployment. This section explains how to deploy the Redis Cluster Helm chart in internal access mode, and step 5 explains how to deploy it in external access mode.
Add the Bitnami Helm chart repository for your local client by executing the following in your local terminal:
helm repo add bitnami https://charts.bitnami.com/bitnami
Install the Bitnami Redis Cluster Helm chart by running the following command (remember to replace the RELEASE-NAME placeholder with the name you want for your deployment):
helm install RELEASE-NAME bitnami/redis-cluster
Once the chart is deployed, you will see a set of commands in the "NOTES" section to get your cluster and to connect to the cluster.

You can navigate to the Tanzu Mission Control user interface and see your deployment running in your cluster:

- After some minutes, you can check the number of pods created in the deployment.
- Run the kubectl get pods command in your terminal:

Or
- Navigate to the Tanzu Mission Control user interface, select your cluster, and in the "Nodes" tab, click the internal IP hostname. In the resulting screen, scroll down until you see the new pods deployed by the chart:

As you can see, the Helm chart deployed six pods in total (numbered from 0 to 5), three master and three slave nodes.
Step 2: Access Redis Cluster
In the "NOTES" section, you will see a message reminding you that the default access mode of Redis Cluster is only via your Kubernetes cluster. To connect to your Redis Cluster, follow these steps:
You can find the commands below in the "NOTES" section of your deployment with the correct values. Copy and paste them to perform the process described below.

Get the Redis password by executing:
export REDIS_PASSWORD=$(kubectl get secret --namespace default RELEASE-NAME -o jsonpath="{.data.redis-password}" | base64 --decode)
Run a Redis pod that you can use as a client:
kubectl run --namespace default RELEASE-NAME-client --rm --tty -i --restart='Never' \ --env REDIS_PASSWORD=$REDIS_PASSWORD \ --image docker.io/bitnami/redis-cluster:5.0.8-debian-10-r5 -- bash
Connect to Redis using redis-cli:
redis-cli -c -h REDIS-SERVICE-NAME -a $REDIS_PASSWORD
You can confirm that the Redis Cluster is operating correctly by executing a simple set of functions such as shown below:

As you can see in the image above, the request is automatically redirected to the right pod for the keys specified in the command.
Step 3: Scale up and down your cluster
The Redis Cluster Helm chart is comprised of six nodes by default (three master and three slave nodes) but you can easily scale up and down the solution according to your needs.
To scale up the cluster, execute the command below by replacing the cluster.nodes parameter with the desired number of nodes you want to deploy and cluster.update.currentNumberOfNodes with the current number of nodes your cluster is running. The following example shows how to scale up the cluster to eight nodes in total. (Remember that RELEASE-NAME is a placeholder, replace it with the name you gave to your chart release at deployment time).
helm upgrade --timeout 600s RELEASE-NAME --set "password=${REDIS_PASSWORD},cluster.nodes=8,cluster.update.addNodes=true,cluster.update.currentNumberOfNodes=6" bitnami/redis-cluster
After a few minutes, you can check that your cluster scaled up correctly by executing the kubectl get pods command. You will see output similar to this:

Navigate to the Tanzu Mission Control user interface, select your cluster, and in the "Nodes" tab, click the internal IP hostname. In the pods section, you will see two new pods created:

To scale the cluster down, you only have to upgrade the cluster by setting the number of nodes you want in the cluster.nodes parameter. (Remember that RELEASE-NAME is a placeholder, replace it with the name of your chart release.) In the following example, the cluster was scaled down by two nodes, restoring the initial state:
WarningTo ensure optimal operation of the Redis Cluster, it is highly recommended to run it with at least six nodes. The cluster can work with only five nodes if needed; however, under this scenario, if a master node crashes twice, no other master node will be available for promotion and the cluster will fail.
helm upgrade --timeout 600s RELEASE-NAME --set "password=${REDIS_PASSWORD},cluster.nodes=6"
You can now check the current number of nodes by executing the kubectl get pods command. You will see output similar to this:

Navigate to the Tanzu Mission Control user interface, select your cluster, and in the "Nodes" tab, click the internal IP hostname. In the pods section, you will see that the cluster now has two pods less:

Step 4: Check Redis Cluster failover
The Bitnami Redis Cluster Helm chart architecture was designed with an enterprise-grade feature: it is a failover cluster. Thus, if any node is down, or even if the complete cluster is down, the cluster automatically creates new nodes to avoid data loss.
To check how the failover works in the Redis Cluster, you can kill some pods and see how the cluster recovers them after a few minutes. In the example below, all pods will be deleted and all pods will be automatically recovered:
Execute the kubectl get pods command to see the name of each pod running in the cluster.
Run the kubectl delete pod command followed by the name of the pod you want to delete as shown below:
kubectl delete pod POD-NAME

- After a few minutes, execute again the kubectl get pods command. You will see how the entire cluster is automatically recovered:

The cluster will create some master nodes and some slave nodes to maintain data replication and read/write operations.
Step 5: Deploy the Bitnami Redis Cluster Helm chart by enabling external access
The Bitnami Redis Cluster Helm chart topology enables the external access mode allowing you to connect to any of the pods using the redis-cli tool installed from a different (non-cluster) host.
The external access mode must be enabled at deployment time. It is not possible to upgrade a Redis Cluster deployment (originally configured for internal access) to make it externally accessible since the nodes are configured to use internal addresses that will be stored in the persistent volumes, and this configuration cannot be changed via upgrade.
To access the Redis Cluster from outside, you need to set the cluster.externalAccess.enabled=true parameter when deploying the chart. This will create (by default) six LoadBalancer services, one for each Redis node. Follow these steps:
Execute the following command to deploy a Redis Cluster with external access enabled. Replace the RELEASE-NAME placeholder with the name you want to give to your deployment.
helm install RELEASE-NAME bitnami/redis-cluster --set cluster.externalAccess.enabled=true

- The next step is to get the external IPs of each service to finish the process. To do so, execute the kubectl get svc command as shown below. You will see an output message similar to this:

Perform an upgrade passing those IPs to the cluster.externalAccess.service.loadbalancerIP array. Copy the helm upgrade command that you will find in the "NOTES" section, then replace the load-balancerip-0, load-balancerip-1, etc., with the corresponding external IP addresses of the Load Balancer services that you have obtain in the step above:
helm upgrade RELEASE-NAME --set "cluster.externalAccess.enabled=true,cluster.externalAccess.service.type=LoadBalancer,cluster.externalAccess.service.loadBalancerIP[0]=load-balancerip-0,cluster.externalAccess.service.loadBalancerIP[1]=load-balancerip-1,cluster.externalAccess.service.loadBalancerIP[2]=load-balancerip-2,cluster.externalAccess.service.loadBalancerIP[3]=load-balancerip-3,cluster.externalAccess.service.loadBalancerIP[4]=load-balancerip-4,cluster.externalAccess.service.loadBalancerIP[5]=load-balancerip-5" bitnami/redis-cluster

Step 6: Access Redis Cluster from a different machine
To access the cluster from outside the server where you have the Redis Cluster running, it is necessary to have the redis-cli tool previously installed. Using the external access mode, you can connect to any of the pods, as all the IP addresses are public.
You can use the Bitnami Redis Docker container instead of installing the redis-cli to run that command line. To do so, execute docker run --rm -it bitnami/redis-cluster redis-cli -c set key val and then proceed as it is explained below.
To connect to any of the cluster nodes, you need execute the redis-cli command followed by the -c and -h options to redirect the client to the service you want to access. In this case, -h must be one of the six (by default) load balancer IP addresses.
Since you are accessing from a different machine, you will need to specify a password when passing the command above. This can be extremely insecure. To avoid any security issue, it is recommended to give REDISCLI_AUTH the same value as REDIS_PASSWORD. To do so:
- Get the Redis Cluster password by executing the command you will find under the "NOTES" section:

Copy an external IP address of any service load balancer.
Execute the command below by replacing the LOAD-BALANCER-IP placeholder with the external IP address you copied in the last step.
REDISCLI_AUTH=$REDIS_PASSWORD redis-cli -c -h LOAD-BALANCER-IP
Congratulations, now you are connected to your cluster! To check that everything works smoothly, you can run a simple command such as cluster nodes to check the status of your cluster. You will see output similar to this:

Useful links
In this tutorial
- Introduction
- Differences between Redis and Redis Cluster Helm chart
- Assumptions and prerequisites
- Step 1: Deploy the Bitnami Redis Cluster Helm chart
- Step 2: Access Redis Cluster
- Step 3: Scale up and down your cluster
- Step 4: Check Redis Cluster failover
- Step 5: Deploy the Bitnami Redis Cluster Helm chart by enabling external access
- Step 6: Access Redis Cluster from a different machine
- Useful links