Skip to content
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

[Kubernetes - Metricbeat] Providing config option to disable Kubeadm config api requests #40086

Merged
merged 29 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
56ca696
updating with config_kubeAdm
gizas Jul 1, 2024
61f848a
updating with config_kubeAdm and setbool option
gizas Jul 2, 2024
acac6ee
updating with events module
gizas Jul 3, 2024
bc3ff53
updating metricbeat.yaml manifest with disable_kubeadm config option
gizas Jul 3, 2024
60292a4
adding changelog line
gizas Jul 3, 2024
d817d1f
Merge branch 'main' of github.com:elastic/beats into kubeadm
gizas Jul 3, 2024
feef113
fixing host in metricbeat.yaml file
gizas Jul 3, 2024
ccb775f
changing variable to use_kubeadm
gizas Jul 19, 2024
499957e
Merge branch 'main' into kubeadm
gizas Jul 19, 2024
3f7fbea
udpating go.mod files
gizas Aug 13, 2024
50d82f7
udpating go.mod files
gizas Aug 13, 2024
09588b0
udpating go.mod files
gizas Aug 13, 2024
85a8695
udpating go.mod files
gizas Aug 13, 2024
3157196
udpating changelog file
gizas Aug 13, 2024
0649650
udpating NOTICE.txt
gizas Aug 13, 2024
e0c227d
udpating tests
gizas Aug 13, 2024
c5262da
Merge branch 'main' into kubeadm
gizas Aug 14, 2024
2fe631e
merging with main
gizas Aug 28, 2024
4583828
Merge branch 'kubeadm' of github.com:elastic/beats into kubeadm
gizas Aug 28, 2024
ffeabd2
removing kubeadm option and use only commonconfig
gizas Sep 2, 2024
64667fe
fixing typos
gizas Sep 2, 2024
5ef848a
fixing reference from central
gizas Sep 2, 2024
8bbe628
fixing newlines
gizas Sep 2, 2024
e3423ad
Merge branch 'main' of github.com:elastic/beats into kubeadm
gizas Sep 2, 2024
20936d6
fixing references to container registry as well
gizas Sep 3, 2024
e2fc92b
adding use_kubeadm in kubernetes config
gizas Sep 6, 2024
9b29bab
reverting change in kubernetes test
gizas Sep 6, 2024
f60ca44
Merge branch 'main' into kubeadm
gizas Sep 6, 2024
b461b38
Merge branch 'main' into kubeadm
gizas Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,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/[email protected].1/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].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 @@ -192,7 +192,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 @@

type kubernetesConfig struct {
KubeConfig string `config:"kube_config"`
KubeAdm bool `config:"use_kubeadm"`
gizas marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -590,8 +590,12 @@
return &nilEnricher{}
}

var specificMetaGen metadata.MetaGen

Check failure on line 593 in metricbeat/module/kubernetes/util/kubernetes.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

specificMetaGen declared and not used (typecheck)
var generalMetaGen *metadata.Resource

Check failure on line 594 in metricbeat/module/kubernetes/util/kubernetes.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

generalMetaGen declared and not used (typecheck)
// 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 @@
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
Loading