Redis Operator creates/configures/manages redis-failovers atop Kubernetes.
This is a fork of spotahome/redis-operator → Saremox/redis-operator → buildio/redis-operator.
Breaking Change: Instance Manager Required
v4.0.0 makes the instance manager the default and only mode. Legacy exec probes are removed.
Key changes:
- Sentinel disabled by default - operator-managed failover is now the default
- Instance manager is always enabled (no opt-out)
- HTTP health probes (
/healthz,/readyz) are now the only probe type - Chart version aligned with operator version (4.0.0)
Minimal configuration (operator-managed failover, no sentinel):
apiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
name: my-redis
spec:
redis:
replicas: 2With Redis Sentinel (opt-in):
apiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
name: my-redis
spec:
redis:
replicas: 2
sentinel:
enabled: true
replicas: 3Sentinel-Free Architecture (#9)
v1.7.0 introduced operator-managed failover as an alternative to Redis Sentinel, reducing pod overhead from 5 pods (2 Redis + 3 Sentinel) to just 2 pods (Redis only).
How it works:
- Operator monitors Redis pods and detects master failures
- On failure, promotes the replica with highest replication offset (minimizes data loss)
- Automatically reconfigures remaining replicas to follow new master
- Master Service (
rfrm-<name>) endpoints update automatically via label selectors
When to use:
- Development/testing environments where you want fewer pods
- Cost-sensitive deployments where 3 Sentinel pods are overhead
- Simple HA setups where operator-managed failover is sufficient
When to keep Sentinel:
- Production environments requiring sub-second failover
- Complex topologies with multiple Redis clusters
- When you need Sentinel's pub/sub notifications
Disable Service Links (#3)
v1.6.1 sets enableServiceLinks: false on all pods to prevent startup failures in namespaces with many services. Kubernetes by default injects environment variables for every service in the namespace, which can exceed limits and cause pod failures.
CNPG-style Instance Manager (#2)
v1.6.0 introduces an optional instance manager that runs as PID 1 in Redis containers, following the CloudNativePG model which has proven reliable at scale.
Features:
- RDB tempfile cleanup - Automatically removes stale
temp-*.rdbfiles on startup, preventing disk exhaustion during crash loops - Zombie process reaper - Properly handles SIGCHLD for BGSAVE/BGREWRITEAOF child processes
- Graceful shutdown - Timeout escalation (SIGTERM → SIGKILL) for reliable shutdown
Enabled by default in v4.0.0+ - no configuration needed.
| Version | Features | Notes |
|---|---|---|
| v1.6.0 | Instance Manager opt-in | instanceManagerImage field |
| v1.6.1 | Disable service links | Prevents startup failures in busy namespaces |
| v1.7.0 | Sentinel-free mode | sentinel.enabled: false |
| v4.0.0 | Instance Manager required | Current release - legacy probes removed, chart/operator versions aligned |
See Issue #2 for instance manager details and Issue #9 for sentinel-free architecture.
- Kubernetes: 1.21+
- Redis: 6+ (also supports Valkey 8)
Tested against Kubernetes 1.29, 1.30, 1.31, 1.32, 1.33, 1.34 and Redis 6, 7.
Starting with 4.0.0, we no longer use 'v' prefix anywhere:
| Git Tag | Chart Version | Image Tag |
|---|---|---|
| 4.0.0 | 4.0.0 | 4.0.0 |
Warning: Previous releases used v prefix for git tags (e.g., v1.7.0). Starting with 4.0.0, git tags are bare version numbers (e.g., 4.0.0).
If you don't specify image.tag, the chart automatically uses the appVersion.
# Install CRD
kubectl apply --server-side -f https://raw.githubusercontent.com/buildio/redis-operator/main/manifests/databases.spotahome.com_redisfailovers.yaml
# Install operator (uses default image version matching chart)
helm upgrade --install redis-operator oci://ghcr.io/buildio/redis-operator/charts/redisoperator \
--namespace redis-operator --create-namespaceNo additional parameters required - the chart defaults to the correct image version.
helm repo add redis-operator https://buildio.github.io/redis-operator
helm repo update
helm install redis-operator redis-operator/redis-operatorREDIS_OPERATOR_VERSION=4.0.0
kubectl apply --server-side -f https://raw.githubusercontent.com/buildio/redis-operator/${REDIS_OPERATOR_VERSION}/manifests/databases.spotahome.com_redisfailovers.yaml
kubectl apply -f https://raw.githubusercontent.com/buildio/redis-operator/${REDIS_OPERATOR_VERSION}/example/operator/all-redis-operator-resources.yaml# Default installation with RBAC, service account, resource limits
kustomize build github.com/buildio/redis-operator/manifests/kustomize/overlays/default?ref=4.0.0 | kubectl apply -f -
# Minimal installation
kustomize build github.com/buildio/redis-operator/manifests/kustomize/overlays/minimal?ref=4.0.0 | kubectl apply -f -
# Full installation with Prometheus ServiceMonitor
kustomize build github.com/buildio/redis-operator/manifests/kustomize/overlays/full?ref=4.0.0 | kubectl apply -f -Helm only manages CRD creation on first install. To update the CRD:
REDIS_OPERATOR_VERSION=4.0.0
kubectl replace --server-side -f https://raw.githubusercontent.com/buildio/redis-operator/${REDIS_OPERATOR_VERSION}/manifests/databases.spotahome.com_redisfailovers.yamlThen upgrade the operator:
helm upgrade redis-operator redis-operator/redis-operatorkubectl apply -f https://raw.githubusercontent.com/buildio/redis-operator/4.0.0/example/redisfailover/basic.yamlThis creates the following resources:
rfr-<NAME>: Redis StatefulSet and ConfigMaprfs-<NAME>: Sentinel Deployment, ConfigMap, and Service
Note: The RedisFailover name must be ≤48 characters.
To use the CNPG-style instance manager for improved reliability:
apiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
name: my-redis
spec:
redis:
replicas: 2
sentinel:
replicas: 3The instance manager is enabled by default:
- An init container copies the
redis-instancebinary to a shared volume - The main container runs
redis-instance runas PID 1 - The instance manager performs cleanup and manages Redis as a child process
For simpler deployments, disable Sentinel and let the operator manage failover:
apiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
name: my-redis
spec:
redis:
replicas: 2
sentinel:
enabled: false
failoverTimeout: "10s" # Optional, defaults to 10sHow failure detection works:
The instance manager provides HTTP health endpoints (/healthz, /readyz) that enable:
- HTTP health probes (faster than exec probes)
- Immediate detection of Redis process crashes
- No process spawning overhead during health checks
This creates only:
rfr-<NAME>: Redis StatefulSet (2 pods)rfrm-<NAME>: Master Service (points to current master via label selector)rfrs-<NAME>: Slave Service (points to replicas)
No Sentinel pods are created.
The operator handles failover by:
- Detecting master failure via health checks
- Selecting the replica with highest replication offset
- Promoting it to master (
SLAVEOF NO ONE) - Reconfiguring other replicas to follow the new master
- Updating pod labels so Services route correctly
The redis-instance binary provides the following commands:
# Run as instance manager (PID 1 mode)
redis-instance run --redis-conf /redis/redis.conf --data-dir /data --db-filename dump.rdb
# Standalone cleanup (removes stale RDB files)
redis-instance cleanup --data-dir /data --db-filename dump.rdb
# Dry-run cleanup (show what would be removed)
redis-instance cleanup --data-dir /data --dry-runWith Sentinel (default):
Connect using a Sentinel-ready client library:
url: rfs-<NAME>
port: 26379
master-name: mymaster
Without Sentinel (sentinel.enabled: false):
Connect directly to the master service:
url: rfrm-<NAME>
port: 6379
The master service automatically routes to the current master pod.
kubectl create secret generic redis-auth --from-literal=password=your-passwordapiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
name: my-redis
spec:
redis:
replicas: 3
sentinel:
replicas: 3
auth:
secretPath: redis-authEnable persistent storage with a PVC:
spec:
redis:
storage:
persistentVolumeClaim:
metadata:
name: redis-data
spec:
accessModes: [ReadWriteOnce]
resources:
requests:
storage: 10Gi
keepAfterDeletion: true # Optional: retain PVCs when RedisFailover is deletedSee persistent-storage.yaml for a complete example.
Configure Redis and Sentinel via customConfig:
spec:
redis:
customConfig:
- maxmemory 2gb
- maxmemory-policy allkeys-lru
sentinel:
customConfig:
- down-after-milliseconds 5000Note: Configuration is applied via CONFIG SET at runtime. Do not modify control options like port, bind, or dir.
Migrate from an existing Redis instance:
spec:
bootstrapNode:
host: existing-redis.example.com
port: "6379"
allowSentinels: false # Set true to also create Sentinels pointing to bootstrap nodeSee bootstrapping.yaml for details.
This project includes comprehensive GitHub Actions workflows:
| Workflow | Triggers | Description |
|---|---|---|
| CI | Push, PR | Build, lint, unit tests, integration tests, Docker build |
| E2E | PR | Full end-to-end tests in minikube cluster |
| Release | Tags | Multi-arch image build and push to GHCR |
The E2E workflow validates:
- Instance manager runs as PID 1
- RDB cleanup works on pod restart
- Redis remains functional after restart
- Sentinel-free mode: no Sentinel resources created
- Sentinel-free mode: operator-managed failover works
Requires controller-gen v0.20.0+ for Go 1.25+:
go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest
make generate-crdmake ci-unit-test
make ci-integration-testmake imagehelm uninstall redis-operator
kubectl delete crd redisfailovers.databases.spotahome.comWarning: Deleting the CRD removes all RedisFailover resources and their managed objects.
kubectl delete redisfailover <NAME>All managed resources are automatically cleaned up via OwnerReferences.
Images are published to GitHub Container Registry:
- Operator & Instance Manager:
ghcr.io/buildio/redis-operator - Helm Chart:
oci://ghcr.io/buildio/redis-operator/charts/redisoperator