Configuring Redis in High Availability Mode
Redis High Availability (HA) is currently in Experimental mode, therefore is not fully supported and have the following limitations:
-
No more than 1 master can be deployed per Kubernetes node
-
Replicas and writers can only see the single master of their own Kubernetes node
To achieve HA, the following parameters have to be set:
-
redis.master.countshould be less or equal the number of nodes in the Kubernetes cluster -
redis.replica.replicaCountshould be more or equal toredis.master.count -
redis.master.service.internalTrafficPolicyshould be set toLocalin order to limit replica and master communication within their own Kubernetes node -
redis.master.topologySpreadConstraintsandredis.master.affinityshould be set in order to allow only 1 replica per nodeaffinity: podAntiAffinityPreset: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: app.kubernetes.io/name: redis app.kubernetes.io/component: master topologyKey: kubernetes.io/hostname ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity topologySpreadConstraints: - maxSkew: 1 topologyKey: topology.kubernetes.io/zone whenUnsatisfiable: DoNotSchedule labelSelector: matchLabels: app.kubernetes.io/name: redis app.kubernetes.io/component: master ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ -
redis.replica.affinityshould be set in order to match the setup of the master nodesaffinity: podAffinityPreset: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: app.kubernetes.io/name: redis app.kubernetes.io/component: master topologyKey: kubernetes.io/hostname ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity -
redis.replica.topologySpreadConstaintsshould be set accordingly to the number of replicas desired in a single node:topologySpreadConstraints: - maxSkew: 1 topologyKey: topology.kubernetes.io/zone whenUnsatisfiable: DoNotSchedule labelSelector: matchLabels: app.kubernetes.io/name: redis app.kubernetes.io/component: replica ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/