I have been searching alot on how to deploy redis with high availability on kubernetes. I have some problems using redis cluster mode and when using the master-slave mode we need to also deploy sentinel to be able to handle master failures
I have been reviewing this great doc which explains how to do that but, I think there is something missing.
I have deployed what's mentioned there but, I needed to make some changes to for the sentinel containers to run in sentinel mode now the main redis-master pod manifest which has the main redis master and the sentinel looks like this.
# redis-master.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
name: redis
redis-sentinel: "true"
role: master
name: redis-master
spec:
containers:
- name: master
image: redis
env:
- name: MASTER
value: "true"
ports:
- containerPort: 6379
resources:
limits:
cpu: "0.1"
volumeMounts:
- mountPath: /redis-master-data
name: data
- name: sentinel
image: redis
command:
- redis-sentinel
- "/redis-master-data/redis.conf"
env:
- name: SENTINEL
value: "true"
ports:
- containerPort: 26379
volumeMounts:
- mountPath: /redis-master-data
name: data
- mountPath: /redis-master
name: config
initContainers:
- name: copy
image: redis
command: ["bash", "-c", "cp /redis-master/redis.conf /redis-master-data/"]
volumeMounts:
- mountPath: /redis-master
name: config
- mountPath: /redis-master-data
name: data
volumes:
- name: data
emptyDir: {}
- name: config
configMap:
name: example-redis-config
items:
- key: redis-config
path: redis.conf
now after all that I am having 2 problems
first this doc is making a service for the sentinels only so I know I should make a service for the redis but I am not even sure are they both masters or not.
second problem assuming one is master and the other is a slave when a failure happens and the sentinel elects a new master how to make that new master belong to the service of the redis masters and not the slave service (cause usually we will make 2 services one which expose masters and the other for slaves)
NOTE: please review the doc mentioned above to understand my question well.