Environment Variables


Comma separated host and port details. Eg:, results in and respectively

Deploy Redis

  1. Clone the setup repo (

  2. Update the redis image and port details in redis-sts.yaml and redis-svc.yaml.

  3. If deploying redis without MOUNT , remove the below one from redis-sts.yaml

Volume Mount:- name: data

     mountPath: /data

     readOnly: false


     - name: data


path: /mnt/redis

  1. Execute from the downloaded repo. (Specify the k8s namespace and cluster size as prompted). 

  2. Minimum size: 6. Master - 3 and slave -3

  3. Once has executed successfully, we can see the pods created like below
    redis-cluster-0, redis-cluster-1 … redis-cluster-5 .

Setting up Redis-Cluster

Now, we are going to set up a cluster by executing the below commands one by one.

Replace the _namespace_ with yours.

  1. Get the  IP  address of the redis-cluster pods.

    kubectl get pods -l app=redis-cluster -o jsonpath='{range.items[*]}{.status.podIP}:6379 ' -n _namespace_

  1. Create a cluster between the pods.

kubectl exec -it redis-cluster-0 -n _namespace_ -- redis-cli --cluster create --cluster-replicas 1 $(kubectl get pods -l app=redis-cluster -o jsonpath='{range.items[*]}{.status.podIP}:6379 ' -n _namespace_)

  1. Get the cluster information

kubectl exec -it -n _namespace_ redis-cluster-0 -- redis-cli cluster info

  1. Verify the master and slaves are connected successfully.

for x in $(seq 0 5); do echo "redis-cluster-$x"; kubectl exec redis-cluster-$x -n _namespace_ -- redis-cli role; echo; done