Skip to content

Conversation

@ssam18
Copy link

@ssam18 ssam18 commented Dec 18, 2025

Description

Add a new namespacesExclude configuration option for the Kubernetes provider that allows users to exclude specific namespaces from being watched.

This is useful when users want to watch all namespaces except specific system namespaces (e.g., kube-system, kube-public, kube-node-lease) without having to explicitly list all namespaces they want to include.

Example Configuration

providers:
  kubernetes:
    namespacesExclude:
      - kube-system
      - kube-public
      - kube-node-lease

Or via environment variable:

DIUN_PROVIDERS_KUBERNETES_NAMESPACESEXCLUDE=kube-system,kube-public,kube-node-lease

Changes

  • Add NamespacesExclude field to PrdKubernetes model
  • Add NamespacesExclude to k8s.Options and k8s.Client
  • Add IsNamespaceExcluded helper method to k8s.Client
  • Filter out excluded namespaces in PodList
  • Update Kubernetes provider to pass NamespacesExclude to k8s client
  • Add documentation for the new option

Behavior

  • If a namespace is in both namespaces (include) and namespacesExclude, it will be excluded
  • Works with the default "all namespaces" behavior - you can watch all namespaces except the ones you exclude
  • Comma-separated list supported for environment variable configuration

Fixes #1341

Add a new 'namespacesExclude' configuration option for the Kubernetes provider
that allows users to exclude specific namespaces from being watched.

This is useful when users want to watch all namespaces except specific system
namespaces (e.g., kube-system, kube-public, kube-node-lease) without having
to explicitly list all namespaces they want to include.
Copy link
Owner

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contrib!

I opened #1582 as I think we don't need a new opt for this case. We can just add support to negate namespaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kubernetes - Ignore namespaces

2 participants