Skip to content

[Design] Persistent Volumes for ValkeyNode #121

Description

@jdheyburn

Previous discussions:

The user should be able to allow for volumes to be attached to ValkeyNodes. This can be used for:

  • persisting memory to disk
    • allow for a partial resync on pod roll
  • persisting nodes.conf (when in Cluster mode)
    • to avoid having to rediscover the cluster on pod rolls
  • other data durability needs

When a volume is enabled on the ValkeyCluster, it should traverse this config to the ValkeyNode, which should create the volume prior to creating the workload (Deployment/StatefulSet). Then attach the volume to the workload (Deployment/StatefulSet) so that it can be read.

The volume should be independently managed by the ValkeyNode controller so that we can dynamically resize it (should the storage class support it) in either:

  • a user request
  • automatically increasing via a future feature

Note: cluster node reconciliation should continue to happen regardless of whether the volume is created or not.

Proposed specs:

apiVersion: valkey.io/v1alpha1
kind: ValkeyCluster
metadata:
  name: my-cluster
spec:
  shards: 3
  replicas: 1
  persistence:
    size: 10Gi
    storageClassName: gp3

This then is traversed to ValkeyNodes:

kind: ValkeyNode
metadata:
  name: my-cluster-0-0
spec:
  # ... other attributes
  persistence:
    size: 10Gi
    storageClassName: gp3

We can use presence-based enabling (if persistence is defined, create the PVC).

Go structs and usage

type PersistenceSpec struct {
    // Size of the PVC. Required when mode is enabled.
    // +optional
    Size *resource.Quantity `json:"size,omitempty"`

    // StorageClassName for the PVC. Uses cluster default if omitted.
    // +optional
    StorageClassName *string `json:"storageClassName,omitempty"`
}

type ValkeyNodeSpec struct {
    // ... existing fields ...

    // Persistent storage configuration.
    // When nil, no PVC is created (ephemeral storage).
    // +optional
    Persistence *PersistenceSpec `json:"persistence,omitempty"`
}

type ValkeyClusterSpec struct {
    // ... existing fields ...

    // Persistent storage configuration passed through to all ValkeyNodes.
    // +optional
    Persistence *PersistenceSpec `json:"persistence,omitempty"`
}

Consumption

The volume should be attached to the pod and then mounted on the container:

volumes:
  - name: data
    persistentVolumeClaim:
      claimName: valkey-<valkeynode-name>-data

containers:
  - name: server
    volumeMounts:
      - name: data
        mountPath: /data

Then the config will need to specify dir:

dir /data
cluster-config-file /data/config/nodes.conf

I'm suggesting to put nodes.conf at /data/configso that there is some tidiness within the /data dir.

Future work, potentially out of scope for this iteration

  • Native RDB/AOF configuration
  • External PVCs
    • is this something we want? Would users like this for their own data migration?
  • Reclaim policy
  • Volume expansion

cc @umar-riswan-ap @deepakpunjabi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions