-
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
Only watch metadata for ReplicaSets in metricbeat k8s module #41289
Only watch metadata for ReplicaSets in metricbeat k8s module #41289
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
394678c
to
993ef88
Compare
993ef88
to
7cd4d05
Compare
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
return map[string]mapstr.M{id: generalMetaGen.Generate(PersistentVolumeClaimResource, r)} | ||
case *kubernetes.StorageClass: | ||
return map[string]mapstr.M{id: generalMetaGen.Generate(StorageClassResource, r)} | ||
default: |
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.
Note: We can't have a branch for PartialObjectMetadata
here, because this may represent different resource types. So this falls into the default branch, and that does the right thing as long as TypeMeta is set. This is why our transform function adds the TypeMeta.
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.
Does not this fall under the case of kubernetes.replicaset rather than default?
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.
No, the actual struct we get here has type PartialObjectMetadata
.
|
||
updateFunc := getEventMetadataFunc(log, generalMetaGen, nil, nil) | ||
|
||
deleteFunc := func(r kubernetes.Resource) []string { |
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.
Why we need the deleteFunc here in the test?
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.
We are testing the delete trigger, so we need some function there. I copied the one we actually use in NewResourceMetadataEnricher
.
(cherry picked from commit 9e6a942)
(cherry picked from commit 9e6a942)
(cherry picked from commit 9e6a942)
(cherry picked from commit 9e6a942)
…#41323) (cherry picked from commit 9e6a942) Co-authored-by: Mikołaj Świątek <[email protected]>
…beat k8s module (#41321) * Only watch metadata for ReplicaSets in metricbeat k8s module (#41289) (cherry picked from commit 9e6a942) * Fix Changelog --------- Co-authored-by: Mikołaj Świątek <[email protected]>
…#41322) (cherry picked from commit 9e6a942) Co-authored-by: Mikołaj Świątek <[email protected]>
Proposed commit message
Use metadata watchers for ReplicaSets in the metricbeats Kubernetes module. This is a similar change to #41100, with two major differences:
TypeMeta
present. The informer doesn't set this, so we need to do it ourselves.A decent chunk of the changes is just passing around a metadata-only k8s client.
For more details see elastic/elastic-agent#5623.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
You need a full K8s cluster, unfortunately. I've tested it using the default elastic-agent standalone manifest, by building a custom container image and loading it into a local kind cluster.
Related issues