Skip to content

feat(apisix): provide opt-in APISIX network policy rules - #1044

Open
NiuBlibing wants to merge 2 commits into
apache:masterfrom
NiuBlibing:feature/network-policies
Open

NiuBlibing wants to merge 2 commits into
apache:masterfrom
NiuBlibing:feature/network-policies

Conversation

@NiuBlibing

@NiuBlibing NiuBlibing commented Nov 13, 2026 •

Copy link
Copy Markdown

Scope

Add an opt-in APISIX NetworkPolicy with independent ingress and egress switches. Each direction accepts complete Kubernetes NetworkPolicy rules, so custom TCP/UDP/metrics/stream/QUIC ports and actual DNS, API and upstream destinations can be expressed without unsafe fixed defaults.

The values and documentation live beside the APISIX settings to keep this topic isolated from the bundled etcd and ingress-controller policies, which are separate PRs (#1055 and #1056). The chart does not claim CNI runtime enforcement from rendering alone.

Validation

uv run --with PyYAML python test/render/network_apisix.py passed with UDP ports, namespace selectors, empty deny rules, duplicate-key checks and resource identity checks.

@NiuBlibing

Copy link
Copy Markdown
Author

Recommended merge order to reduce overlapping changes while keeping each PR single-topic:

#1039 → #1040 → #1041 → #1042 → #1043 → #1044 → #1045 → #1046 → #1047

The PRs are intentionally all based on master so their review diffs contain one topic. If upstream merges another overlapping change, only the affected topic branch needs a rebase.

@NiuBlibing

Copy link
Copy Markdown
Author

Updated recommended merge order after separating Admin API access policy from Ingress wiring:

#1039 → #1040 → #1041 → #1042 → #1043 → #1048 → #1044 → #1045 → #1046 → #1047

Each PR remains based on master and contains one topic. The sequence only reduces merge conflicts between templates and values; it is not a runtime dependency for every topic.

@membphis membphis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed at 0dfd2927d1ccebe46d1a46de9ee394ace817d6fa against baseline acd25584395d905511b68a20420bddf2bbd71a80.

[P1] Allow the controller's required egress before enabling isolation by default

With ingress-controller.enabled=true and a NetworkPolicy-enforcing CNI, networkpolicy-ingress-controller.yaml enables egress isolation but the default egress.to: [] leaves only the DNS rule. The controller can resolve names, but it cannot connect to the Kubernetes API server or APISIX Admin API, so reconciliation stops working.

Please either keep egress isolation opt-in or provide a working default that allows those required connections. This also needs a controller reconciliation test with policy enforcement; rendering alone cannot demonstrate connectivity. See the Kubernetes NetworkPolicy egress semantics.

[P1] Account for configured listener ports and protocols

The APISIX ingress policy is enabled by default and allows only a fixed list of TCP ports. It does not follow service.http.containerPort, additional HTTP/TLS listeners, PROXY protocol listeners, or the TCP/UDP ports configured under service.stream. For example, an existing UDP stream listener remains exposed by its Service but is denied by the new policy.

Please derive allowed ports and protocols from the enabled listeners, or make policy creation opt-in to preserve existing installations. Add coverage for a customized HTTP port, additional listeners, and both TCP and UDP stream traffic. The upgrade impact of enabling these policies by default should also be documented.

@NiuBlibing
NiuBlibing force-pushed the feature/network-policies branch from 0dfd292 to 08f6d35 Compare November 19, 2026 11:12
@NiuBlibing NiuBlibing changed the title feat(apisix): add component network policies feat(apisix): provide opt-in APISIX network policy rules Nov 19, 2026
@NiuBlibing

Copy link
Copy Markdown
Author

Updated at c3d9fda. This PR now owns only APISIX policy rules; bundled etcd and Controller policies are split into #1055/#1056. Fixed ports and DNS-only egress were removed; ingress and egress accept complete rules and default disabled.

This branch has not been deployed

No deployments
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