Skip to content

K8s client leader election#2107

Merged
ryanjbaxter merged 21 commits intospring-cloud:mainfrom
wind57:k8s-native-leader-election
Dec 31, 2025
Merged

K8s client leader election#2107
ryanjbaxter merged 21 commits intospring-cloud:mainfrom
wind57:k8s-native-leader-election

Conversation

@wind57
Copy link
Contributor

@wind57 wind57 commented Dec 22, 2025

No description provided.

Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
<module>spring-cloud-starter-kubernetes-fabric8-loadbalancer</module>
<module>spring-cloud-kubernetes-discovery</module>
<module>spring-cloud-starter-kubernetes-discoveryclient</module>
<module>spring-cloud-kubernetes-client-leader</module>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new module that adds support for k8s client leader election

Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>

private volatile boolean shutDownCalled = false;

KubernetesClientLeaderElectionInitiator(String candidateIdentity, String candidateNamespace,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as with fabric8 implementation, this is the main class you should look at.

@wind57 wind57 changed the title K8s native leader election K8s client leader election Dec 28, 2025
@wind57 wind57 marked this pull request as ready for review December 28, 2025 21:41
@wind57
Copy link
Contributor Author

wind57 commented Dec 28, 2025

@ryanjbaxter k8s client leader election implementation is ready to be looked at. It very much looks like fabric8 one tbh. thank you

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements leader election support for the Kubernetes Java client, complementing the existing Fabric8 implementation. It introduces native leader election functionality that can use either Lease or ConfigMap resources as locks, depending on cluster capabilities.

Key Changes:

  • Added a new module spring-cloud-kubernetes-client-leader with complete leader election implementation
  • Created comprehensive integration tests covering various leader election scenarios (readiness checks, failover, concurrent elections)
  • Updated documentation to reflect support for both Fabric8 and Kubernetes client implementations

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
spring-cloud-kubernetes-client-leader/pom.xml New module definition for K8s client leader election
spring-cloud-kubernetes-client-leader/src/main/java/** Core implementation classes including initiator, callbacks, and auto-configuration
spring-cloud-kubernetes-client-leader/src/test/java/** Unit tests for auto-configuration and info contributor functionality
spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-leader-election/** Integration tests covering readiness, failover, and concurrent election scenarios
spring-cloud-kubernetes-dependencies/pom.xml Added dependency management for the new module
pom.xml Added new module to the parent POM
spring-cloud-kubernetes-integration-tests/pom.xml Added integration test module reference
docs/modules/ROOT/pages/leader-election.adoc Updated documentation to mention both Fabric8 and K8s client support
spring-cloud-kubernetes-fabric8-leader/** Minor naming corrections and test improvements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: wind57 <eugen.rabii@gmail.com>
@wind57
Copy link
Contributor Author

wind57 commented Dec 30, 2025

@ryanjbaxter I fixed copilot comments, can you re-trigger it again? thank you

Signed-off-by: wind57 <eugen.rabii@gmail.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: wind57 <eugen.rabii@gmail.com>
@github-project-automation github-project-automation bot moved this to Todo in 2025.1.1 Dec 31, 2025
@ryanjbaxter ryanjbaxter added this to the 5.0.1 milestone Dec 31, 2025
@ryanjbaxter ryanjbaxter merged commit 1881bf9 into spring-cloud:main Dec 31, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in 2025.1.1 Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants