-
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
Changes from 6 commits
3320d21
4eb9519
9b10a6c
08fb001
1c1e97a
fe70e8f
af70273
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,47 @@ data: | |
# Reload module configs as they change: | ||
reload.enabled: false | ||
|
||
# To enable hints based autodiscover uncomment this: | ||
#metricbeat.autodiscover: | ||
# providers: | ||
# - type: kubernetes | ||
# node: ${NODE_NAME} | ||
# hints.enabled: true | ||
metricbeat.autodiscover: | ||
providers: | ||
# To enable hints based autodiscover uncomment this: | ||
#- type: kubernetes | ||
# node: ${NODE_NAME} | ||
# hints.enabled: true | ||
# 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. | ||
#- type: kubernetes | ||
# scope: cluster | ||
# node: ${NODE_NAME} | ||
# unique: true | ||
# # identifier: <lease_lock_name> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 I will remove it |
||
# templates: | ||
# - config: | ||
# - module: kubernetes | ||
# hosts: ["kube-state-metrics:8080"] | ||
# period: 10s | ||
# add_metadata: true | ||
# metricsets: | ||
# - state_node | ||
# - state_deployment | ||
# - state_replicaset | ||
# - state_pod | ||
# - state_container | ||
# - state_cronjob | ||
# - state_resourcequota | ||
# - state_statefulset | ||
# # Uncomment this to get k8s events: | ||
# #- event | ||
# - module: kubernetes | ||
# metricsets: | ||
# - apiserver | ||
# hosts: ["https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}"] | ||
# bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token | ||
# ssl.certificate_authorities: | ||
# - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt | ||
# period: 30s | ||
|
||
processors: | ||
- add_cloud_metadata: | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 Removing the deployment completely will have the same result -> 0 Deployment Pods. |
||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
k8s-app: metricbeat | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,3 +197,44 @@ metricbeat 1 1 1 1 1m | |
------------------------------------------------ | ||
|
||
Metrics should start flowing to Elasticsearch. | ||
|
||
|
||
[float] | ||
==== Deploying Metricbeat Daemonset with Leader Election enabled | ||
|
||
In some cases users may want to avoid deploying both a Deployment and a Daemonset | ||
to collect cluser-wide metrics and node-level metrics. | ||
For this case, we provide the option to deploy Metricbeat only as a Daemonset | ||
and leverage the leader election feature which allows to define configurations | ||
that are enabled only by the leader Pod. The leader Pod is automatically chosen | ||
between the Pods of the Daemonset. | ||
Here is an example of a configuration that enables leader election: | ||
[source,yaml] | ||
----- | ||
metricbeat.autodiscover: | ||
providers: | ||
- type: kubernetes | ||
scope: cluster | ||
node: ${NODE_NAME} | ||
unique: true | ||
identifier: leaderelectionmetricbeat | ||
templates: | ||
- config: | ||
- module: kubernetes | ||
hosts: ["kube-state-metrics:8080"] | ||
period: 10s | ||
add_metadata: true | ||
metricsets: | ||
- state_node | ||
----- | ||
Users can find more info about the `unique` and `identifier` options at <<configuration-autodiscover>>. | ||
|
||
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: | ||
Comment on lines
+232
to
+235
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
["source", "sh", subs="attributes"] | ||
------------------------------------------------ | ||
curl -L -O https://raw.githubusercontent.com/elastic/beats/{branch}/deploy/kubernetes/metricbeat-kubernetes.yaml | ||
kubectl create -f metricbeat-kubernetes.yaml | ||
------------------------------------------------ |
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
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