Install highly available Redis with Sentinel#
-
Install the Redis Operator from the OT-Container-Kit Helm repository:
helm install redis-operator redis-operator \ --repo https://ot-container-kit.github.io/helm-charts \ --set featureGates.GenerateConfigInInitContainer=true -
Generate a strong, random password for authenticating with Redis:
PASSWORD=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 24) -
Create a Kubernetes secret to securely store the password:
kubectl create secret generic msr-redis-secret \ --from-literal=REDIS_PASSWORD=${PASSWORD} -
Deploy the Redis with Sentinel instance:
Note
Set
clusterSizeandsentinel.sizeto the desired number of Redis nodes.helm install msr-redis redis-replication \ --repo https://ot-container-kit.github.io/helm-charts \ --set redisReplication.clusterSize=3 \ --set redisReplication.image=quay.io/opstree/redis \ --set redisReplication.tag=v7.2.13 \ --set redisReplication.redisSecret.secretName=msr-redis-secret \ --set redisReplication.redisSecret.secretKey=REDIS_PASSWORD \ --set podSecurityContext.runAsUser=1000 \ --set podSecurityContext.fsGroup=1000 \ --set sentinel.enabled=true \ --set sentinel.size=3 \ --set sentinel.image=quay.io/opstree/redis-sentinel \ --set sentinel.tag=v7.2.13 \ --set storageSpec.volumeClaimTemplate.spec.accessModes={ReadWriteOnce} \ --set storageSpec.volumeClaimTemplate.spec.resources.requests.storage=8Gi -
Retrieve the connection details for the Redis service:
Get the Sentinel master name:
kubectl -n default get redisreplication msr-redis -o jsonpath='{.status.connectionInfo. masterName}{"\n"}'Get the Sentinel headless service's name and port number:
kubectl get svc | grep redis i.e. msr-redis ClusterIP 10.96.169.88 <none> 6379/TCP 34s msr-redis-additional ClusterIP 10.96.57.50 <none> 6379/TCP 34s msr-redis-headless ClusterIP None <none> 6379/TCP 34s msr-redis-master ClusterIP 10.96.57.51 <none> 6379/TCP 34s msr-redis-replica ClusterIP 10.96.33.204 <none> 6379/TCP 34s msr-redis-s-hl ClusterIP None <none> 26379/TCPIn the example above,
msr-redis-s-hlis Sentinel headless service which uses port26379. -
In
values.yml, configure the Redis connection fields using the Sentinel service, port, and master name:addr— Comma-separated list of Sentinel pod addresses in the following format:<pod-name>.<headless-service-name>.<namespace>.svc.cluster.local:<port>sentinelMasterSet— Master name defined during Sentinel deployment (for example,mymaster).
Example configuration:
redis: type: external external: addr: "msr-redis-s-0.msr-redis-s-hl.default.svc.cluster.local:26379,msr-redis-s-1.msr-redis-s-hl.default.svc.cluster.local:26379,msr-redis-s-2.msr-redis-s-hl.default.svc.cluster.local:26379" existingSecret: msr-redis-secret sentinelMasterSet: "mymaster"
Upgrade highly available Redis#
-
Verify Redis version:
kubectl get pod <Redis Pod> -o jsonpath='{.spec.containers[*].image}' kubectl get pod <Sentinel Pod> -o jsonpath='{.spec.containers[*].image}' -
Upgrade Redis:
helm upgrade msr-redis redis-replication \ --repo https://ot-container-kit.github.io/helm-charts \ --set redisReplication.clusterSize=3 \ --set redisReplication.image=quay.io/opstree/redis \ --set redisReplication.tag=v7.2.13 \ --set redisReplication.redisSecret.secretName=msr-redis-secret \ --set redisReplication.redisSecret.secretKey=REDIS_PASSWORD \ --set podSecurityContext.runAsUser=1000 \ --set podSecurityContext.fsGroup=1000 \ --set sentinel.enabled=true \ --set sentinel.size=3 \ --set sentinel.image=quay.io/opstree/redis-sentinel \ --set sentinel.tag=v7.2.13 \ --set storageSpec.volumeClaimTemplate.spec.accessModes={ReadWriteOnce} \ --set storageSpec.volumeClaimTemplate.spec.resources.requests.storage=8GiNote
Mirantis recommends Redis 7.2.11 or later within 7.2.x branch. The validated versions are 7.2.11, 7.2.12, and 7.2.13. For the full list of available versions, see the redis-operator page.