Connect to a Cluster instance
A Valkey Cluster partitions keys across 16,384 hash slots. The client must
discover topology and follow MOVED and ASK redirections. A non-Cluster-aware
client can connect to one node but exposes redirection errors to the application
when a command belongs to another node.
For protocol-level behavior, see the official Valkey Cluster specification.
TOC
Discover Services and nodesConnect with valkey-cliVerify topologyUse TLSExternal accessApplication-client requirementsDiscover Services and nodes
For ClusterIP, the Service with the same name as the Valkey resource is a
bootstrap endpoint. The client obtains topology from the server and then opens
connections to the advertised node addresses.
Connect with valkey-cli
Use -c to follow Cluster redirections:
With access control list (ACL) authentication:
Test a disposable key:
Curly braces define a hash tag. Keys with the same non-empty text inside braces map to the same slot, which is required for multi-key commands that operate on a single Cluster slot.
Verify topology
Run health commands from a ready data Pod or an authenticated client endpoint:
Confirm cluster_state:ok, full slot assignment, expected primary and replica
counts, and reachable advertised addresses.
Use TLS
The generated server requires a trusted client certificate by default. The
bootstrap name valkey-cluster.default is in the generated certificate for this
example; the .svc form is not. This command proves only that the bootstrap
connection can authenticate.
The Cluster announces generated per-Pod Service addresses for node connections,
but the generated certificate does not include those Service names or addresses.
Consequently, a client that performs normal hostname verification can fail after
MOVED or ASK, even when bootstrap PING succeeds. Treat this as an unresolved
2.0.0 Cluster TLS limitation. Require a delivered build that aligns every
announced endpoint with a certificate subject alternative name, and test a key
on every shard. Do not use --insecure as the workaround.
External access
Cluster external access creates per-Pod Services so the advertised topology can route clients directly to the correct node. Discover all generated Services:
For LoadBalancer, wait until every required per-Pod Service has an ingress
address. For NodePort, ensure the client can reach the selected node addresses
and all allocated ports. A single reachable bootstrap endpoint is insufficient
if redirected node endpoints are blocked.
The generated certificate also does not cover arbitrary external addresses, so the Cluster TLS limitation above applies to external access as well as the in-cluster announced topology.
Leave spec.access.ports unset for 2.0.0 unless the delivered build documents a
validated fixed-port format. Kubernetes then allocates NodePorts.
Application-client requirements
- Configure more than one bootstrap endpoint when the client library supports it.
- Enable topology refresh and
MOVED/ASKhandling. - Use bounded connection, command, and retry timeouts.
- Confirm DNS, routes, firewall rules, TLS names, and network policies for every advertised node.
- Keep multi-key operations within one hash slot or redesign the operation.
- Revalidate topology behavior after scaling, failover, access changes, or certificate rotation.
Cluster replication is asynchronous, and the protocol permits acknowledged
write loss in documented failure windows. See the official Cluster
specification, CLUSTER SHARDS
reference, TLS
documentation, and client
catalog. Verify the selected library's behavior in
its own documentation and tests.