kubescape / kubescape/operator
Regex for includeNamespaces / excludeNamespaces
- Dominant language
- Go
- Stars
- 24
- Forks
- 37
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
## Overview
Allow `includeNamespaces` / `excludeNamespaces` in the kubescape-operator
config to accept regex patterns in addition to exact namespace names.
## Problem
From a scalable standpoint, it would be nice to create a regex so that we can have dynamic namespaces.
## Solution
includeNamespaces: "kube-system" # unchanged, exact match
includeNamespacesRegex: "^team-.*-prod$" # new, RE2 regex
excludeNamespaces: [...]
excludeNamespacesRegex: [...]
A namespace is included if it matches any entry in either list; excluded likewise. Patterns use Go's `regexp` (RE2) and are compiled once at config load — invalid patterns fail fast with a clear error.
## Alternatives
**Flux GitOps workaround**: a CronJob with namespace list/get RBAC resolves the regex against live cluster state every N minutes and writes the matched names to a ConfigMap. The HelmRelease references it via `spec.valuesFrom`, so Flux re-renders the chart whenever the list changes.
## Additional context
- Related: kubescape/helm-charts#664 (dynamic reconfiguration without redeploy)
- Example would be how prometheus handles namespaces for alerts
Contributor guide
Research direction
Start at the operator's config-loading and namespace-selection paths, then trace how includeNamespaces and excludeNamespaces are parsed and applied. Add coverage for exact names, regex matches, include/exclude behavior, and invalid RE2 patterns; done means patterns are compiled during config load and invalid configuration fails with a clear error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100