Install Dragonfly as a Multi Node Cluster using k8s operator

Hi,

I am evaluating dragonfly as an alternative to Redis.
I am trying to figure out installation of dragonfly as a cluster using the dragonfly k8s operator.
Could you guide me here?

Hi @keshava88, welcome to the Dragonfly community.

Currently, the Dragonfly K8s Operator doesn’t support Dragonfly Cluster (the multi-node clustering) yet. The operator supports high availability (HA), though. A single Dragonfly primary instance is able to handle hundreds of GB or even 1TB of in-memory data. Depending on your workload and memory size, please let us know if a primary-replica HA setup is sufficient.

If you are already running Redis Cluster, Dragonfly supports the emulated cluster mode. It’s a single Dragonfly primary (optionally with HA as well), but compatible Redis Cluster, so that it eases your migration. To enable emulated cluster mode using the K8s operator, please see the documentation here about the args field.

spec:
  args:
   - "--cluster_mode=emulated"

If you really need to scale Dragonfly horizontally, Dragonfly Cluster is currently in private beta within Dragonfly Cloud, our managed offering. Please contact us if that’s what you’re looking for.

@joezhou_df - I wonder if you could help me with a related question?

We spun up a Dragonfly with the operator on a K8s node for developer doing a .Net service which wanted a key/value store. We noticed the following output from the dragonfly logs.

CLUSTER NODES failed with reason: Cluster is disabled. Enable via passing --cluster_mode=emulated

So we added the arg --cluster_mode=emulated to the dragonfly instances.

But we do not really understand why we saw this and what impact setting cluster_mode to emulated will have?

Is this some type of bad configuration on the client side?

The .Net client is using Redis.OM: GitHub - redis/redis-om-dotnet: Object mapping, and more, for Redis and .NET

Hi @thedukedk, let’s break the issue down:

  • Redis Cluster requires a different version of client, namely a cluster client, which can be thought of as a superset of the ordinary Redis single-instance client. This is because Redis Cluster has a client-server-coordinated design.
  • The cluster client provides the same data retrieval & manipulation commands (i.e., GET, SET), but it also supports additional commands for cluster coordination, normally not directly called by developers. For instance, the CLUSTER NODES command is used to retrieve the cluster configuration from a server node or instance within the cluster.
  • It’s likely the developer initiated the .NET client as a cluster client instead of a single-node client. So upon connecting, the cluster client needs to call the CLUSTER NODES command to gather cluster information.
  • Dragonfly --cluster_mode=emulated helps migrate from a Redis Cluster to a Dragonfly single node, and it should have negligible impact in terms of performance.
  • So, if you have code that was working with Redis Cluster, --cluster_mode=emulated should be used in Dragonfly, so that the existing cluster client works seamlessly with Dragonfly.
  • But if this is a new project, then the developers should check the .NET client initialization again to make sure it’s creating a single-node client instead of a cluster client.

I am not very familiar with the .NET client library, but let’s take the Go library as an example. Note that the same library supports multiple types of clients.

A single-instance (standalone) client should be created like this:

import "github.com/redis/go-redis/v9"

client := redis.NewClient(&redis.Options{
	Addr:	  "localhost:6379",
	Password: "mypwd",
	DB:		  0,
})

val, err := client.Get(ctx, "key").Result()

And a cluster client is created like this:

import "github.com/redis/go-redis/v9"

client := redis.NewClusterClient(&redis.ClusterOptions{
    Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},
})

// Same usage after client initialization.
// Developers don't call commands like 'CLUSTER NODES'.
val, err := client.Get(ctx, "key").Result()

It might not be exactly the same for .NET, but you get the idea. I hope that’s clear and it solves your problem!

1 Like

That clears a lot up for me. Thank you sooo much!

I am more on the operations side of things. And Dragonfly is also a bit of a new technology for us.

I can pass this information along to the developer and we can dig into how to do this correctly for a single node client.

Again, thank you for taking the time. It is very much appreciated.

2 Likes