I have an application using the Spring Cloud Kubernetes leader election mechanism. When shutting down the pod, I would like to revoke leadership before the Spring graceful shutdown starts to ensure that the leader is never shutdown. This is to avoid that the instance is shutdown while the leader is doing one of its tasks.
For that, I added a preStop hook which is executed when the pod starts shutting down and before the Spring graceful shutdown is started. But I have observed that sometimes the leadership is granted to the same pod. Is there a way to avoid that?
I have added an internal flag to make the application aware the shutdown is in progress, so if the leadership is granted again, I can avoid to do any leader-related operation. With this what Im implementing is that the leader stops doing its tasks before shutting down, but even though this solves my original problem, its not exactly what I was trying to implement on first place.
Thanks in advance!
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744757752a4591984.html
评论列表(0条)