Skip to content

add support Lease-based leader election (rather than ConfigMaps) #1877

Closed

Description

@thesuperzapper

What is the feature and why do you need it:

Currently, the K8S Python API only supports leader election using ConfigMapLock.

The K8S Go API supports using the proper Lease resource type with its LeaseLock, and actually recently removed support for the legacy ConfigMap approach.

We should update the Kubernetes Python API to provide a Lease-based leader election.


/cc @Invictus17 @tdihp

Activity

  1. roycaihw commented on Aug 15, 2022

    @roycaihw
    Member

    /help

  2. k8s-ci-robot commented on Aug 15, 2022

    @k8s-ci-robot
    Contributor

    @roycaihw:
    This request has been marked as needing help from a contributor.

    Guidelines

    Please ensure that the issue body includes answers to the following questions:

    • Why are we solving this issue?
    • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
    • Does this issue have zero to low barrier of entry?
    • How can the assignee reach out to you for help?

    For more details on the requirements of such an issue, please see here and ensure that they are met.

    If this request no longer meets these requirements, the label can be removed
    by commenting with the /remove-help command.

    Details

    In response to this:

    /help

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

  3. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Aug 15, 2022
  4. Jagrutiti commented on Aug 21, 2022

    @Jagrutiti

    Hi,

    I am beginner to Kuberenetes repo. Do you think this is a good issue to pick?

  5. k8s-triage-robot commented on Feb 8, 2023

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

    This bot triages PRs according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

    You can:

    • Mark this PR as fresh with /remove-lifecycle stale
    • Close this PR with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  6. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Feb 8, 2023
  7. thesuperzapper commented on Feb 8, 2023

    @thesuperzapper
    Author

    /remove-lifecycle stale

  8. removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Feb 8, 2023
  9. edas-smith commented on Jun 17, 2024

    @edas-smith

    +1 for this - Would be great to have this

  10. lwille commented on Jul 25, 2024

    @lwille

    Adding my +1 to prevent this from becoming stale.

  11. rvlane commented on Oct 9, 2024

    @rvlane
    Contributor

    Came across this researching providing HA on an operator based solution and wanted to have this Lease-base lock implemented. Got a fork setup through my company and plan to contribute this back to the project. Just need to know the process for contributing this back. Thanks

  12. Invictus17 commented on Nov 3, 2024

    @Invictus17
    Contributor

    @rvlane you can send a PR similar to https://github.com/kubernetes-client/python/pull/1747/commits. Hope that helps. I can review it.

    cc: @roycaihw

  13. rvlane commented on Dec 16, 2024

    @rvlane
    Contributor

    @Invictus17 Thanks. Starting work on this now.

  14. rvlane commented on Dec 17, 2024

    @rvlane
    Contributor

    @Invictus17 Implementation question:
    Currently the LeaderElectionRecord saves the string representation of the times and lease_duration. I woiuld prefer to change this to save the raw datetime object and let ConfigMapLock and the new LeaseLock decode as needed since currently ConfigMapLock saves to the annotation in string format and the isoformat is required by the V1Lease object. Reluctant to do this in case anyone is using the LeaderElectioniRecord itself. So question is: Can I change LeaderElectionRecord to store raw objects instead of string representations? Otherwise, if need to keep this record structure in tact, will convert from string to object, then to isoformat for the V1Lease. Thanks.

    cc: @roycaihw

  15. rvlane commented on Dec 17, 2024

    @rvlane
    Contributor

    @Invictus17 Pull request created: #2314

  16. chala2001 commented on Aug 28, 2026

    @chala2001
    Contributor

    Opened #2690 for this. It picks up @rvlane's #2314, which the triage robot closed as rotten last November; his commit is credited with a Co-authored-by trailer.

    @roycaihw the test you asked for on that PR is included, along with a few fixes that came out of rebasing it onto current master. The one worth mentioning here: the times were being written as local wall clock with a Z appended, so on any host that is not UTC the Lease carried a timestamp off by the host's offset, which would not interoperate with a client-go leader on the same Lease.

    @MadJlzz @Invictus17 you both offered to help on this one, so it is up if you have time to look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions