lighthouse-agent runs as a single replica. If the pod is evicted or a node fails/OOM issues etc. Service discovery synchronization stops until a replacement pod starts and re-lists all resources.
Proposal
Add leader election using coordination/v1 Leases so multiple replicas can run simultaneously. The leader processes resources; standby replicas keep informer caches warm. On failover, the new leader starts processing immediately with no cold-start delay.
Approach:
Syncers in Admiral already expose ShouldProcess hook, we can use that to make a decision on Leader to process the event and skip it on Replica. Ensuring the informer caches stay warm but we don't process events on both instances.
Probably can just add support for passive replica initially and build on top of that for hot standby replica as optimization.
Configuration:
The replica count should probably come from the operator itself as it configures this. Currently the count seems hardcoded?
https://github.com/submariner-io/submariner-operator/blob/928b75e213138a0daec74c32683a0253905de1e6/internal/controllers/servicediscovery/servicediscovery_controller.go#L241
Open Challenges:
- If we have a standby replica that gets the events and skips processing and we fail over, the events might stay in the informer cache and never be updated to API server. Might need to force drain post failover somehow
lighthouse-agent runs as a single replica. If the pod is evicted or a node fails/OOM issues etc. Service discovery synchronization stops until a replacement pod starts and re-lists all resources.
Proposal
Add leader election using coordination/v1 Leases so multiple replicas can run simultaneously. The leader processes resources; standby replicas keep informer caches warm. On failover, the new leader starts processing immediately with no cold-start delay.
Approach:
Syncers in Admiral already expose ShouldProcess hook, we can use that to make a decision on Leader to process the event and skip it on Replica. Ensuring the informer caches stay warm but we don't process events on both instances.
Probably can just add support for passive replica initially and build on top of that for hot standby replica as optimization.
Configuration:
The replica count should probably come from the operator itself as it configures this. Currently the count seems hardcoded?
https://github.com/submariner-io/submariner-operator/blob/928b75e213138a0daec74c32683a0253905de1e6/internal/controllers/servicediscovery/servicediscovery_controller.go#L241
Open Challenges: