Backend Development 15 min read

Deploying Redis Sentinel with Portainer and Integrating It into Spring Boot

This tutorial walks through installing Portainer, using it to deploy a Redis master‑slave‑sentinel cluster with Docker Compose, creating a custom bridge network, testing failover, and finally integrating the sentinel setup into a Spring Boot application with Lettuce connection pooling and sample controller code.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Deploying Redis Sentinel with Portainer and Integrating It into Spring Boot

The author introduces Portainer as a convenient Docker graphical management tool and outlines the steps to install it using a simple portainer.yml Docker‑Compose file.

After launching Portainer with docker-compose -f portainer.yml up -d , the UI is accessed via http:// :9000 where users can manage containers, images, and networks.

As a practical example, the article demonstrates deploying a Redis Sentinel architecture (one master, two slaves, three sentinel nodes) entirely through Portainer.

First, a redis-cluster.yml file defines the master and two slave services, specifying custom external ports and password‑protected commands; the stack is started with docker-compose -f redis-cluster.yml up and verified in Portainer’s container list.

Next, a custom bridge network named redis-sentinel is created via Portainer’s Network UI and the Redis containers are attached to it, isolating the sentinel topology from other workloads.

A separate redis-sentinel.yml file defines three sentinel services, each mounting its own sentinel.conf and joining the redis-sentinel network; the sentinel configuration includes monitoring the master’s IP, authentication, and failover parameters.

Failover is tested by stopping the master container through the Portainer UI; the remaining sentinels automatically elect a new master, which can be observed in their logs.

For application integration, the guide adds spring-boot-starter-data-redis and commons-pool2 (Lettuce pool) dependencies, then configures spring.redis.sentinel properties (master name, node addresses, passwords) and Lettuce pool settings in application.yml .

Sample Java code shows the LettuceConnectionFactory bean creation path, the RedisTemplate injection, a simple DTO ( RedisStrDto ), and REST endpoints ( /setKey and /getKey/{key} ) for storing and retrieving string values.

Finally, API calls are demonstrated to verify that data written to the master is correctly replicated to the slaves and that the Spring Boot service can interact with the Redis Sentinel cluster without issues.

backendDockerSpring BootLettuceDocker ComposePortainerRedis Sentinel
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.