Skip to content

[receiver/k8sobjectsreceiver]: support exclude_namespaces to exclude namespace from being watched#41440

Merged
ChrsMark merged 22 commits into
open-telemetry:mainfrom
KyriosGN0:deny-ns
Jan 21, 2026
Merged

[receiver/k8sobjectsreceiver]: support exclude_namespaces to exclude namespace from being watched#41440
ChrsMark merged 22 commits into
open-telemetry:mainfrom
KyriosGN0:deny-ns

Conversation

@KyriosGN0
Copy link
Copy Markdown
Contributor

@KyriosGN0 KyriosGN0 commented Jul 19, 2025

Description

This PR introduces a new parameter to the receiver config, called ignore_namespaces its array of string that specify which namespaces should be excluded from being watched at all (can be a regex expression)
the option in my opinion should not be used together with the Namespaces option, as one is allowlist and the other is denylist

Link to tracking issue

Fixes #36217

Testing

ran a kind cluster, deployed otel collector configured with this receiver and a debug exporter, created pods in a namespace that is in the deny list and saw that they are not being pulled/watched and that pods in other namespaces are pulled/watched

@KyriosGN0 KyriosGN0 marked this pull request as ready for review July 19, 2025 15:52
@KyriosGN0 KyriosGN0 requested review from a team, ChrsMark, TylerHelmuth and dmitryax as code owners July 19, 2025 15:52
@github-actions github-actions Bot requested a review from hvaghani221 July 19, 2025 15:52
@atoulme
Copy link
Copy Markdown
Contributor

atoulme commented Jul 19, 2025

Please add a changelog and check the CI

@KyriosGN0
Copy link
Copy Markdown
Contributor Author

@atoulme Thanks, added the required file for changelog

@ChristianCiach
Copy link
Copy Markdown
Contributor

ChristianCiach commented Jul 20, 2025

I am not a maintainer or anything, so my opinion carries little weight. But I think the name {{something}}_deny_list is really strange and sticks out like a sore thumb. It's like naming a namespace field namespace_string. I think ignore_namespaces would be a lot more idiomatic.

Edit: Other components, like the filelog receiver, seem to use the include/exclude naming pattern. So how about exclude_namespaces?

@dmitryax
Copy link
Copy Markdown
Member

I agree with @ChristianCiach.

Please also use https://github.com/open-telemetry/opentelemetry-collector/blob/main/filter/config.go. So the user config could be

exclude_namespaces:
  - regexp: kube-*

@atoulme atoulme marked this pull request as draft July 22, 2025 15:07
@atoulme
Copy link
Copy Markdown
Contributor

atoulme commented Jul 22, 2025

Moving to draft while you address the feedback - please mark ready to review once done.

@KyriosGN0 KyriosGN0 marked this pull request as ready for review August 1, 2025 13:12
@KyriosGN0
Copy link
Copy Markdown
Contributor Author

hey @dmitryax, i have addressed you comments, thanks!

@KyriosGN0 KyriosGN0 changed the title [receiver/k8sobjectsreceiver]: support namespace_deny_list to exclude namespace from being watched [receiver/k8sobjectsreceiver]: support ignore_namespaces to exclude namespace from being watched Aug 1, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added the Stale label Aug 16, 2025
@KyriosGN0
Copy link
Copy Markdown
Contributor Author

Not stale
Waiting for review

@github-actions github-actions Bot removed the Stale label Aug 17, 2025
Comment thread .chloggen/deny-ns.yaml Outdated
Comment thread receiver/k8sobjectsreceiver/config.go Outdated
Comment thread receiver/k8sobjectsreceiver/receiver.go
@KyriosGN0 KyriosGN0 changed the title [receiver/k8sobjectsreceiver]: support ignore_namespaces to exclude namespace from being watched [receiver/k8sobjectsreceiver]: support exclude_namespaces to exclude namespace from being watched Sep 7, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added the Stale label Sep 22, 2025
@KyriosGN0
Copy link
Copy Markdown
Contributor Author

not stale, i will rebase in the next 2 days probably

KyriosGN0 and others added 19 commits January 20, 2026 18:16
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
…_namespaces

Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
…type

Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Co-authored-by: Christos Markou <chrismarkou92@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
ChrsMark and others added 2 commits January 21, 2026 10:17
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
@KyriosGN0
Copy link
Copy Markdown
Contributor Author

/rerun

@ChrsMark ChrsMark merged commit ac830be into open-telemetry:main Jan 21, 2026
191 checks passed
@otelbot
Copy link
Copy Markdown
Contributor

otelbot Bot commented Jan 21, 2026

Thank you for your contribution @KyriosGN0! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help.

@odubajDT
Copy link
Copy Markdown
Contributor

Hey, there is an ongoing refactoring of this component and some of the functionality was moved to internal/k8sinventory with this PR. Would you @KyriosGN0 b interested in adapting the internal library as well and afterwards using the adapted internal code in the k8sobjectsreceiver?

There is an already PR with adapted code using the k8sinventory lib (without your changes) here. I would gladly step back from the PR in case you would be interested in bringing it to the line.

Thanks!

@KyriosGN0
Copy link
Copy Markdown
Contributor Author

here

hey @odubajDT this sounds really interesting, but i don't have the bandwith for that right now

@KyriosGN0 KyriosGN0 deleted the deny-ns branch May 7, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[receiver/k8sobjects] allow options to exclude namespace

7 participants