Skip to content

Latest commit

 

History

History
141 lines (86 loc) · 11.2 KB

File metadata and controls

141 lines (86 loc) · 11.2 KB
graph LR
    LeaderElectionManager["LeaderElectionManager"]
    ResourceLockInterface["ResourceLockInterface"]
    ConfigMapResourceLock["ConfigMapResourceLock"]
    LeaseResourceLock["LeaseResourceLock"]
    LeaderElectionRecord["LeaderElectionRecord"]
    KubernetesCoreV1APIClient["KubernetesCoreV1APIClient"]
    V1ConfigMapModel["V1ConfigMapModel"]
    KubernetesCoordinationV1APIClient["KubernetesCoordinationV1APIClient"]
    V1LeaseModel["V1LeaseModel"]
    LeaderElectionTest["LeaderElectionTest"]
    LeaderElectionManager -- "manages leadership using" --> ResourceLockInterface
    ConfigMapResourceLock -- "implements" --> ResourceLockInterface
    LeaseResourceLock -- "implements" --> ResourceLockInterface
    ConfigMapResourceLock -- "interacts with" --> KubernetesCoreV1APIClient
    ConfigMapResourceLock -- "uses" --> V1ConfigMapModel
    LeaseResourceLock -- "interacts with" --> KubernetesCoordinationV1APIClient
    LeaseResourceLock -- "uses" --> V1LeaseModel
    ResourceLockInterface -- "stores state in" --> LeaderElectionRecord
    LeaderElectionTest -- "tests" --> LeaderElectionManager
    LeaderElectionTest -- "uses mock for" --> ResourceLockInterface
Loading

CodeBoardingDemoContact

Component Details

This component provides a robust implementation of leader election logic, crucial for building highly available and fault-tolerant applications in Kubernetes. It uses Kubernetes resources (like ConfigMaps or Leases) as distributed locks to ensure only one instance of an application performs a critical task at a time.

LeaderElectionManager

Manages the leader election process, including acquiring and renewing the leadership lease. It orchestrates the election logic and interacts with a resource lock to maintain leadership.

Related Classes/Methods:

ResourceLockInterface

Defines the abstract interface for resource lock mechanisms used in leader election. Concrete implementations provide methods to get, create, and update the leader election record.

Related Classes/Methods:

  • kubernetes.base.leaderelection.resourcelock.resourcelock.ResourceLock (full file reference)

ConfigMapResourceLock

Implements the resource lock mechanism using Kubernetes ConfigMaps. It provides methods to get, create, and update the leader election record stored in a ConfigMap, acting as the persistent storage for leadership status.

Related Classes/Methods:

LeaseResourceLock

Implements the resource lock mechanism using Kubernetes Leases. It provides methods to get, create, and update the leader election record stored in a Lease object.

Related Classes/Methods:

  • kubernetes.base.leaderelection.resourcelock.leaselock.LeaseLock (full file reference)

LeaderElectionRecord

Represents the data structure used to store the leader election state, including holder identity, lease duration, and acquire/renew times.

Related Classes/Methods:

KubernetesCoreV1APIClient

Provides an interface to interact with the Kubernetes Core V1 API server, specifically for managing ConfigMap objects.

Related Classes/Methods:

V1ConfigMapModel

Represents the Kubernetes V1ConfigMap object model, used for data serialization and deserialization when interacting with the Kubernetes API.

Related Classes/Methods:

KubernetesCoordinationV1APIClient

Provides an interface to interact with the Kubernetes Coordination V1 API server, specifically for managing Lease objects.

Related Classes/Methods:

V1LeaseModel

Represents the Kubernetes V1Lease object model, used for data serialization and deserialization when interacting with the Kubernetes API.

Related Classes/Methods:

LeaderElectionTest

Contains unit tests for the leader election mechanism, simulating different scenarios of leader election and verifying the behavior of the LeaderElection and ResourceLock components.

Related Classes/Methods: