Avoid leadership grant on shutdown (Spring Cloud Kubernetes) - Stack Overflow

I have an application using the Spring Cloud Kubernetes leader election mechanism. When shutting down t

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信