Skip to content

chore: replace the redis cluster in docker-compose with valkey - #2140

Merged
netomi merged 3 commits into
mainfrom
chore/valkey-cluster-compose
Sep 3, 2026
Merged

chore: replace the redis cluster in docker-compose with valkey#2140
netomi merged 3 commits into
mainfrom
chore/valkey-cluster-compose

Conversation

@netomi

@netomi netomi commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Replaces the six-node Redis cluster in docker-compose.yml with Valkey 9.1, and tidies up the surrounding compose setup.

Redis → Valkey

  • valkey/valkey:9.1 images, valkey-server / valkey-cli, data under ./data/valkey, services renamed redis-node-*valkey-node-*, profile renamed redisvalkey.
  • redis.confvalkey.conf, with masteruser / masterauth renamed to Valkey's primaryuser / primaryauth.
  • REDISCLI_AUTH stays as-is: valkey-cli still reads the password from that exact variable (there is no VALKEYCLI_AUTH), so there is a comment in the file to stop it looking like a leftover.
  • Published ports (7001-7006 → 7000) are unchanged, so the commented-out cluster config in server/src/dev/resources/application.yml still points at the right nodes. Only its comment wording is updated — the property keys stay spring.data.redis, as required by the Jedis client.

Compose cleanups

Valkey bootstraps a cluster exactly the way Redis does (valkey-cli --cluster create; the official image has no env-driven cluster bootstrap, and no self-forming cluster config exists in 8.x or 9.x). These are improvements to our own setup rather than anything Valkey-specific:

  • The six node services differ only in name, published port and data directory, so they now share an x-valkey-node anchor. The block goes from ~145 lines to ~55.
  • The init service waits on condition: service_healthy for all six nodes instead of sleep 10, and passes --cluster-yes instead of piping in a yes (which also drops the bash -c wrapper).
  • Init is now idempotent. Previously a second up on existing data failed with [ERR] Node redis-node-1:7000 is not empty; it now creates the cluster only when node-1 still knows just itself. It checks cluster_known_nodes rather than cluster_state, because nodes.conf is loaded at node startup while the state only turns ok once the nodes have gossiped — gating on the state is racy against the health check.

redisinsight → valkey-admin

redisinsight is replaced by valkey/valkey-admin, which serves the same purpose for Valkey and takes its connection from VALKEY_HOST / VALKEY_PORT / VALKEY_USERNAME / VALKEY_PASSWORD, so there is no manual setup in the UI. It listens on 8080 and is published as 8090, since the server service already publishes 8080.

Usage is now docker compose --profile valkey up -d, plus --profile valkey-admin for the UI at http://localhost:8090.

Testing

Run against the actual compose file:

  • Fresh up: cluster forms with 3 primaries / 3 replicas, all 16384 slots covered, all nodes agreeing on slot config, init exits 0. master_link_status:up on a replica confirms primaryauth works with the default user disabled.
  • Restart on existing data: init prints valkey cluster already initialized and exits 0.
  • valkey-admin reachable on 8090 and connected — node-1's client list shows valkey_admin_orchestrator_client authenticated as openvsx issuing cluster slots.

🤖 Generated with Claude Code

Swap the six-node Redis cluster for Valkey 9.1: valkey/valkey images,
valkey-server/valkey-cli, data under ./data/valkey, and the compose
profile renamed from `redis` to `valkey`. redis.conf becomes valkey.conf
with masteruser/masterauth renamed to primaryuser/primaryauth.
REDISCLI_AUTH stays, as valkey-cli still reads the password from it.

Valkey bootstraps a cluster the same way Redis does, but the surrounding
compose setup is tidied up while we are here:

- the six node services differ only in name, port and data directory, so
  they now share an x-valkey-node anchor
- the init service waits for the nodes to be healthy instead of sleeping
  for a fixed 10s, and passes --cluster-yes rather than piping in a yes
- init is idempotent: it only creates the cluster when node-1 still knows
  just itself, so a restart on existing data no longer fails. It checks
  known nodes rather than cluster_state because nodes.conf is loaded at
  startup while the state only turns ok once the nodes have gossiped

redisinsight is replaced by valkey-admin, which serves the same purpose
for Valkey and takes its connection from the environment, so there is no
manual setup in the UI. It listens on 8080, published as 8090 because the
server service already publishes 8080.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@netomi
netomi requested review from cstamas and a lite review from Copilot September 3, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The cluster init idempotency check uses a potentially incorrect ERE regex ($$) that can cause fresh cluster creation to be skipped.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the development Docker Compose setup to replace the existing Redis Cluster services with a Valkey (9.1) cluster, including updated node configuration and an updated optional admin UI service.

Changes:

  • Replace the six Redis cluster node services and init container with Valkey equivalents (including YAML anchors to reduce duplication).
  • Update cluster node configuration from Redis masteruser/masterauth to Valkey primaryuser/primaryauth.
  • Update the dev application.yml comment to refer to Valkey (keeping Spring Redis property keys unchanged).
File summaries
File Description
docker-compose.yml Replaces Redis cluster services with Valkey services, introduces shared node anchor, updates init flow and adds Valkey Admin UI service.
valkey.conf Updates node config header and switches replication auth directives to Valkey’s primary* names.
server/src/dev/resources/application.yml Updates comment wording to reference Valkey instead of Redis.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docker-compose.yml
netomi and others added 2 commits September 3, 2026 09:28
Valkey Admin discovers the topology from the pre-configured connection
once at startup and never retries, so it has to start after the cluster
exists - otherwise it comes up alongside the nodes, finds no cluster and
sits idle with no collectors. Wait for valkey-cluster-init to complete.

That dependency crosses a profile boundary, so the cluster services join
the valkey-admin profile as well: `--profile valkey-admin` now brings up
the cluster plus the UI, while `--profile valkey` stays cluster-only.

Also set DEPLOYMENT_MODE and VALKEY_AUTH_TYPE explicitly. Both match the
image defaults, but they are what upstream's Docker deployment docs spell
out for a pre-configured connection.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
In Web mode the UI manages connections itself, so pre-configuring the
connection starts metrics collection but does not populate the UI - it
still asks for one on first use. Record the values that work, including
why the published localhost ports are not among them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@netomi

netomi commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

the valkey-admin interface is really cool, was not aware that something like this exists before working on that PR

@cstamas cstamas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool use of yaml refs btw!

@netomi
netomi merged commit 68c7a7c into main Sep 3, 2026
6 checks passed
@netomi
netomi deleted the chore/valkey-cluster-compose branch September 3, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants