Skip to content

Valkey Operator User Guide

Table of Contents

  1. Getting Started
  2. Installing the Operator
  3. Basic Usage
  4. Architecture Overview
  5. Configuration Examples
  6. Monitoring
  7. Customizing Generated Resources
  8. Security
  9. Troubleshooting

Getting Started

Valkey Operator is a Kubernetes operator that automates the deployment and management of Valkey instances. It supports multiple architectures:

  • Cluster Mode - High-performance distributed Valkey clusters with automatic sharding
  • Failover Mode - High-availability using Sentinel
  • Replica Mode - Standalone or primary-replica architecture
  • Sentinel Mode - Standalone sentinel instances for monitoring external deployments

Installing the Operator

Prerequisites

  • Kubernetes 1.33+
  • kubectl configured to access your cluster
  • Cluster administrator permissions
  • cert-manager installed (for webhook TLS certificates)

Installation Methods

Helm is the recommended way to install Valkey Operator. It provides easy configuration, upgrades, and rollbacks.

The chart is published to oci://ghcr.io/chideat/charts/valkey-operator. Its versions are the operator's release tags without the v: chart 2.1.0 runs operator v2.1.0. Without --version, Helm installs the latest release.

# Install with cert-manager managing webhook TLS certificates (default)
# Requires cert-manager: https://cert-manager.io/docs/installation/
helm install valkey-operator oci://ghcr.io/chideat/charts/valkey-operator \
  --namespace valkey-system --create-namespace

From a checkout of the repository, charts/valkey-operator installs the chart of that checkout instead.

Prerequisites: cert-manager must be installed. cert-manager integration is enabled by default (certManager.enabled=true).

If you don't have cert-manager, you can disable webhooks:

helm install valkey-operator oci://ghcr.io/chideat/charts/valkey-operator \
  --namespace valkey-system --create-namespace \
  --set webhook.enabled=false
Customizing the Helm installation

All configuration options are documented in the chart's values, which helm show values oci://ghcr.io/chideat/charts/valkey-operator prints; in the repository they are charts/valkey-operator/values.yaml. Common overrides:

Parameter Description Default
image.repository Operator image repository chideat/valkey-operator
image.tag Operator image tag Chart appVersion
replicaCount Number of operator replicas 1
certManager.enabled Enable cert-manager for webhook TLS true
webhook.enabled Enable admission webhooks true
metrics.enabled Enable metrics endpoint true
serviceMonitor.enabled Enable Prometheus ServiceMonitor false
Upgrading
helm upgrade valkey-operator oci://ghcr.io/chideat/charts/valkey-operator \
  --namespace valkey-system
Uninstalling
helm uninstall valkey-operator --namespace valkey-system

# CRDs are not removed automatically; remove them manually if needed:
kubectl delete crd clusters.valkey.buf.red failovers.valkey.buf.red \
  sentinels.valkey.buf.red users.valkey.buf.red valkeys.rds.valkey.buf.red

Method 2: Using Kustomize

# Install CRDs and operator
kubectl apply -k https://github.com/chideat/valkey-operator/config/default

Method 3: Using Manifests

# Download and apply manifests
curl -L https://github.com/chideat/valkey-operator/releases/latest/download/manifests.yaml | kubectl apply -f -

Verify Installation

# Check if the operator is running
kubectl get pods -n valkey-system

# Verify CRDs are installed
kubectl get crd | grep valkey

Basic Usage

Deploy a Simple Valkey Cluster

apiVersion: rds.valkey.buf.red/v1alpha1
kind: Valkey
metadata:
  name: my-valkey-cluster
  namespace: default
spec:
  arch: cluster
  version: "8.0"
  replicas:
    shards: 3
    replicasOfShard: 1
  resources:
    requests:
      memory: 1Gi
      cpu: 500m
    limits:
      memory: 2Gi
      cpu: 1000m
kubectl apply -f valkey-cluster.yaml
kubectl get valkey my-valkey-cluster -w

Deploy a Valkey Failover Instance

apiVersion: rds.valkey.buf.red/v1alpha1
kind: Valkey
metadata:
  name: my-valkey-failover
  namespace: default
spec:
  arch: failover
  version: "8.0"
  replicas:
    replicasOfShard: 3
  sentinel:
    replicas: 3
    quorum: 2
  resources:
    requests:
      memory: 512Mi
      cpu: 250m
kubectl apply -f valkey-failover.yaml
kubectl get valkey my-valkey-failover -w

Clients connect with the password the operator generates for the default user, and for a failover instance also with the one for the sentinel nodes; see Passwords.

Architecture Overview

Cluster Architecture

┌───────────────────────────────────────────────────────────┐
│                      Valkey Cluster                       │
├──────────────────┬──────────────────┬───────────────────┤
│     Shard 1      │      Shard 2     │      Shard 3      │
│   Master + 1R    │    Master + 1R   │    Master + 1R    │
│ Slots 0-5460     │ Slots 5461-10922 │ Slots 10923-16383 │
└──────────────────┴──────────────────┴───────────────────┘

Failover Architecture

┌─────────────────────────────────────────┐
│              Sentinel Cluster           │
│           (3 Sentinel Nodes)            │
└─────────────────┬───────────────────────┘
                  │ Monitors
┌─────────────────▼───────────────────────┐
│              Valkey Failover            │
│         Master + 2 Replicas             │
└─────────────────────────────────────────┘

Configuration Examples

Production Valkey Cluster with Storage

apiVersion: rds.valkey.buf.red/v1alpha1
kind: Valkey
metadata:
  name: prod-valkey-cluster
  namespace: valkey-production
spec:
  arch: cluster
  version: "8.0"
  replicas:
    shards: 6
    replicasOfShard: 2
  resources:
    requests:
      memory: 4Gi
      cpu: 2000m
    limits:
      memory: 8Gi
      cpu: 4000m
  storage:
    storageClassName: fast-ssd
    capacity: 50Gi
    retainAfterDeleted: true
  access:
    serviceType: LoadBalancer
  customConfigs:
    maxmemory-policy: allkeys-lru
    tcp-keepalive: "300"
    save: "900 1 300 10 60 10000"
  affinityPolicy: AntiAffinity
  tolerations:
    - key: valkey
      operator: Equal
      value: "true"
      effect: NoSchedule

Secure Valkey Cluster with TLS and ACL

apiVersion: rds.valkey.buf.red/v1alpha1
kind: Valkey
metadata:
  name: secure-valkey-cluster
  namespace: valkey-secure
spec:
  arch: cluster
  version: "8.0"
  replicas:
    shards: 3
    replicasOfShard: 1
  access:
    serviceType: ClusterIP
    enableTLS: true
    certIssuer: my-cluster-issuer
    certIssuerType: ClusterIssuer
---
apiVersion: valkey.buf.red/v1alpha1
kind: User
metadata:
  name: app-user
  namespace: valkey-secure
spec:
  accountType: custom
  arch: cluster
  username: myapp
  passwordSecrets:
    - app-user-password
  aclRules: "+@read +@write -@dangerous ~app:* &notifications:*"
  instanceName: secure-valkey-cluster

Monitoring

Prometheus Integration

The operator includes built-in Prometheus exporter support:

spec:
  exporter:
    disable: false
    resources:
      requests:
        memory: 64Mi
        cpu: 50m
      limits:
        memory: 128Mi
        cpu: 100m

Exporter Flags and Environment Variables

The exporter runs with the flags the operator needs. To pass more, such as --include-system-metrics or REDIS_EXPORTER_CHECK_KEYS, patch the exporter container through spec.overwrites; see Customizing Generated Resources.

ServiceMonitor for Prometheus Operator

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: valkey-cluster
  namespace: valkey-system
spec:
  selector:
    matchLabels:
      app: valkey-cluster
      role: exporter
  endpoints:
    - port: exporter
      interval: 30s
      path: /metrics

Customizing Generated Resources

The operator generates a StatefulSet and a PodDisruptionBudget for the Valkey nodes (one of each per shard on the cluster architecture) and for the sentinel nodes, and the Services that reach them. spec.overwrites patches them, for settings the Valkey spec has no field for: a priority class, topology spread constraints, extra volumes, exporter flags, probe timing, a budget's eviction policy, a Service's annotations or traffic policy. Each entry names the kind it patches, StatefulSet, PodDisruptionBudget or Service, and holds the patch for every object of that kind. A Service entry also names a target, the group of Services it patches (see Service Targets). A kind, or a kind and target, appears at most once.

apiVersion: rds.valkey.buf.red/v1alpha1
kind: Valkey
metadata:
  name: demo
spec:
  arch: failover
  # ...
  overwrites:
    - kind: StatefulSet
      patch:
        metadata:
          labels:
            team: cache
        spec:
          template:
            spec:
              priorityClassName: critical
              containers:
                - name: exporter
                  args: ["--include-system-metrics=true"]
                  env:
                    - name: REDIS_EXPORTER_CHECK_KEYS
                      value: "session:*"
                - name: valkey
                  livenessProbe:
                    periodSeconds: 30
    - kind: PodDisruptionBudget
      patch:
        spec:
          unhealthyPodEvictionPolicy: AlwaysAllow
    - kind: Service
      target: readwrite
      patch:
        metadata:
          annotations:
            external-dns.alpha.kubernetes.io/hostname: cache.example.com
  sentinel:
    replicas: 3
    overwrites:
      - kind: StatefulSet
        patch:
          spec:
            template:
              spec:
                priorityClassName: critical

Each patch is a strategic merge patch, so it lists only what it adds or changes. Containers, environment variables and volumes merge by name, and volume mounts by mountPath; lists without a merge key, such as args, are replaced whole. Where a patch sets a field the operator also sets, and the field is not protected, the patch wins.

A null in a patch deletes that field. Client-side kubectl apply and kubectl patch --type merge drop null values from a patch written as an object before they reach the operator, while kubectl apply --server-side, kubectl create and a JSON patch (kubectl patch --type json) keep them. A patch can also be written as text, a string that holds it in YAML or JSON, which every client passes through unchanged. On the cluster architecture, this one removes the CPU limit of the agent container:

spec:
  overwrites:
    - kind: StatefulSet
      patch: |
        spec:
          template:
            spec:
              containers:
                - name: agent
                  resources:
                    limits:
                      cpu: null

spec.sentinel.overwrites patches the sentinel StatefulSet, PodDisruptionBudget and Services. It applies only on the failover architecture, and only when the operator runs the sentinel nodes, that is, when spec.sentinel.sentinelReference is not set; elsewhere it is rejected.

The operator records a checksum of the patches in the valkey.buf.red/checksum-overwrites annotation of each object it patches, so a change to the overwrites always updates those objects. Pods roll when a StatefulSet change reaches the pod template; a PodDisruptionBudget or a Service changes in place. The exception is a pod Service of the failover and replica architectures or of the sentinel nodes: each pod reads the address it announces from its Service when it starts, so after updating one the operator restarts its pod, and waits until that pod is ready again before it moves on to the next pod of the same StatefulSet, as it does when the access settings change. That does not apply when access.ports assigns the node ports.

What a StatefulSet Patch Cannot Change

The operator relies on parts of the StatefulSets it generates, so these are protected:

  • The identity and status of the StatefulSet, the operator's labels, and annotations that start with valkey.buf.red/checksum.
  • replicas, updateStrategy, revisionHistoryLimit, ordinals, selector, serviceName, podManagementPolicy, volumeClaimTemplates and persistentVolumeClaimRetentionPolicy. The operator scales and rolls the StatefulSets itself.
  • In the pod template: the operator's labels and the kubectl.kubernetes.io/restartedAt annotation; affinity, tolerations, nodeSelector, securityContext and imagePullSecrets, which have fields in the Valkey spec; serviceAccountName, serviceAccount, automountServiceAccountToken and terminationGracePeriodSeconds; the local.inject host alias (127.0.0.1 or ::1); and the operator's volumes conf, sentinel-config, temp, valkey-auth, valkey-data, valkey-opt and valkey-tls.
  • In every container the operator runs: image, imagePullPolicy, command, ports and securityContext; environment variables with the names the operator uses, such as POD_IP, REDIS_ADDR or REDIS_PASSWORD; and the mount paths /account, /data, /etc/valkey, /mnt/opt, /opt, /tmp and /tls, and anything under them.
  • In the valkey and sentinel containers: args, lifecycle, resources, and what a probe runs. A probe's timing can change, but a probe the operator does not set cannot be added.
  • In the exporter container: resources (set spec.exporter.resources instead), and the flags that the operator sets or that would point the exporter at another server or credentials: --redis.addr, --redis.user, --redis.password, --redis.password-file, --tls-ca-cert-file, --tls-client-cert-file, --tls-client-key-file, --skip-tls-verification, --web.listen-address, --web.telemetry-path and --version.
  • In the init and agent containers: args.

A patch cannot add containers; it can only change the ones the operator runs:

StatefulSet Containers Init containers
Valkey nodes, cluster architecture valkey, exporter, agent init
Valkey nodes, failover and replica architectures valkey, exporter init
Sentinel nodes sentinel, agent init

What a PodDisruptionBudget Patch Cannot Change

The budget's identity and status, the operator's labels, annotations that start with valkey.buf.red/checksum, and selector, which picks the pods the budget counts, are protected. Other labels and annotations, maxUnavailable, minAvailable and unhealthyPodEvictionPolicy can change.

The operator sets maxUnavailable, and a budget cannot have both maxUnavailable and minAvailable, so a patch that sets minAvailable replaces the operator's maxUnavailable:

overwrites:
  - kind: PodDisruptionBudget
    patch:
      spec:
        minAvailable: 1

Service Targets

A Service entry patches every Service of its target:

Target Cluster architecture Failover and replica architectures Sentinel nodes
headless the headless Service of each shard, <name>-<shard> the headless Service, rfs-<name>
instance the Service of all the nodes, <name>
readwrite the Service of the primary, rfr-<name>-readwrite
readonly the Service of the replicas, rfr-<name>-readonly
exporter the headless Service of the nodes, which serves the exporter port, rfr-<name>
pod the Service of each node, drc-<name>-<shard>-<index> the Service of each node, rfr-<name>-<index> the Service of each sentinel, rfs-<name>-<index>

spec.overwrites takes the targets of the architecture, and spec.sentinel.overwrites those of the sentinel nodes.

What a Service Patch Cannot Change

The Service's identity and status, the operator's labels, and annotations that start with valkey.buf.red/checksum are protected, and so are these fields:

  • selector, ports and type, through which the operator reaches its pods and each pod announces its address;
  • ipFamilies and ipFamilyPolicy, which follow access.ipFamilyPrefer;
  • clusterIP, clusterIPs, healthCheckNodePort and loadBalancerClass, which the API server assigns or keeps once set;
  • externalIPs, which would take over traffic to any address, and externalName.

Other labels and annotations can change, and so can externalTrafficPolicy, internalTrafficPolicy, trafficDistribution, sessionAffinity, sessionAffinityConfig, publishNotReadyAddresses, loadBalancerIP, loadBalancerSourceRanges and allocateLoadBalancerNodePorts. sessionAffinityConfig needs sessionAffinity: ClientIP in the same patch.

Some fields apply only to some Service types. loadBalancerSourceRanges, the service.beta.kubernetes.io/load-balancer-source-ranges annotation and allocateLoadBalancerNodePorts apply to LoadBalancer Services, and externalTrafficPolicy to NodePort and LoadBalancer Services. The readwrite, readonly and pod Services take their type from access.serviceType (spec.sentinel.access.serviceType for the sentinel nodes), and the others are ClusterIP. The operator leaves these fields out of a Service whose type does not take them, so a patch keeps working when access.serviceType changes.

Rejected and Restored Patches

The admission webhook of the Valkey resource rejects a patch that is neither an object nor text that holds one, changes a protected field, adds a container, sets both minAvailable and maxUnavailable, sets sessionAffinityConfig without sessionAffinity: ClientIP, uses a patch directive (a key starting with $), deletes a protected field with null, names a field the object does not have, or gives a field a value of the wrong type. It also rejects a Service entry without a target or with a target the architecture does not have, and a target on any other kind.

The operator checks again when it applies the patches, because some reach it unchecked: webhooks can be disabled, a Sentinel resource created on its own has no webhook, and admission accepts what the current settings do not use, such as a patch for the exporter container with the exporter disabled, or loadBalancerSourceRanges for a ClusterIP Service. The operator skips a patch that is neither an object nor text that holds one, uses a patch directive, or gives a field a value of the wrong type. From the other patches it keeps protected fields as generated; drops containers it does not run, a minAvailable set together with maxUnavailable, and fields the Service type does not take; and applies the rest. It reports each of these in a Warning event with reason Overwrites on the Cluster, Failover or Sentinel resource.

Security

Passwords

The operator generates a password for the default user of every instance it creates and, on the failover architecture, for its sentinel nodes. Instances created by an earlier version of the operator keep what they had: the operator does not add a password to a running instance on its own, because every client that connects without one would be locked out.

The default user

A client that connects without a username is the default user. For every new instance the operator generates a password for it and creates a User resource that holds it:

Architecture User Secret with the password
cluster cluster-acl-<name>-default cluster-acl-<name>-default-secret
failover, replica failover-acl-<name>-default failover-acl-<name>-default-secret
kubectl get secret failover-acl-my-valkey-failover-default-secret \
  -o jsonpath='{.data.password}' | base64 -d

The operator applies the User once the instance is ready, so the default user requires the password from the moment the User reaches the Ready phase, not from the first start of the instance:

kubectl get users.valkey.buf.red failover-acl-my-valkey-failover-default -o jsonpath='{.status.phase}'

The password is managed in that User and nowhere else. To change it, write a new password into the Secret: the operator applies it to every node. A password is 8 to 32 characters long, made only of letters, digits and the characters ~!@#$%^&*()-_=+?, with at least one of each. The ACL rules, +@all -acl ~* &* by default, are the User's aclRules. The default user cannot be deleted while the instance exists.

To require a password on an instance created by an earlier version, create the User yourself, under the name in the table, once its clients have the password:

apiVersion: valkey.buf.red/v1alpha1
kind: User
metadata:
  name: failover-acl-my-valkey-failover-default
  namespace: default
spec:
  accountType: custom
  arch: failover
  instanceName: my-valkey-failover
  username: default
  passwordSecrets:
    - my-valkey-failover-default-password
  aclRules: "+@all -acl ~* &*"

The sentinel nodes

When a failover instance is created with spec.sentinel.access.defaultPasswordSecret left empty, it is set to sentinel-acl-<name>-default-secret, and the operator generates that Secret before it starts the sentinel nodes. A client that asks the sentinel nodes for the primary needs this password, as well as the default user's for the primary itself. To use a password of your own, name your Secret in defaultPasswordSecret when you create the instance. No password is generated when spec.sentinel.sentinelReference points to sentinel nodes the operator does not run, or when the admission webhooks are disabled.

Network Policies

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: valkey-cluster-netpol
  namespace: valkey-system
spec:
  podSelector:
    matchLabels:
      app: valkey-cluster
  policyTypes:
    - Ingress
    - Egress
  ingress:
    - from:
        - namespaceSelector:
            matchLabels:
              name: application
      ports:
        - protocol: TCP
          port: 6379
  egress:
    - to: []
      ports:
        - protocol: TCP
          port: 6379

Pod Security Context

spec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 999
    runAsGroup: 999
    fsGroup: 999
    seccompProfile:
      type: RuntimeDefault

Troubleshooting

Common Issues

Cluster Not Ready

# Check cluster status
kubectl describe cluster my-cluster

# Check pod logs
kubectl logs -l app=valkey-cluster -c valkey

# Check operator logs
kubectl logs -n valkey-system deployment/valkey-operator-controller-manager

Storage Issues

# Check PVC status
kubectl get pvc -l app=valkey-cluster

# Check storage class
kubectl get storageclass

# Check node storage capacity
kubectl describe nodes

Network Connectivity

# Test connectivity between pods
kubectl exec -it <pod-name> -- valkey-cli cluster nodes

# Check service endpoints
kubectl get endpoints -l app=valkey-cluster

# Test external access
kubectl port-forward service/my-cluster 6379:6379

Debug Mode

Enable debug logging in the operator:

spec:
  containers:
    - name: manager
      args:
        - --zap-log-level=debug

Performance Tuning

Memory Settings

customConfigs:
  maxmemory: "1gb"
  maxmemory-policy: "allkeys-lru"
  maxmemory-samples: "10"

Network Settings

customConfigs:
  tcp-keepalive: "300"
  tcp-backlog: "511"
  timeout: "300"

Persistence Settings

customConfigs:
  save: "900 1 300 10 60 10000"
  stop-writes-on-bgsave-error: "yes"
  rdbcompression: "yes"