Skip to content

feat: add watch-namespace flag to filter namespaces to watch for resources#175

Open
jdheyburn wants to merge 1 commit into
valkey-io:mainfrom
jdheyburn:feat/watch-namespace-flag
Open

feat: add watch-namespace flag to filter namespaces to watch for resources#175
jdheyburn wants to merge 1 commit into
valkey-io:mainfrom
jdheyburn:feat/watch-namespace-flag

Conversation

@jdheyburn
Copy link
Copy Markdown
Collaborator

@jdheyburn jdheyburn commented May 12, 2026

Closes #178

Summary

Adds a new flag --watch-namespace that will limit the resources watched by the managers. This will help to reduce memory usage in larger clusters. The flag can be specified multiple times to limit to multiple namespaces.

Features / Behaviour Changes

Lower memory use

Implementation

Limitations

Testing

Tested locally by building the image and deploying to local kind cluster.

- args:
  # ...
  - --watch-namespace=valkey-operator-system
  - --zap-log-level=4
2026-05-12T10:06:58Z    INFO    setup    Restricting cache to namespaces    {"namespaces": ["valkey-operator-system"[]}

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message explains what changed and why
  • Tests are added or updated.
  • Documentation files are updated.
  • I have run pre-commit locally (pre-commit run --all-files or hooks on commit)

…urces

Signed-off-by: Joseph Heyburn <jdheyburn@gmail.com>
@jdheyburn jdheyburn marked this pull request as ready for review May 12, 2026 12:56
Comment thread cmd/main.go
flag.BoolVar(&enableHTTP2, "enable-http2", false,
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
seenNamespaces := make(map[string]struct{})
flag.Func("watch-namespace", "Namespace to watch (repeatable; omit for cluster-wide)", func(s string) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how can users set this watch-namespace envvar from helm or operator env? i think we need to document that part

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've got a draft PR for the helm chart here: valkey-io/valkey-helm#172

Is that what you had in mind?

For env var, can any of these arguments today be set via env var? I hadn't had that in scope.

Copy link
Copy Markdown
Collaborator

@bjosv bjosv left a comment

Choose a reason for hiding this comment

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

Some operators seem to only, or also, use the env. variable WATCH_NAMESPACE, like dragonfly-opeator, cnpg, OT Redis operator and cockroach-operator.
It might be a convention from the Operator SDK, and some state that its simpler with env. than injecting extra args.
An env var would need to be comma separated.

Looking at the helm chart PR which uses your args; your solution seems cleaner.

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.

Filter namespaces for the operator to watch

3 participants