You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update NPEP-133 with Admin-tier restriction, DNS security guidance, and v1alpha2 API
The PR updates the details around domainNames
as discussed in KubeCon Atlanta:
https://docs.google.com/document/d/1AtWQy2fNa4qXRag9cCp5_HsefD7bxKe3ea2RPn8jnSs/edit?tab=t.k47ujuef4zxk#bookmark=id.hl0pbdvwfotd
- Restrict domainNames to Admin tier only with CEL validation
(Baseline tier breaks the NetworkPolicy override model)
- Add CEL validation for Accept-only action restriction
- Update API examples to v1alpha2 ClusterNetworkPolicy format
- Add Expected Behavior points for DNS reachability and resolv.conf
- Add Recommended Behavior section covering DNS security concerns,
grace period, and DNSSEC best practice
- Add Connection Lifecycle section for policy add/remove semantics
* Support basic wildcard matching capabilities when specifying FQDNs (for
18
18
example `*.cloud-provider.io`)
19
-
* Currently only `ALLOW` type rules are proposed.
19
+
* Currently only `ACCEPT` type rules are proposed.
20
20
* Safely enforcing `DENY` rules based on FQDN selectors is difficult as there
21
21
is no guarantee a Network Policy plugin is aware of all IPs backing a FQDN
22
22
policy. If a Network Policy plugin has incomplete information, it may
23
23
accidentally allow traffic to an IP belonging to a denied domain. This would
24
24
constitute a security breach.
25
25
26
-
By contrast, `ALLOW` rules, which may also have an incomplete list of IPs,
26
+
By contrast, `ACCEPT` rules, which may also have an incomplete list of IPs,
27
27
would not create a security breach. In case of incomplete information, valid
28
28
traffic would be dropped as the plugin believes the destination IP does not
29
29
belong to the domain. While this is definitely undesirable, it is at least
30
30
not an unsafe failure.
31
31
32
-
* Currently only AdminNetworkPolicy is the intended scope for this proposal.
33
-
* Since Kubernetes NetworkPolicy does not have a FQDN selector, adding this
34
-
capability to BaselineAdminNetworkPolicy could result in writing baseline
35
-
rules that can't be replicated by an overriding NetworkPolicy. For example,
36
-
if BANP allows traffic to `example.io`, but the namespace admin installs a
37
-
Kubernetes Network Policy, the namespace admin has no way to replicate the
38
-
`example.io` selector using just Kubernetes Network Policies.
32
+
* DomainNames is restricted to the Admin tier of ClusterNetworkPolicy only.
33
+
* Since Kubernetes NetworkPolicy does not have a FQDN selector, using
34
+
domainNames in the Baseline tier would allow writing baseline rules that
35
+
can't be replicated by an overriding NetworkPolicy. For example, if a
36
+
Baseline-tier ClusterNetworkPolicy allows traffic to `example.io`, but
37
+
the namespace admin installs a Kubernetes NetworkPolicy, the namespace
38
+
admin has no way to replicate the `example.io` selector using just
39
+
Kubernetes NetworkPolicies. This breaks the fundamental tier override
40
+
model where NetworkPolicy can always override Baseline-tier rules.
39
41
40
42
## Non-Goals
41
43
42
44
* This enhancement does not include a FQDN selector for allowing ingress
43
45
traffic.
44
46
* This enhancement only describes enhancements to the existing L4 filtering as
45
-
provided by AdminNetworkPolicy. It does not propose any new L7 matching or
47
+
provided by ClusterNetworkPolicy. It does not propose any new L7 matching or
46
48
filtering capabilities, like matching HTTP traffic or URL paths.
47
49
* This selector should not control what DNS records are resolvable from a
48
50
particular workload.
@@ -92,15 +94,29 @@ goal in this case is to ensure we do not make these unimplementable down the
92
94
line.
93
95
94
96
* As a cluster admin, I want to switch the default disposition of the cluster to
95
-
be default deny. This is enforced using a `BaselineAdminNetworkPolicy`. I also
96
-
want individual namespace owners to be able to specify their egress peers.
97
-
Namespace admins would then use a FQDN selector in the Kubernetes
98
-
`NetworkPolicy` objects to allow `my-service.com`.
97
+
be default deny. This is enforced using a Baseline-tier
98
+
`ClusterNetworkPolicy`. I also want individual namespace owners to be able to
99
+
specify their egress peers. Namespace admins would then use a FQDN selector
100
+
in the Kubernetes `NetworkPolicy` objects to allow `my-service.com`.
99
101
100
102
## API
101
103
102
-
This NPEP proposes adding a new type of `AdminNetworkPolicyEgressPeer` called
103
-
`FQDNPeerSelector` which allows specifying domain names.
104
+
This NPEP proposes adding a `DomainNames` field to
105
+
`ClusterNetworkPolicyEgressPeer` which allows specifying domain names as
106
+
egress peers. DomainNames is only available with Accept rules in the Admin
107
+
tier of ClusterNetworkPolicy.
108
+
109
+
These restrictions are enforced via CEL validation on
110
+
`ClusterNetworkPolicySpec` (Baseline tier) and
111
+
`ClusterNetworkPolicyEgressRule` (Accept-only):
112
+
113
+
```go
114
+
// +kubebuilder:validation:XValidation:rule="self.tier == 'Baseline' ? !self.egress.exists(rule, rule.to.exists(peer, has(peer.domainNames))) : true",message="domainNames cannot be used in Baseline tier as NetworkPolicy cannot override FQDN rules"
115
+
typeClusterNetworkPolicySpecstruct { ... }
116
+
117
+
// +kubebuilder:validation:XValidation:rule="self.to.exists(peer, has(peer.domainNames)) ? self.action == 'Accept' : true",message="domainNames may only be used with Accept action"
118
+
typeClusterNetworkPolicyEgressRulestruct { ... }
119
+
```
104
120
105
121
```golang
106
122
@@ -126,22 +142,27 @@ This NPEP proposes adding a new type of `AdminNetworkPolicyEgressPeer` called
0 commit comments