Upgrading Redis and RedisCluster
The upgrade strategy for standalone Redis includes the downtime of the system but for cluster setup mode any application will not face any type of issues or downtime. The operator uses the rolling deployment strategy for cluster setup where it will upgrade the redis leader pods and once the leader is upgraded it will follow the same strategy for redis follower pods.
Upgrade of standalone setup
For upgrading the standalone setup of Redis, first we need to identify the current version of it and that can be done via combination of kubectl and redis-server command.
Now let’s say the new version, we want to migrate is 7.0.5. In that case, we can simply use helm upgrade command to upgrade the redis cluster.
Once the upgrade strategy is completed, we can verify the redis pod status by executing:
Verify the version of redis pod by using the same cli command.
For YAML manifest based upgrade, please update the spec section of Redis Object. For further details check here.
Things to keep in mind:
Note
- Standalone upgrade introduces downtime, so make sure you have strategy in-place. A better option could be deploying a new redis standalone alongside and point the application to it.
- Your applications should be compatible with the new version of Redis on which you are upgrading.
Upgrading cluster setup
Similar to standalone setup upgrade, the cluster setup upgrade can also be performed by helm command. But again first we need to verify the version of existing cluster setup.
As an initial step of Redis cluster upgrade, first we need to check the version of redis and also the health of cluster. Again this can be achieved by kubectl and redis-cli.
Once the version and cluster health is verified, we can trigger the upgrade of the cluster by using helm command. Let’s upgrade the cluster version to v7.
Once the upgrade using helm is completed, we need to verify the redis cluster pod status. Also, we need to check the version and health of redis cluster to verify the upgrade is successful or not.
For YAML manifest based upgrade, please update the spec section of Redis Object. For further details check here.
Things to keep in mind:
Note
- Cluster upgrade doesn’t cause any kind of downtime because of rolling update strategy of Kubernetes, there will be always a redis available to serve application requests.
- If application is highly critical, in such scenarios it would make sense to create a new cluster and migrate the application pointing to it
StatefulSet Recreation Strategy
In some scenarios, you may need to recreate the StatefulSet completely, for example when you need to change immutable fields. Redis Operator provides an annotation redis.opstreelabs.in/recreate-statefulset that can be set to true to recreate the StatefulSet.
Redis Operator supports specifying the deletion propagation strategy when recreating StatefulSets. This allows more control over how dependent resources like Pods are handled during the recreation process.
Available Strategies
You can control the deletion behavior using the annotation redis.opstreelabs.in/recreate-statefulset-strategy with the following values:
- foreground (default): The StatefulSet and its dependent objects (like Pods) are deleted synchronously. Kubernetes waits for all dependent objects to be deleted before finalizing the StatefulSet deletion.
- background: The StatefulSet is deleted immediately, and dependent objects are deleted asynchronously in the background.
- orphan: The StatefulSet is deleted but its dependent objects (Pods) are kept running. This provides the most control and minimizes downtime, but requires manual cleanup later.
Example Usage
Here’s how to configure Redis with a specific StatefulSet recreation strategy:
When to Use Different Strategies
- foreground: When you want to ensure a complete, clean recreation of the Redis system and can tolerate downtime.
- background: When you want to minimize the time the StatefulSet object itself exists in a “Terminating” state and don’t need to wait for dependent objects to be deleted.
- orphan: When you need to avoid downtime during StatefulSet recreation, especially in production environments. The existing Pods will continue to serve traffic while the new StatefulSet is being created.
Warning
Using the “orphan” strategy will keep the Pods running, but they won’t be managed by the StatefulSet until the new one adopts them. If the Pods need to be updated, you may need to manually delete them so the new StatefulSet can create fresh Pods.This feature is useful when upgrading Redis with changes to immutable StatefulSet fields, allowing administrators to control the recreation process according to their operational requirements.