Skip to content
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

feat: Watch Namespaces based on labels and label selectors #10104

Merged
merged 27 commits into from
Oct 1, 2024

Conversation

davidjumani
Copy link
Contributor

Forward port of solo-io#10066

Description

The watchNamespaces setting allows users to restrict the namespaces in which Edge watches resources. Since this is a static list, users need to update it when they need to modify namespaces to watch
This feature aims to dynamically determine the list of namespaces to watch by defining labels on namespaces or filtering namespaces based on a label expression.

This feature identifies namespaces with label selectors. These can be :

  • Matching labels : All namespaces that contain a predefined list of labels will be added to the list of namespaces to watch. Eg.: All namespaces labelled with gloo-translate=enabled will be watched
  • Matching expressions : All namespaces that contain labels that match a given criteria will be watched. Eg.: All namespaces are labelled with environment in (prod, dev) will be watched

This will introduce a new setting to select namespaces :

apiVersion: gloo.solo.io/v1
kind: Settings
metadata:
  name: default
spec:
  watchNamespaceSelectors:
  - matchLabels:
      gloo-translate: enabled
  - matchExpressions:
    - key: env
      operator: In
      values:
        - prod
        - dev

API changes

  • Added the watchNamespaceSelectors to the settings CRC

Code changes

Added a KubeNamespaceWatcher to the setup snapshot emitter. This will trigger a new snapshot if any namespace has been created / deleted / modified and not necessarily if the namespace belongs to the list we watch. The syncer will determine whether to sync based on whether :

  • The settings CR has changed
  • The namespaces we watch has chagned

Context

Watch Namespaces based on labels and label selectors
Design doc

Interesting decisions

Testing steps

Added kubernetes e2e tests

Notes for reviewers

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@davidjumani davidjumani requested a review from a team as a code owner September 24, 2024 20:21
@github-actions github-actions bot added keep pr updated signals bulldozer to keep pr up to date with base branch work in progress signals bulldozer to keep pr open (don't auto-merge) labels Sep 24, 2024
@solo-changelog-bot
Copy link

Issues linked to changelog:
solo-io#9274

Copy link

github-actions bot commented Sep 24, 2024

Visit the preview URL for this PR (updated for commit 0473dd0):

https://gloo-edge--pr10104-watch-namespace-sele-l9osdenz.web.app

(expires Tue, 08 Oct 2024 14:52:59 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 77c2b86e287749579b7ff9cadb81e099042ef677

@davidjumani davidjumani removed the work in progress signals bulldozer to keep pr open (don't auto-merge) label Oct 1, 2024
@soloio-bulldozer soloio-bulldozer bot merged commit 4538565 into main Oct 1, 2024
19 checks passed
@soloio-bulldozer soloio-bulldozer bot deleted the watch-namespace-selectors-v2 branch October 1, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep pr updated signals bulldozer to keep pr up to date with base branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants