Skip to content

Comments

Handling mutliple namespaces#41

Merged
mlguerrero12 merged 3 commits intok8snetworkplumbingwg:mainfrom
zeeke:us/multiple-namespaces
Jan 26, 2026
Merged

Handling mutliple namespaces#41
mlguerrero12 merged 3 commits intok8snetworkplumbingwg:mainfrom
zeeke:us/multiple-namespaces

Conversation

@zeeke
Copy link
Member

@zeeke zeeke commented Jan 14, 2026

A networkpolicy can refer to multiple NADs, which can be in different namespaces.

Avoid filtering peerPods using the exact networkname and use the policy's policy-for annotation.
Create an end2end test case that involves pods from multiple namespaces.

Improve the integration test verification method by introducing the golden file pattern, which also offers a better understanding of the nftables generated by the controller.

@gemini-code-assist
Copy link

Summary of Changes

Hello @zeeke, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the MultiNetworkPolicy functionality by enabling it to manage network policies across multiple Kubernetes namespaces and NetworkAttachmentDefinitions. The core change involves updating the policy enforcement mechanism to correctly identify and apply rules based on the policy-for annotation, ensuring accurate peer pod filtering. This improvement provides greater flexibility for defining complex network security policies in multi-tenant or distributed environments, validated by a new comprehensive end-to-end test.

Highlights

  • Multi-Namespace Network Policy Support: MultiNetworkPolicy now supports referencing NetworkAttachmentDefinitions (NADs) that reside in different namespaces, enhancing cross-namespace network policy capabilities.
  • Refined Peer Pod Filtering: The logic for filtering peer pods has been updated to utilize the policy-for annotation within the MultiNetworkPolicy, allowing for more precise and flexible network selection across namespaces.
  • New End-to-End Test Case: A new end-to-end test case has been added to validate the correct enforcement of MultiNetworkPolicy across multiple namespaces and distinct network configurations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly refactors the logic to handle multiple namespaces for network policies by leveraging the policy-for annotation. The addition of a new end-to-end test for multi-namespace scenarios is a great improvement. My review focuses on improving the reliability of the new test and fixing a minor typo in the Go code.

@zeeke zeeke force-pushed the us/multiple-namespaces branch 2 times, most recently from 448c8d7 to d181138 Compare January 16, 2026 15:01
Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
@zeeke zeeke force-pushed the us/multiple-namespaces branch 3 times, most recently from 2d6162b to 13c3546 Compare January 19, 2026 12:48
@zeeke zeeke force-pushed the us/multiple-namespaces branch from 13c3546 to 7a54c80 Compare January 20, 2026 08:42
Copy link
Collaborator

@mlguerrero12 mlguerrero12 left a comment

Choose a reason for hiding this comment

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

Nice work @zeeke! Just some minor comments

zeeke added 2 commits January 26, 2026 14:22
A networkpolicy can refer to multiple NADs, which can be in different namespaces.

Avoid filtering peerPods using the exact networkname and use the policy's `policy-for` annotation.
Create an end2end test case that involves pods from multiple namespaces.

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
@zeeke zeeke force-pushed the us/multiple-namespaces branch from 7a54c80 to 4c73a85 Compare January 26, 2026 13:23
@zeeke
Copy link
Member Author

zeeke commented Jan 26, 2026

Thanks @mlguerrero12 for the review! I addressed your comments

(Hope everything is going well in your new adventure! 😃)

@mlguerrero12 mlguerrero12 merged commit e5d27b4 into k8snetworkplumbingwg:main Jan 26, 2026
6 checks passed
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.

2 participants