Repository navigation
Conversation
✅ Deploy Preview for kubernetes-sigs-network-policy-api ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hi @vpbh. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The manifests and probes consistently validate positive and negative pod-selection behavior across both tiers.
Review effort: Balanced
Findings: None
What changed in this PR
Adds conformance coverage ensuring CNP pod selectors are enforced independently of namespace selection.
Changes:
- Adds Admin and Baseline tier pod-selector tests.
- Adds manifests covering pod-label and pod-name selection for subjects and peers.
| File | Description |
|---|---|
conformance/tests/baseline-admin-network-policy-standard-pod-selector-rules.go |
Tests Baseline tier selectors. |
conformance/tests/admin-network-policy-standard-pod-selector-rules.go |
Tests Admin tier selectors. |
conformance/base/baseline_tier/standard-pod-selector-rules.yaml |
Defines Baseline test policies. |
conformance/base/admin_tier/standard-pod-selector-rules.yaml |
Defines Admin test policies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@netlify retry |
|
/ok-to-test |
|
@vpbh probably easiest to rebase on master since the netlify fixes landed (to retrigger the website lanes) |
Every podSelector in the suite matches on conformance-house, which every pod in a namespace carries, so pod selection was never exercised beyond namespace granularity: an implementation that ignored podSelector would pass the suite. Add CNPAdminTierPodSelector and CNPBaselineTierPodSelector, each driven by one manifest with two policies. The first selects its subject by pod label alone, with namespaceSelector omitted so that an ignored podSelector would widen the subject to every pod in the cluster, and denies traffic to and from peers selected both by pod label alone and by pod name within a namespace. The second uses a single-pod subject. Probes assert that the selected pods are enforced while same-namespace siblings and non-subject pods are not. Signed-off-by: Vinay Pai <vinaypaibh@gmail.com>
11ab4fb to
c159ab2
Compare
tssurya
left a comment
There was a problem hiding this comment.
overall LGTM, some comments
| priority: 20 | ||
| subject: | ||
| # namespaceSelector is omitted on purpose: the subject is selected by pod label alone, across all | ||
| # namespaces. An implementation that ignored podSelector would apply this policy to every pod. |
There was a problem hiding this comment.
| # namespaces. An implementation that ignored podSelector would apply this policy to every pod. | |
| # namespaces. |
This second comment is confusing, - would apply this to every pod in full cluster? or maybe to the namespaces they selected etc right? its subjective to what setting the implementation did, - maybe we can skip that sentence
|
|
||
| // egress rule at index 1 (deny-to-cedric-diggory-0) selects a single pod by name within hufflepuff -> DENIED | ||
| serverPod = kubernetes.GetPod(t, s.Client, "network-policy-conformance-hufflepuff", "cedric-diggory-0", s.TimeoutConfig.GetTimeout) | ||
| kubernetes.PokeServer(t, s.ClientSet, &s.KubeConfig, "network-policy-conformance-gryffindor", "harry-potter-0", "tcp", |
There was a problem hiding this comment.
nit: maybe use harry-potter-1 here to ensure both pods were selected by pod selector in subject
| serverPod.Status.PodIP, int32(80), s.TimeoutConfig, true) | ||
| }) | ||
| }, | ||
| } |
There was a problem hiding this comment.
these are good tests - but would be also better to have "Allow" action and "Pass" action tested with pod selector than just "Deny" rules in both ingress and egress to mix it up - same for add a protocol/port range variation perhaps - i.e one rule can stay plain L3, but other rules can be L4 matches - otherwise we don't want to add too many duplicate tests again for those specially
If you want to do them in add-on PRs as FUP that's fine.
| ) | ||
| } | ||
|
|
||
| var CNPBaselineTierPodSelector = suite.ConformanceTest{ |
There was a problem hiding this comment.
I think these tests are a good first start
I see baseline more interesting in combo with Network Policy - we dont need to do those here, but we need to maybe do a tracker to edit/tweak https://github.com/kubernetes-sigs/network-policy-api/blob/main/conformance/tests/admin-network-policy-standard-integration.go to include a podselector test in combo with NetworkPolicy - as a TODO for future
| serverPod.Status.PodIP, int32(80), s.TimeoutConfig, true) | ||
| }) | ||
| }, | ||
| } |
There was a problem hiding this comment.
Is it that the PR is fixing #104 (comment) ?
What about #111 ? - since its easy to swap/change labels I don't mind if we just get it done in one go - like it should be super easy to include the label changes here itself - I think the start/stop matching , lets cover those too in one go - then easier for you for reviews as well (if we finish both in one go)
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: vpbh The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Every
podSelectorin the suite matches on conformance-house, which every pod in a namespace carries, so pod selection was never exercised beyond namespace granularity: any implementation that ignoredpodSelectorwould pass the suite.Add
CNPAdminTierPodSelectorandCNPBaselineTierPodSelector, each driven by one manifest with two policies:namespaceSelectoromitted so that an ignoredpodSelectorwould widen the subject to every pod in the cluster, and denies traffic to and from peers selected both by pod label alone and by pod name within a namespace.