Leader Election Documentation (#728)

* Leader Election Documentation

* update docs

Co-authored-by: aswanson <anders_swanson@mcafee.com>
This commit is contained in:
Anders Swanson
2021-02-08 07:01:03 -08:00
committed by GitHub
parent 696627ee47
commit fd018e807d
2 changed files with 31 additions and 1 deletions

View File

@@ -1,3 +1,31 @@
== Leader Election
The Spring Cloud Kubernetes leader election mechanism implements the leader election API of Spring Integration using a Kubernetes ConfigMap.
<TBD>
Multiple application instances compete for leadership, but leadership will only be granted to one.
When granted leadership, a leader application receives an `OnGrantedEvent` application event with leadership `Context`.
Applications periodically attempt to gain leadership, with leadership granted to the first caller.
A leader will remain a leader until either it is removed from the cluster, or it yields its leadership.
When leadership removal occurs, the previous leader receives `OnRevokedEvent` application event.
After removal, any instances in the cluster may become the new leader, including the old leader.
To include it in your project, add the following dependency.
====
Fabric8 Leader Implementation
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-kubernetes-fabric8-leader</artifactId>
</dependency>
----
====
====
To specify the name of the configmap used for leader election use the following property.
====
[source]
----
spring.cloud.kubernetes.leader.config-map-name=leader
----
====

View File

@@ -1,2 +1,4 @@
# Role to which leader election this instance will participate
spring.cloud.kubernetes.leader.role=world
# Configmap to which leader election metadata will be saved
spring.cloud.kubernetes.leader.config-map-name=leader