Skip to content

Latest commit

 

History

History
98 lines (64 loc) · 2.54 KB

File metadata and controls

98 lines (64 loc) · 2.54 KB

Local Redis Cluster

A 6-node Redis cluster you can run locally for development and testing. Available as both Docker Compose and Kubernetes configurations. Pulls the latest version of Redis, which includes search, JSON, time series, and probabilistic data structure modules.

Quick Start

Docker Compose

cd docker-compose
docker compose up -d

Your cluster is available at localhost:7001localhost:7006.

Kubernetes

Requires Docker Desktop with Kubernetes enabled.

kubectl apply -R -f kubernetes/

Watch for all pods to show Running and the init job to show Completed:

kubectl get pods -w

Your cluster is available at localhost:30001localhost:30006.

Connecting from Your App

Each cluster has 6 nodes accessible from localhost. Your app connects to these ports and uses a node address map to translate the internal hostnames that Redis advertises back to localhost.

Environment Ports
Docker Compose 7001–7006
Kubernetes 30001–30006

Both clusters can run simultaneously since the ports don't overlap.

See the app/ directory for a working Node.js example using node-redis that connects to the cluster, seeds data, and runs search queries.

Cluster Topology

Three simulated machines (alfa, bravo, charlie), each running one primary and one replica. Redis uses cluster-announce-human-nodename to track machine affinity, keeping a primary and its replica on different machines — just like a production deployment.

Tearing Down

Docker Compose

cd docker-compose
docker compose down

Kubernetes

kubectl delete -R -f kubernetes/

Upgrading Redis

Both configurations use the redis:latest tag. To pick up a new version:

Docker Compose

cd docker-compose
docker compose pull
docker compose down && docker compose up -d

Kubernetes

kubectl rollout restart statefulset redis

Within the same major version line, upgrades are seamless — Redis handles data format changes automatically. If anything goes sideways after an upgrade, wipe the data and start fresh:

# Docker Compose
cd docker-compose
docker compose down -v && docker compose up -d

# Kubernetes
kubectl delete -R -f kubernetes/
kubectl delete pvc -l app=redis
kubectl apply -R -f kubernetes/

Prerequisites

  • Docker Desktop
  • Kubernetes enabled in Docker Desktop (for the Kubernetes setup)