Deploying a Redis Cluster in Google Kubernetes Engine using Helm Chart

Redis is an open-source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. This article will walk through simple steps to install a Redis Instance in Google Kubernetes Engine Cluster. By following this you can set up and deploy a Redis instance for the development environment in just 5 minutes in your existing K8s cluster.

This article assumes that you have a basic knowledge of handling K8s.

Prerequisite

Procedure for installing Redis using Helm

Step 1: Creating a secret credential for Redis

Create a secret named “ dev-redis-password” from a file containing a Redis password which you need to set for your instance. Note password should be stored in variable named redis-password

kubectl create secret generic dev-redis-password --from-file redis-password=./redis-password.txt

Step 2: Installing Redis using the Helm package manager

Run a command in your cluster terminal. Note that the secret file name should be the same in the command as created in the previous step. If you want to expose Redis to the outside you can choose type as LoadBalancer. In command, I have disabled the master-slave configuration. If you are setting up for production then can enable mater slave.

helm repo add bitnami https://charts.bitnami.com/bitnamihelm install dev-redis --set usePassword=true,usePasswordFile=true,existingSecret=dev-redis-password,cluster.enabled=false,master.persistence.enabled=false,master.service.type=LoadBalancer bitnami/redis

Step 3: Finding the Redis Load balancer IP

That’s it. Redis instance is installed on your server. After a few minutes, you can navigate to Services and Ingress and hit refresh. Your Redis will be listed under the Services tab. Find the IP address of Load balancer as shown in the below screenshot.

Step 4: Connecting to Redis instance

You can connect to Redis using CLI by using the following command

redis-cli -h your-load-balancer-ip -p 6379 -a your-secret-password ping

Another option is using a VS Code extension you can connect if you are in need of a GUI tool. I have explained it in my last post

https://blog.sharetechlinks.com/how-to-install-and-use-the-redis-explorer-visual-studio-code-extension-5-simple-steps/

This guide was just to get you started setting up Redis in K8s. There are several configurations possible while installing. You can refer to the official guide for more details and configure Redis based on your needs.

https://github.com/bitnami/charts/tree/master/bitnami/redis/#installing-the-chart

Originally published at https://blog.sharetechlinks.com on November 17, 2020.

Tech Enthusiast, Full Stack Software Engineer, Product Manager, Engineering Enterprise SaaS product

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store