-
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
Add k8s manifest leveraging leaderelection #20512
Add k8s manifest leveraging leaderelection #20512
Conversation
Signed-off-by: chrismark <[email protected]>
Pinging @elastic/integrations-platforms (Team:Platforms) |
Tested on a 3-node cluster on GKE:
Reviews more than welcome at this point. |
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
I wonder if we want to maintain the two sets of manifests for Metricbeat. Having a provider with leader election or a deployment to do the same thing is an implementation detail. I think that having an only strategy is more clear, and having leader election by default seems a better option as it only requires the One way to help on the migration while keeping the current set of manifests would be:
Having the deployment with |
Or we can also add the leadership configuration to current manifests but commented out, and add a comment about deleting the deployment if this configuration is wanted. |
Oh, another thought come to my mind that could affect the decision of deprecating the deployment manifest. How does leader election work when there are many candidates? In a cluster with thousands of nodes there will be thousands of candidates competing for the lease. |
Hmm, good question but I don't think we can know about it if we don't try 🙂 . The thousands of leader candidates will try to get the lock and we rely on the locking mechanism of the Is this what you had in mind? |
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Yes, this is what I was thinking, with 3K candidates, if a leader change is needed, 3K interactions with the API will be done more or less suddenly. But as you say in a cluster this size the API is probably sized accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config LGTM, added some suggestions about the docs.
Signed-off-by: chrismark <[email protected]>
(cherry picked from commit 7b7fb3b)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry for the posthumous review here but I didn't expect we would merge right ahead.
I'm not sure I fully understand why we're keeping around the single-pod deployment. I know we need to keep backward compatibility but the setup for new users onboarding with 7.10 seems a bit clumsy, having to manually remove the deployment definition or (worse) set replicas to 0.
Can we discuss what's the use case that would impact backward compatibility if we remove the deployment?
Users can enable the respective parts the Daemonset ConfigMap and | ||
set the `replicas` of the Deployment to `0` in order to only deploy | ||
the Daemonset on the cluster with the leader election provider enabled | ||
in order to collect cluster-wide metrics: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrsMark Something doesn't work with the wording here, we should make this statement a bit clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Uncomment the following to enable leader election provider that handles | ||
# singleton instance configuration across the Daemonset Pods of the whole cluster | ||
# in order to monitor some unique data sources, like kube-state-metrics. | ||
# When enabling this remember to also delete the Deployment or just set the replicas of the | ||
# Deployment to 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too much wording IMO, if we do the docs right this should only be
# uncomment the following to enable collection from kube-state-metrics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I will try to improve it
# scope: cluster | ||
# node: ${NODE_NAME} | ||
# unique: true | ||
# # identifier: <lease_lock_name> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be confusing: under which circumstances should I uncomment? What the value should be in that case?
I'd remove this line altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I will remove it
@@ -258,6 +293,8 @@ metadata: | |||
labels: | |||
k8s-app: metricbeat | |||
spec: | |||
# Set to 0 if using leader election provider with the Daemonset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we remove the Deployment instead? I don't think the UX is great here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Removing the deployment completely will have the same result -> 0 Deployment Pods.
Thanks for the comments @masci! I would say that the current approach is smoother for every case. I don't think we should remove the Deployment completely by now since in many cases it can be really helpful when it comes to scaling where someone may want to collect cluster-wide metrics from big clusters. In this regard, introducing the new |
Let's continue the discussion at #20601 |
What does this PR do?
This PR proposes new Kubernetes manifests for shake of #19731, leveraging unique Autodiscover provider implemented at #20281.
With these manifests, only Metricbeat's Deamonset will be able to monitor whole k8s cluster since one Deamonset Pod each time will hold the leadership being responsible to coordinate metricsets that collect cluster wide metrics.
We will might need a meta issue to keep track of deprecating Deployment manifests (if needed).
Why is it important?
To get rid of the requirement to maintain/handle two different deployment strategies.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Test the manifests similarly to the testing steps of #20281 (comment).
metricbeat-leaderelection-kubernetes.yml
properly to set the proper image (iedocker.elastic.co/beats/metricbeat:7.10.0-SNAPSHOT
) and the proper ES output (ie on Elastic Cloud)metricbeat-leaderelection-kubernetes.yml
manifest and make sure that all the desired metricsets are shipping events and that k8s related Dashboards are populated with data correctly.kubectl delete
the leader pod and make sure that the leadership is either transfered to another Pod or it is gained again by the new replacement Pod.Example:
Related issues