Skip to content

Conversation

@bowei
Copy link
Contributor

@bowei bowei commented Nov 7, 2025

Example:

apiVersion: policy.networking.k8s.io/v1alpha2
kind: ClusterNetworkPolicy
metadata:
  name: port1
spec:
  tier: Admin
  priority: 0
  subject:
    namespaces:
      matchLabels:
        kubernetes.io/metadata.name: sensitive-ns
  ingress:
    - action: Deny
      name: select-all-deny-all
      from:
      - pods:
          namespaceSelector:
            matchLabels: {}
          podSelector:
            matchLabels: {}
      protocols:
        tcp:
          - destinationPort:
              number: 8080
              # flags: [syn] # future extension example
          - destinationPort:
              range:
                start: 8080
                end: 9090
        udp:
          - destinationPort:
              number: 8080
          - destinationPort:
              number: 9090
        destinationNamedPort:
          - name: http
          - name: monitoring

@netlify
Copy link

netlify bot commented Nov 7, 2025

Deploy Preview for kubernetes-sigs-network-policy-api ready!

Name Link
🔨 Latest commit f5ea69a
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-network-policy-api/deploys/69240479ffba1a0008efe9eb
😎 Deploy Preview https://deploy-preview-342--kubernetes-sigs-network-policy-api.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot requested a review from aojea November 7, 2025 23:10
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 7, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bowei
Once this PR has been reviewed and has the lgtm label, please assign aojea for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested a review from npinaeva November 7, 2025 23:10
@bowei bowei marked this pull request as draft November 7, 2025 23:10
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 7, 2025
@bowei
Copy link
Contributor Author

bowei commented Nov 13, 2025

I am going to update this to match the NPEP.

kubernetes-sigs#297

protocols:
  tcp:
    - destinationPort:
        number: 8080
    - destinationPort:
        range:
          start: 8080
          end: 9090
  udp:
    - destinationPort:
        number: 8080
    - destinationPort:
        number: 9090
  destinationNamedPort:
    - name: http
    - name: monitoring
@bowei bowei marked this pull request as ready for review November 24, 2025 07:09
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 24, 2025
@bowei
Copy link
Contributor Author

bowei commented Nov 24, 2025

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 24, 2025
@k8s-ci-robot
Copy link
Contributor

@bowei: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-network-policy-api-crd-e2e f5ea69a link true /test pull-network-policy-api-crd-e2e
pull-network-policy-api-verify f5ea69a link true /test pull-network-policy-api-verify

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions 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. I understand the commands that are listed here.

@danwinship
Copy link
Contributor

      protocols:
        tcp:
          - destinationPort:
              number: 8080
              # flags: [syn] # future extension example
          - destinationPort:
              range:
                start: 8080
                end: 9090
        udp:
          - destinationPort:
              number: 8080
          - destinationPort:
              number: 9090

We noticed in the last meeting that this is kind of weird: the protocols struct fields have "OR" semantics, whereas in almost all other cases, struct fields have "AND" semantics.

It seems like it would be better to have protocols contain an array, and have "exactly one of" semantics for the elements of the array. This is probably equivalent to one of the earlier proposals which we rejected for some other reason?

@bowei
Copy link
Contributor Author

bowei commented Dec 2, 2025

Agreed that OR'ing across nested lists in structs is not most straightforward:

Specifically:

protocols:
  proto1:
    - <match1>
    - <match2>
  proto2:
    - <match1>
    - <match2>

Will be <proto1, match1> OR <proto1, match2> OR <proto2, match1> OR <proto2, match2>...

Whereas just saying "OR across this list of items":

protocols:
- proto1:
    <match1>
- proto1:
    <match2>
- proto2:
  ...

seems more understandable. (This option was covered in the big thread on Nadia's NPEP...)

// Subject field.
type BaselineAdminNetworkPolicyIngressRule struct {
// Name is an identifier for this rule, that may be no more than 100 characters
// Name is an identifier for this rule, that may be no more than 100 charactersp
Copy link
Contributor

Choose a reason for hiding this comment

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

typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch

// DestinationNamedPort selects a destination port on a pod based on the Container.Port
// name.
//
// This cannot be used this in a rule with Nodes or Networks peers, as they
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for this to be validated via CEL, or are implementations expected to validate this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will add CEL.

@bowei
Copy link
Contributor Author

bowei commented Dec 18, 2025

/close

shifting to option 3:

#347

@k8s-ci-robot
Copy link
Contributor

@bowei: Closed this PR.

Details

In response to this:

/close

shifting to option 3:

#347

Instructions 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants