DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Taking KubeMQ Build & Deploy for a Test Drive: My Thoughts and Impressions
  • A Guide to Container Runtimes
  • Docker vs Kubernetes: Which to Use and When?
  • Using KRaft Kafka for Development and Kubernetes Deployment

Trending

  • Transforming AI-Driven Data Analytics with DeepSeek: A New Era of Intelligent Insights
  • Kubeflow: Driving Scalable and Intelligent Machine Learning Systems
  • Performing and Managing Incremental Backups Using pg_basebackup in PostgreSQL 17
  • AI-Based Threat Detection in Cloud Security
  1. DZone
  2. Software Design and Architecture
  3. Microservices
  4. Getting Started With Kubernetes and Redis using Redis Enterprise

Getting Started With Kubernetes and Redis using Redis Enterprise

Enjoy using Redis clusters? Well, their Docker container makes it a perfect match for Kubernetes' orchestration capabilities, ensuring availability.

By 
Cihan B. user avatar
Cihan B.
·
May. 04, 17 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
15.6K Views

Join the DZone community and get the full member experience.

Join For Free

Kubernetes provides simpler orchestration with containers and has been widely adopted. It is easy to get a Redis Enterprise cluster on Kubernetes with the new Redis Enterprise Docker container.

We will use the Docker container for version 4.5 of Redis Enterprise for the steps here. You can find more information on the container image on Docker Hub and see details on how to deploy the container locally with Docker below:

  • Working with Redis Enterprise and Docker
  • Getting Started with Redis Enterprise and Docker on Windows.
  • Getting Started with Redis Enterprise and Docker on Mac OSx.
  • Getting Started with Redis Enterprise and Docker on Linux.

Deploying Redis Enterprise With Kubernetes on Google Cloud

We will go through four steps to set up our cluster with Redis Enterprise.

  • Step #1: Create a Kubernetes cluster on Google Cloud.
  • Step #2: Deploy the Redis Enterprise containers to Kubernetes cluster.
  • Step #3: Setup Redis Enterprise cluster.
  • Step #4: Create a Redis database and test your connectivity.

Note: The deployment is deliberately simplified and is great for getting started with Kubernetes and Redis Enterprise fast. It certainly isn’t intended for production use.

Requirements

The steps below were performed using the latest Google Cloud SDK and the kubectl tool on MacOS. There may be slight differences in detailed instructions with another operating system.

Step #1: Create a Kubernetes Cluster on Google Cloud

Let's first get your command line environment set up.

  • First, authenticate to your Google Cloud environment.

gcloud auth login

  • Get the default project_ID set. Here is how you can list and set the project context to be used with the upcoming commands. Note that you will get some random name like mine (“speedy-lattice-166011”) if you have not explicitly specified an ID.

gcloud projects list gcloud config set project speedy-lattice-166011

  • Finally, let’s get the default zone/geography where you want your cluster set up. Here is how you can list the zones and set the zone context to be used:

gcloud compute zones list
gcloud config set compute/zone europe-west1-c


Let’s get the Kubernetes cluster up and running.

On your Google Cloud console, click on “Container Engine” option on the left nav and create a new cluster.

getting-started

To define your Kubernetes cluster, give it a name and keep the size of the cluster to 3 nodes. we’ll use all 3 nodes to deploy the Redis Enterprise cluster. I recommend you keep the size of nodes as at least 2 cores and over 7GB RAM.

getting-started

Note: It may take a few minutes to create the cluster. Ensure the Kubernetes cluster creation is complete before proceeding to the next step.

For best placement, Redis Enterprise pods should be placed on separate physical nodes in the Kubernetes cluster. This ensures better availability when facing node failures. Placing multiple Redis Enterprise nodes in the same physical host can cause multiple nodes to fail at once and may result in availability and data loss. To ensure we can guarantee better placement, we need to upgrade the Kubernetes cluster to 1.6.2 or better. You can do the upgrade in the details page of the Kubernetes cluster deployment we just created.

getting-started

Note: By the way, If you are a command line kind of person, here is how you can simplify the three screen above into 2 simple lines;
gcloud container clusters create cluster-1 --num-nodes=3 -m n1-standard-2
gcloud container clusters upgrade cluster-1 --master --cluster-version=1.6.2


Finally, to finish the Kubernetes deployment, you need to get the Kubernetes console up and running and start the Kubernetes proxy. In the terminal window, run the following commands.

Connect to the Kubernetes cluster:
gcloud container clusters get-credentials cluster-1

The output will read:

# Fetching cluster endpoint and auth data.
# kubeconfig entry generated for cluster-1. 


And finally, start the Kubernetes proxy:

kubectl proxy

Step #2: Deploy the Redis Enterprise containers to Kubernetes cluster

You now need to feed the container YAML file to provision Redis Enterprise cluster. A sample YAML file can be found here.
kubectl apply -f redis-enterprise.yaml

If the deployment is successful, the output should look like this:

# deployment "redispack-deployment" created 
# service "redispack" created


You can now see the list of container nodes deployed on the Kubernetes cluster. Simply run the following to see the list of nodes:
kubectl get po

 The output will look something like this:

NAME READY STATUS RESTARTS AGE
redispack-deployment-709212938-765lg 1/1 Running 0 7s
redispack-deployment-709212938-k8njr 1/1 Running 0 7s
redispack-deployment-709212938-kcjd7 1/1 Running 0 7s


Step #3: Set Up the Redis Enterprise Cluster

We are now ready to create the Redis Enterprise cluster. There is one small change that needs to be made to the container to get networking to work properly: We need to change the CSS binding to 0.0.0.0. To do this, you need to run the following in each container with each iteration using the pod's name from the kubectl get po output above.

kubectl exec -it redispack-deployment-709212938-765lg -- bash
 # sudo su -
 # sed ‘s/bind 127.0.0.1/bind 0.0.0.0/g’ -i /opt/redislabs/config/ccs-redis.conf
 # cnm_ctl restart


With this, let’s provision the first node or the Redis Enterprise cluster.

kubectl exec -it redispack-deployment-709212938-765lg "/opt/redislabs/bin/rladmin" cluster 
create name cluster.local username cihan@redislabs.com password redislabs123 flash_enabled


We will need the IP address of the first node to be able to instruct the following nodes to join the cluster.

kubectl exec -it redispack-deployment-709212938-765lg ifconfig | grep "inet addr"


In my case, the output was 10.0.2.10. Let's add nodes 2 and 3 to the cluster:

kubectl exec -it redispack-deployment-709212938-k8njr "/opt/redislabs/bin/rladmin" cluster join 
username cihan@redislabs.com password redislabs123 nodes 10.0.2.10 flash_enabled


kubectl exec -it redispack-deployment-709212938-kcjd7 "/opt/redislabs/bin/rladmin" cluster join 
username cihan@redislabs.com password redislabs123 nodes 10.0.2.10 flash_enabled

Step #4: Create a Redis Database and Test Your Connectivity

We are now ready to create the database and connect to it. The following curl command can be used to create a database on port 12000. The database will be named “sample-db”.

kubectl exec -it redispack-deployment-709212938-765lg bash
# curl -k -u "cihan@redislabs.com:redislabs123" --request POST --url "https://localhost:9443/v1/bdbs" --header 'content-type: application/json' --data '{"name":"sample-db","type":"redis","memory_size":1073741824,"port":12000}'


To test the connection to the database, we will use the redis-cli tool. Here is a simple set followed by a get to validate the Redis deployment.

kubectl exec -it redispack-deployment-709212938-765lg bash
# /opt/redislabs/bin/redis-cli -p 12000
# 127.0.0.1:12000> set a 1
# OK
# 127.0.0.1:12000> get a
# "1"
# 127.0.0.1:12000>


Note: To clean up the deployment, you can simply delete the cluster using the following command line:
gcloud container clusters delete cluster-1

Kubernetes Redis (company) Docker (software)

Published at DZone with permission of Cihan B., DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Taking KubeMQ Build & Deploy for a Test Drive: My Thoughts and Impressions
  • A Guide to Container Runtimes
  • Docker vs Kubernetes: Which to Use and When?
  • Using KRaft Kafka for Development and Kubernetes Deployment

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!