What is KubeBlocks?
KubeBlocks is an open-source Kubernetes operator designed to manage stateful workloads, particularly databases. It provides:- Unified Management: Manage multiple database engines through a consistent API
- Day-2 Operations: Automated scaling, backup, restore, monitoring, and failover
- Production-Ready: Built for production environments with high availability
- Multi-Topology Support: Standalone, replication, and sharding configurations
Prerequisites
Before you begin, ensure you have:- Kubernetes cluster >= v1.21
kubectlinstalled - Installation Guidehelminstalled - Installation Guide- KubeBlocks installed and running
Installing KubeBlocks
If you haven’t installed KubeBlocks yet, follow these steps:Step 1: Install KubeBlocks Operator
Step 2: Install FalkorDB Addon
Enable the FalkorDB addon for KubeBlocks. You can use either the kbcli command-line tool or Helm.Option A: Using kbcli (Recommended)
First, install kbcli:Option B: Using Helm
Step 3: Create a Namespace
Create a dedicated namespace for your FalkorDB instances:Deployment Options
KubeBlocks supports three deployment topologies for FalkorDB:- Standalone - Single instance for development and testing
- Replication - High availability with primary/secondary nodes and Sentinel
- Sharding - Horizontal scalability with multiple shards (Redis Cluster mode)
Option 1: Standalone Deployment
A standalone deployment is ideal for development, testing, or small workloads.Create a Standalone Cluster
Create a file namedfalkordb-standalone.yaml:
Option 2: Replication Deployment (Recommended)
A replication deployment provides high availability with automatic failover using Redis Sentinel.Understanding the Architecture
The replication topology includes:- FalkorDB Component: Primary and secondary nodes for data storage and queries
- Sentinel Component: Monitors FalkorDB nodes and manages automatic failover
- Minimum of 3 Sentinel Replicas: Required for quorum-based failover decisions
Create a Replication Cluster
Create a file namedfalkordb-replication.yaml:
Why Does Sentinel Start First?
KubeBlocks ensures that Sentinel instances start before FalkorDB replicas. This is because:- Each FalkorDB replica queries Sentinel on startup to determine if a primary node exists
- If no primary exists, the replica configures itself as the primary
- If a primary exists, the replica configures itself as a secondary and begins replication
Verify the Deployment
Check the cluster status:primary and one or more secondary pods.
Option 3: Sharding Deployment
A sharding deployment distributes data across multiple shards for horizontal scalability.Create a Sharding Cluster
Create a file namedfalkordb-sharding.yaml:
Connecting to FalkorDB
Step 1: Get Connection Credentials
Retrieve the password for your FalkorDB instance:Step 2: Port Forward to the Cluster
Enable local access to the FalkorDB service:Step 3: Connect Using redis-cli
Connect to your FalkorDB instance:Step 4: Run a Test Query
Execute a simple Cypher query to verify the connection:Day-2 Operations
KubeBlocks provides comprehensive Day-2 operations for managing your FalkorDB clusters.Horizontal Scaling
Scale Out
Add more replicas to your cluster:Scale In
Remove replicas from your cluster:Vertical Scaling
Update CPU and memory resources:Volume Expansion
Expand storage volume (requires storage class with volume expansion support):Restart Cluster
Restart all components:Stop and Start
Stop the cluster (releases pods but retains storage):Configuration Management
Reconfigure Parameters
Update FalkorDB configuration dynamically:maxclients) require a restart. KubeBlocks will handle this automatically.
Verify the configuration:
Backup and Restore
Create a Backup Repository
Before creating backups, configure a backup repository:Full Backup
Create a full backup using Redis BGSAVE:Continuous Backup (Point-in-Time Recovery)
Enable continuous backup using AOF (Append-Only File):- Enable AOF timestamps:
- Update the BackupSchedule to enable AOF backup:
enabled: true for the aof backup method.
Restore from Backup
Restore a new cluster from a backup:Exposing Services
Expose via LoadBalancer
Expose FalkorDB to external clients:Expose via NodePort
For on-premises or development environments:Monitoring with Prometheus
Enable Metrics Export
Ensure metrics are enabled when creating the cluster:Create PodMonitor
Create a PodMonitor to scrape metrics:Access Grafana Dashboard
- Access your Grafana instance
- Import a Redis/FalkorDB dashboard from the Grafana dashboard store
- Configure the dashboard to use the correct job label (e.g.,
monitoring/falkordb-replication-pod-monitor)
Best Practices
High Availability
- Use the replication topology with at least 3 Sentinel replicas
- Distribute pods across availability zones using pod anti-affinity
- Configure appropriate resource requests and limits
- Enable automated backups with appropriate retention policies
Security
- Use Kubernetes secrets for storing passwords
- Enable TLS for client connections (if required)
- Use Network Policies to restrict access to FalkorDB pods
- Regularly rotate credentials
Performance
- Choose appropriate storage class with good I/O performance
- Monitor resource usage and scale vertically/horizontally as needed
- For write-heavy workloads, consider disabling AOF timestamps
- Use sharding topology for large datasets
Storage
- Ensure storage class supports volume expansion
- Configure appropriate storage size based on expected data growth
- Use persistent volumes with replication for data durability
- Test backup and restore procedures regularly
Troubleshooting
Cluster Not Ready
If the cluster status remainsCreating for an extended period:
Connection Issues
If you cannot connect to FalkorDB:Backup Failures
If backups fail:Deleting the Cluster
To delete a cluster and all its resources:WipeOut policy deletes all data including backups. Use Delete policy to retain backups.
Additional Resources
- KubeBlocks Official Documentation
- KubeBlocks FalkorDB Examples
- FalkorDB Documentation
- Redis Sentinel Documentation
- Kubernetes Operators
Summary
KubeBlocks provides a powerful, production-ready solution for deploying and managing FalkorDB on Kubernetes. With support for multiple topologies, comprehensive Day-2 operations, and automated backup/restore capabilities, KubeBlocks simplifies the operational complexity of running FalkorDB in Kubernetes environments. Whether you need a simple standalone instance for development or a highly available sharded cluster for production, KubeBlocks has you covered.Frequently Asked Questions
What Kubernetes version does KubeBlocks require?
What Kubernetes version does KubeBlocks require?
KubeBlocks requires Kubernetes >= v1.21. Ensure you also have
kubectl and helm installed before deploying.What topologies does KubeBlocks support for FalkorDB?
What topologies does KubeBlocks support for FalkorDB?
KubeBlocks supports standalone (single instance for development), replication (master + replicas with Sentinel for HA), and sharding (Redis Cluster mode for horizontal scalability).
How do I scale my FalkorDB cluster with KubeBlocks?
How do I scale my FalkorDB cluster with KubeBlocks?
Create an OpsRequest with
type: HorizontalScaling to add or remove replicas, or type: VerticalScaling to change CPU and memory resources. KubeBlocks handles the operation automatically.Does KubeBlocks support automated backups?
Does KubeBlocks support automated backups?
Yes. KubeBlocks supports full backups via RDB (BGSAVE) and continuous backups via AOF for point-in-time recovery. Configure a BackupRepo (e.g., S3) and create Backup resources.
How do I connect to FalkorDB deployed with KubeBlocks?
How do I connect to FalkorDB deployed with KubeBlocks?
Retrieve the password from the Kubernetes secret (
falkordb-replication-conn-credential), then use kubectl port-forward or expose via LoadBalancer/NodePort. Connect with redis-cli -a <password>.