Skip to content

Commit

Permalink
[Kubernetes - Metricbeat] Providing config option to disable Kubeadm …
Browse files Browse the repository at this point in the history
…config api requests (#40086)


* updating with config_kubeAdm and setbool option
  • Loading branch information
gizas authored Sep 10, 2024
1 parent 5bd0723 commit 7176eec
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Add new memory/cgroup metrics to Kibana module {pull}37232[37232]
- Add SSL support to mysql module {pull}37997[37997]
- Add SSL support for aerospike module {pull}38126[38126]
- Add `use_kubeadm` config option in kubernetes module in order to toggle kubeadm-config api requests {pull}40086[40086]
- Add new metricset network for the vSphere module. {pull}40559[40559]
- Add new metricset resourcepool for the vSphere module. {pull}40456[40456]
- Log the total time taken for GCP `ListTimeSeries` and `AggregatedList` requests {pull}40661[40661]
Expand Down
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12587,11 +12587,11 @@ various licenses:

--------------------------------------------------------------------------------
Dependency : github.com/elastic/elastic-agent-autodiscover
Version: v0.8.1
Version: v0.8.2
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-autodiscover@v0.8.1/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-autodiscover@v0.8.2/LICENSE:

Apache License
Version 2.0, January 2004
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ require (
github.com/awslabs/kinesis-aggregation/go/v2 v2.0.0-20220623125934-28468a6701b5
github.com/elastic/bayeux v1.0.5
github.com/elastic/ebpfevents v0.6.0
github.com/elastic/elastic-agent-autodiscover v0.8.1
github.com/elastic/elastic-agent-autodiscover v0.8.2
github.com/elastic/elastic-agent-libs v0.10.0
github.com/elastic/elastic-agent-system-metrics v0.11.1
github.com/elastic/go-elasticsearch/v8 v8.14.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ github.com/elastic/dhcp v0.0.0-20200227161230-57ec251c7eb3 h1:lnDkqiRFKm0rxdljqr
github.com/elastic/dhcp v0.0.0-20200227161230-57ec251c7eb3/go.mod h1:aPqzac6AYkipvp4hufTyMj5PDIphF3+At8zr7r51xjY=
github.com/elastic/ebpfevents v0.6.0 h1:BrL3m7JFK7U6h2jkbk3xAWWs//IZnugCHEDds5u2v68=
github.com/elastic/ebpfevents v0.6.0/go.mod h1:ESG9gw7N+n5yCCMgdg1IIJENKWSmX7+X0Fi9GUs9nvU=
github.com/elastic/elastic-agent-autodiscover v0.8.1 h1:u6TWqh7wfevu6S4GUq4SIxYBRo4b/P5RZmx/rSvT10A=
github.com/elastic/elastic-agent-autodiscover v0.8.1/go.mod h1:0gzGsaDCAqBfUZjuCqqWsSI60eaZ778A5tQZV72rPV0=
github.com/elastic/elastic-agent-autodiscover v0.8.2 h1:Fs2FhR33AMBPfm5/jz4drVzaEZaqOIHlDBvGtkUZdIk=
github.com/elastic/elastic-agent-autodiscover v0.8.2/go.mod h1:VZnU53EVaFTxR8Xf6YsLN8FHD5DKQzHSPlKax9/4w+o=
github.com/elastic/elastic-agent-client/v7 v7.15.0 h1:nDB7v8TBoNuD6IIzC3z7Q0y+7bMgXoT2DsHfolO2CHE=
github.com/elastic/elastic-agent-client/v7 v7.15.0/go.mod h1:6h+f9QdIr3GO2ODC0Y8+aEXRwzbA5W4eV4dd/67z7nI=
github.com/elastic/elastic-agent-libs v0.10.0 h1:W7uvay0UYdLPtauXGsMD8Xfoe4qtcVWQR4icBgf/26Q=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ data:
hosts: ["kube-state-metrics:8080"]
period: 10s
add_metadata: true
# use_kubeadm: true
metricsets:
- state_node
- state_deployment
- state_daemonset
- state_replicaset
- state_pod
- state_container
- state_job
- state_cronjob
- state_resourcequota
- state_statefulset
Expand All @@ -45,14 +47,16 @@ data:
metricsets:
- apiserver
hosts: ["https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}"]
# use_kubeadm: true
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
ssl.certificate_authorities:
- /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
period: 30s
# Uncomment this to get k8s events:
#- module: kubernetes
# metricsets:
# - event
- module: kubernetes
metricsets:
- event
# use_kubeadm: true
# To enable hints based autodiscover uncomment this:
#- type: kubernetes
# node: ${NODE_NAME}
Expand Down Expand Up @@ -113,6 +117,7 @@ data:
- volume
period: 10s
host: ${NODE_NAME}
# use_kubeadm: true
hosts: ["https://${NODE_NAME}:10250"]
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
ssl.verification_mode: "none"
Expand All @@ -125,6 +130,7 @@ data:
metricsets:
- proxy
period: 10s
# use_kubeadm: true
host: ${NODE_NAME}
hosts: ["localhost:10249"]
---
Expand All @@ -151,12 +157,12 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: metricbeat
image: docker.elastic.co/beats/metricbeat:8.0.0-SNAPSHOT
image: docker.elastic.co/beats/metricbeat:8.16.0-SNAPSHOT
command: [ "sleep" ]
args: [ "infinity" ]
env:
- name: ELASTICSEARCH_HOST
value: elasticsearch.default.svc.cluster.local
value: elasticsearch
- name: ELASTICSEARCH_PORT
value: "9200"
- name: ELASTICSEARCH_USERNAME
Expand Down
2 changes: 2 additions & 0 deletions metricbeat/module/kubernetes/event/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

type kubeEventsConfig struct {
KubeConfig string `config:"kube_config"`
KubeAdm bool `config:"use_kubeadm"`
KubeClientOptions kubernetes.KubeClientOptions `config:"kube_client_options"`
Namespace string `config:"namespace"`
SyncPeriod time.Duration `config:"sync_period"`
Expand All @@ -40,6 +41,7 @@ type Enabled struct {
func defaultKubernetesEventsConfig() kubeEventsConfig {
return kubeEventsConfig{
SyncPeriod: 10 * time.Minute,
KubeAdm: true,
LabelsDedot: true,
AnnotationsDedot: true,
SkipOlder: true,
Expand Down
13 changes: 10 additions & 3 deletions metricbeat/module/kubernetes/util/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ import (

type kubernetesConfig struct {
KubeConfig string `config:"kube_config"`
KubeAdm bool `config:"use_kubeadm"`
KubeClientOptions kubernetes.KubeClientOptions `config:"kube_client_options"`

Node string `config:"node"`
SyncPeriod time.Duration `config:"sync_period"`
Node string `config:"node"`
SyncPeriod time.Duration `config:"sync_period"`

// AddMetadata enables enriching metricset events with metadata from the API server
AddMetadata bool `config:"add_metadata"`
Expand Down Expand Up @@ -592,6 +592,10 @@ func NewResourceMetadataEnricher(

var specificMetaGen metadata.MetaGen
var generalMetaGen *metadata.Resource
// We initialise the use_kubeadm variable based on modules KubeAdm base configuration
config.AddResourceMetadata.Namespace.SetBool("use_kubeadm", -1, commonMetaConfig.KubeAdm)
config.AddResourceMetadata.Node.SetBool("use_kubeadm", -1, commonMetaConfig.KubeAdm)

// Create the metadata generator to be used in the watcher's event handler.
// Both specificMetaGen and generalMetaGen implement Generate method for metadata collection.
if resourceName == ServiceResource || resourceName == PodResource {
Expand Down Expand Up @@ -755,6 +759,9 @@ func NewContainerMetadataEnricher(
log.Errorf("Error starting the watchers: %s", err)
return &nilEnricher{}
}
// We initialise the use_kubeadm variable based on modules KubeAdm base configuration
config.AddResourceMetadata.Namespace.SetBool("use_kubeadm", -1, commonMetaConfig.KubeAdm)
config.AddResourceMetadata.Node.SetBool("use_kubeadm", -1, commonMetaConfig.KubeAdm)

metaGen, err := createMetadataGenSpecific(client, commonConfig, config.AddResourceMetadata, PodResource, resourceWatchers)
if err != nil {
Expand Down

0 comments on commit 7176eec

Please sign in to comment.