0

I have a Spring Boot web application, packaged as a container that I am deploying in Kubernetes. The application has a scheduled job that must run periodically only on one of the running pods.

I'm using Spring Cloud Kubernetes's leader election capability, with Fabric8 as the provider, to select the pod that runs this job.

Suppose I run this service with one pod instance. The first time I start this service, it elects the one pod as the leader, and everything works as expected. But if I kill the pod, the new pod instance does not recover; it is unable to elect itself as the leader. The configmap that indicates which pod is the leader still points to the old killed pod.

If I delete the configmap entry, the pod detects that there is no leader and then elects itself.

How can I fix this so that my new pod elects itself as the leader automatically, without me having to delete the configmap?

Mark
  • 4,970
  • 5
  • 42
  • 66

1 Answers1

1

Ideally upon the leader died lease won't get renewed as per example after sometime, thus lease resources should be acquired by another candidate after a timeout.

Otherwise terminate the pod gracefully, in the shutdown hook execute the cleanup logic.

Hrishikesh
  • 370
  • 3
  • 11