diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index c856b639743..fe34954c43b 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -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] diff --git a/NOTICE.txt b/NOTICE.txt index 1144db8a260..b0a0438eb29 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -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 diff --git a/go.mod b/go.mod index 5081c345039..56318068f27 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 838744dab13..df15b7c4791 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/metricbeat/module/kubernetes/_meta/test/docs/01_playground/metricbeat.yaml b/metricbeat/module/kubernetes/_meta/test/docs/01_playground/metricbeat.yaml index b65ea0734c9..bfc3121800f 100644 --- a/metricbeat/module/kubernetes/_meta/test/docs/01_playground/metricbeat.yaml +++ b/metricbeat/module/kubernetes/_meta/test/docs/01_playground/metricbeat.yaml @@ -26,6 +26,7 @@ data: hosts: ["kube-state-metrics:8080"] period: 10s add_metadata: true + # use_kubeadm: true metricsets: - state_node - state_deployment @@ -33,6 +34,7 @@ data: - state_replicaset - state_pod - state_container + - state_job - state_cronjob - state_resourcequota - state_statefulset @@ -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} @@ -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" @@ -125,6 +130,7 @@ data: metricsets: - proxy period: 10s + # use_kubeadm: true host: ${NODE_NAME} hosts: ["localhost:10249"] --- @@ -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 diff --git a/metricbeat/module/kubernetes/event/config.go b/metricbeat/module/kubernetes/event/config.go index cc62c3395c7..a5dbc07aeea 100644 --- a/metricbeat/module/kubernetes/event/config.go +++ b/metricbeat/module/kubernetes/event/config.go @@ -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"` @@ -40,6 +41,7 @@ type Enabled struct { func defaultKubernetesEventsConfig() kubeEventsConfig { return kubeEventsConfig{ SyncPeriod: 10 * time.Minute, + KubeAdm: true, LabelsDedot: true, AnnotationsDedot: true, SkipOlder: true, diff --git a/metricbeat/module/kubernetes/util/kubernetes.go b/metricbeat/module/kubernetes/util/kubernetes.go index f94d424ec0e..6de1e661140 100644 --- a/metricbeat/module/kubernetes/util/kubernetes.go +++ b/metricbeat/module/kubernetes/util/kubernetes.go @@ -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"` @@ -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 { @@ -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 {