diff --git a/docs/src/main/asciidoc/leader-election.adoc b/docs/src/main/asciidoc/leader-election.adoc index aee32932..474b1eb6 100644 --- a/docs/src/main/asciidoc/leader-election.adoc +++ b/docs/src/main/asciidoc/leader-election.adoc @@ -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. - +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] +---- + + org.springframework.cloud + spring-cloud-kubernetes-fabric8-leader + +---- +==== + +==== + +To specify the name of the configmap used for leader election use the following property. +==== +[source] +---- +spring.cloud.kubernetes.leader.config-map-name=leader +---- +==== diff --git a/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/src/main/resources/application.properties b/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/src/main/resources/application.properties index f6ededa7..6c665afd 100644 --- a/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/src/main/resources/application.properties +++ b/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/src/main/resources/application.properties @@ -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