Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[extension/leader elector] Initial implementation for the extension leader elector #37144

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

rakesh-garimella
Copy link

@rakesh-garimella rakesh-garimella commented Jan 10, 2025

Description

This extension could be used to run multiple receivers in HA mode. The receiver which has successfully acquired the lease becomes active and thus becomes leader.

The extension uses k8s.io/client-go/tools/leaderelection to perform leader election. The component that owns the lease becomes the leader and runs the function defined in onStartedLeading. If the leader loses the lease, it runs the function defined in onStoppedLeading, stops its operation, and waits to acquire the lease again.

The config would like this:

receivers:
  my_awesome_reciever:
    leader_elector: leader_elector
exporters:
  debug:
    verbosity: detailed
extensions:
  leader_elector:
    auth_type: kubeConfig
    lease_name: foo
    lease_namespace: default

service:
  extensions: [leader_elector]
  pipelines:
    metrics:
      receivers: [my_awesome_receiver]
      exporters: [debug]
  telemetry:
    logs:
      level: debug

Note: The receiver requires to be modified in order to support this extension.

Link to tracking issue

Fixes
#34460

Testing

Unit tests have been implemented.

Documentation

Readme doc has been added.

@rakesh-garimella rakesh-garimella requested a review from a team as a code owner January 10, 2025 14:30
Copy link

linux-foundation-easycla bot commented Jan 10, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@JaredTan95
Copy link
Member

One question, does this extension work for all receivers? Does the receiver need to be modified?

@rakesh-garimella
Copy link
Author

One question, does this extension work for all receivers? Does the receiver need to be modified?

Hi @JaredTan95 the receiver needs to be modified to be able to support this extension.

receivers: [my_awesome_receiver]
```
### Leader Election Configuration
Copy link
Member

@JaredTan95 JaredTan95 Jan 10, 2025

Choose a reason for hiding this comment

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

It would be better to give a rolebingding example about the lease that serviceaccount needs to bind with ClusterRoleBinding ClusterRole.

See the example in Kubernetes Events Receiver: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/k8seventsreceiver#rbac

@atoulme atoulme added the Sponsor Needed New component seeking sponsor label Jan 10, 2025
@atoulme
Copy link
Contributor

atoulme commented Jan 10, 2025

Please secure a sponsor for this component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sponsor Needed New component seeking sponsor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants