最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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!

发布评论

评论列表(0)

  1. 暂无评论