Installing a redis cluster in Kubernetes

Prep work

The example below will use the OpenEBS hostpath storage classes and operators. Installing openebs is described in my kubernetes storage post.

Determine the storageclass name.

 kubectl get

As I’m currently testing openebs in microk8s I will use the storage class named openebs-hostpath in the below examples. As a redis cluster handles its own data

If there are any affinity rules that are wanted set the labels now. This example is going to set a label on a node and set the affinity to look for that as a soft (preferredDuringSchedulingIgnoredDuringExecution) target.

kubectl label nodes [NodeName] workertype=database


helm repo add bitnami

kubectl create namespace redis-demo

helm install redis --set "global.redis.password=HiThere,global.storageClass=openebs-hostpath,redis.nodeAffinityPreset.type=soft,redis.nodeAffinityPreset.key=workertype,redis.nodeAffinityPreset.values[0]=database" bitnami/redis-cluster --namespace redis-demo

kubectl -n redis-demo get pods

If external access is desired it should be set at deployment by setting cluster.externalAccess.enabled to true as part of the above –set command.


See the redis-cluster chart docs for externalAccess options.


With those commands run there should be some output that looks like the following.

NAME: redis
LAST DEPLOYED: Sat Feb  5 23:08:17 2022
NAMESPACE: redis-demo
STATUS: deployed
CHART NAME: redis-cluster
APP VERSION: 6.2.6** Please be patient while the chart is being deployed **

To get your password run:

export REDIS_PASSWORD=$(kubectl get secret --namespace "redis-demo" redis-redis-cluster -o jsonpath="{.data.redis-password}" | base64 --decode)

You have deployed a Redis™ Cluster accessible only from within you Kubernetes Cluster.INFO: The Job to create the cluster will be created. To connect to your Redis™ cluster:

  1. Run a Redis™ pod that you can use as a client:
kubectl run --namespace redis-demo redis-redis-cluster-client --rm --tty -i --restart='Never' --env REDIS_PASSWORD=$REDIS_PASSWORD --image -- bash
  1. Connect using the Redis™ CLI:
redis-cli -c -h redis-redis-cluster -a $REDIS_PASSWORD

Remove redis cluster

helm delete redis --namespace redis-demo
kubectl delete namespace redis-demo