kubernetes_asyncio.leaderelection.resourcelock.leaselock module

class kubernetes_asyncio.leaderelection.resourcelock.leaselock.LeaseLock(name: str, namespace: str, identity: str, api_client: ApiClient)

Bases: BaseLock

async create(name: str, namespace: str, election_record: LeaderElectionRecord) bool
Parameters:
  • electionRecord – Annotation string

  • name – Name of the lease object to be created

  • namespace – Namespace in which the lease object is to be created

Returns:

‘True’ if object is created else ‘False’ if failed

election_record(lease: V1Lease)

Get leader election record from Lease spec.

async get(name: str, namespace: str) tuple[bool, LeaderElectionRecord] | tuple[bool, Exception] | tuple[bool, None]
Parameters:
  • name – Name of the lease object information to get

  • namespace – Namespace in which the lease object is to be searched

Returns:

‘True, election record’ if object found else ‘False, exception response’

time_str_to_iso(str_time) datetime | None
async update(name: str, namespace: str, updated_record: LeaderElectionRecord) bool
Parameters:
  • name – name of the lock to be updated

  • namespace – namespace the lock is in

  • updated_record – the updated election record

Returns:

True if update is successful False if it fails

update_lease(leader_election_record: LeaderElectionRecord, current_spec: V1LeaseSpec | None = None)