Skip to content

Implements option #3 (npep-187: More protocols support)#347

Merged
danwinship merged 4 commits into
kubernetes-sigs:mainfrom
bowei:pr-option-3
Feb 4, 2026
Merged

Implements option #3 (npep-187: More protocols support)#347
danwinship merged 4 commits into
kubernetes-sigs:mainfrom
bowei:pr-option-3

Conversation

@bowei
Copy link
Copy Markdown
Contributor

@bowei bowei commented Dec 18, 2025

Changes to implement option #3 for the port matching

Example (from #297)

apiVersion: policy.networking.k8s.io/v1alpha2
kind: ClusterNetworkPolicy
metadata:
  name: cluster-wide-deny
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
    - tcp:
        destinationPort:
          range:
            start: 8080
            end: 9090
    - udp:
        destinationPort:
          number: 8080
    - udp:
        destinationPort:
          number: 9090
    - namedPort: http
    - namedPort: monitoring
    - icmp: # that doesn't exist yet, but may be added
        type: 7
        code: 3

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 18, 2025

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

Name Link
🔨 Latest commit 78dea92
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-network-policy-api/deploys/6982f33b41b93800084af276
😎 Deploy Preview https://deploy-preview-347--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 added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 18, 2025
@bowei bowei force-pushed the pr-option-3 branch 3 times, most recently from c347f62 to fcfa3cd Compare December 18, 2025 17:58
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Copy link
Copy Markdown
Member

@npinaeva npinaeva left a comment

Choose a reason for hiding this comment

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

i think we are missing +optional or +required tags on most new fields?

@bowei
Copy link
Copy Markdown
Contributor Author

bowei commented Jan 22, 2026

i think we are missing +optional or +required tags on most new fields?

I think I fixed all of the instances -- please take a look.

Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Comment thread pkg/crdtest/testdata/valid/deny-with-ports.yaml
Comment thread pkg/crdtest/testdata/valid/deny-with-ports.yaml Outdated
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go
@bowei
Copy link
Copy Markdown
Contributor Author

bowei commented Jan 23, 2026

Updated to incorporate all code review feedback.

Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go
@bowei bowei force-pushed the pr-option-3 branch 2 times, most recently from ad0a4fc to f6466fe Compare January 28, 2026 16:29
Copy link
Copy Markdown
Contributor

@danwinship danwinship left a comment

Choose a reason for hiding this comment

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

One nitpick but I think this is good to go.

Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bowei, danwinship

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

The pull request process is described 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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 28, 2026
Comment thread apis/v1alpha2/clusternetworkpolicy_types.go Outdated
@danwinship
Copy link
Copy Markdown
Contributor

Conformance failure is expected at this point until we update kube-network-policies, right? Meaning, this is ready to merge?

@bowei
Copy link
Copy Markdown
Contributor Author

bowei commented Feb 4, 2026

Yes, I think so. I have the draft for fixing kube-network-policies as well, so hopefully we can get everything back green very soon.

@danwinship danwinship merged commit 2c8a1a8 into kubernetes-sigs:main Feb 4, 2026
7 of 10 checks passed
@bowei bowei deleted the pr-option-3 branch February 4, 2026 23:43
@tssurya tssurya mentioned this pull request Feb 5, 2026
@aojea
Copy link
Copy Markdown
Contributor

aojea commented Feb 14, 2026

Yes, I think so. I have the draft for fixing kube-network-policies as well, so hopefully we can get everything back green very soon.

@bowei @danwinship is this the reason why the github actions is failing on kube-network-policies? https://github.com/kubernetes-sigs/kube-network-policies/actions?query=e2e_npa

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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.

6 participants