-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Implement kubernetes agent cluster scope leader election #19731
Comments
Pinging @elastic/integrations-platforms (Team:Platforms) |
go-client includes a leader election implementation https://godoc.org/k8s.io/client-go/tools/leaderelection |
+1 for using leader election package @jsoriano proposed. I drafted an experimental code snippet and seemed to work, so the implementation should be quite straight forward on leader election level. However we need to figure out at which point we will integrate this change. One possible solution could be to add this on Module level. In this, we will give the option to the users to define an extra flag to define that this module configuration should be applied only on leader elected nodes. For instance:
|
Love to see this is viable! Thank you for digging in. I was thinking this could make more sense in autodiscover? This may go beyond the scope of the kubernetes module, as I may have some other inputs I want to launch as a singleton for the whole cluster. (ie, running certain uptime monitors, a global gateway for logs, etc) If we add a I'm not fully onboard with this either, would like to hear other opinions and use cases |
I was also thinking that it could make sense in autodiscover, it could be a new provider with a config like this:
Or this:
The configuration could be in a configmap, so all the leader candidates would have the same configuration, though maybe this is not so important if they are deployed with a If a provider gets the lock, it generates an event to start the configuration, if it loses it, it stops it. And this could be used with other modules with cluster scope. |
Do you foresee any situation where you may want to use Pods/Nodes/Service autodiscover in combination with leader election? If that's the case, perhaps the |
Umm, yeah, we might want to enable it only if some pods or services exist, and using their metadata.
Where would you put this flag? at the template level so we can have different leaders?
Or at the provider level? and multiple providers are needed if multiple leaderships are wanted?
At the provider level it looks better as the provider keeps state, and we probably don't need multiple leaderships on the same instance. |
++ for making this an autodiscover feature as several integrations other than After reading the comments I'm wondering, should this feature be called leader election at all? As a user, if I deploy 3 metricbeats and I see "leader election" I suppose one of them will be somehow special, but it seems we'll have a different abstraction layer here: with the leader being elected among the providers and not the beats, we may potentially have several leaders around at the same time and for a single beat instance. Would something like this be more intuitive?
Note I also omitted the configmap name / leader id as I think it'd be better if we could hide it as an implementation detail. This would save the users the extra cognitive effort and us the burden of validating user input. |
|
This would fit in a case where we want to automatically identify +1 for @masci 's version (plus having hardcoded the beat name as default identifier):
So every provider that is "tagged" with wdyt @exekias ? |
PoC for further discussion: #20281 |
sounds good to me folks! +1 on Jaime's comment to have another parameter to specify the identifier, with a good default |
Something we need to figure out is what happens to metadata. When doing
For the later part, how will the UX be? by doing this with autodiscover we may be adding unwanted metadata to the input, as autodiscover may understand it's launching the input for certain Pod, right? |
I think that's right in principle. However we don't ship any |
Pinging @david-kow who might be also interested into this new feature. |
Reopening to check we are done with documentation / recommendations / migration path. |
Good catch, we've some conversations running about docs/recommendations here #20601 |
Right now, when deploying Metricbeat on Kubernetes we deploy two different resources:
kube-state-metrics
and Kubernetes events.We could simplify this by removing the need for a Deployment in favour of some type of leader election within the DaemonSet. In a nutshell, we need a way to flag one of the agents in the Daemonset as leader, making it in charge of both host and cluster scopes.
While leader election is challenging, API Server provides a great locking mechanism that is present in K8S, and we can leverage in many ways. So we don't really need things like agents talking to each other.
We should discuss our options here, one possibility is doing something like this:
leader
field as part of autodiscover events. This way cluster scope metricsets can be configured based on that.The text was updated successfully, but these errors were encountered: