Closed iva3682 closed 2 months ago
Why do we need custom this param ? @iva3682
When you restart a pod with Sentinel, its myid changes to a random one. Other Sentinels receive his new myid, but the old one also takes part in the elections, which prevents the correct determination of the Sentinel master. Using the SENTINEL_ID parameter, you can fix myid to a specific value. For example, (when using Stateful Sets) like this:
...
- env:
- name: SENTINEL_ID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
...
I understand. It seems to be related to removing the sentinel in the cluster, as described in this Redis documentation. I'm not sure if it works, because I couldn't find an example of sentinel myid in the Redis GitHub repository.
Yes, for some reason Redis developers do not mention the possible "sentinel myid" configuration in sentinel.conf (it might make sense to create a corresponding issue in the redis repository), but this parameter is described here: https://github.com/redis/redis/blob/617909e943be0691ac9179aa1e6664937a4ca255/src/sentinel.c#L510. I use this patch in my cluster and it works fine: after restarting the Sentinel pod, the expected number of instances participate in the elections, not +1. There is no need to execute the SENTINEL RESET command after restarting the pod, this has a good effect on the autonomy of the Sentinel cluster.
add SENTINEL_ID for fixed sentinel myid