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 CEL
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 `Accept` type rules are proposed.
20
-
* Safely enforcing `Deny` rules based on FQDN selectors is difficult as there
19
+
* Currently only `ACCEPT` type rules are proposed.
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, `Accept` 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 Admin tier of ClusterNetworkPolicy is the intended scope for this
33
-
proposal.
34
-
* Since Kubernetes NetworkPolicy does not have a FQDN selector, adding this
35
-
capability to Baseline tier could result in writing baseline rules that can't
36
-
be replicated by an overriding NetworkPolicy. For example, if Baseline tier
37
-
allows traffic to `example.io`, but the namespace admin installs a Kubernetes
38
-
Network Policy, the namespace admin has no way to replicate the `example.io`
39
-
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.
40
41
41
42
## Non-Goals
42
43
@@ -93,15 +94,29 @@ goal in this case is to ensure we do not make these unimplementable down the
93
94
line.
94
95
95
96
* As a cluster admin, I want to switch the default disposition of the cluster to
96
-
be default deny. This is enforced using a `Baseline`tier in ClusterNetworkPolicy`.
97
-
I also want individual namespace owners to be able to specify their egress peers.
98
-
Namespace admins would then use a FQDN selector in the Kubernetes
99
-
`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`.
100
101
101
102
## API
102
103
103
-
This NPEP proposes adding a new type of `ClusterNetworkPolicyEgressPeer` called
104
-
`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.action != 'Accept' ? !self.to.exists(peer, has(peer.domainNames)) : true",message="domainNames may only be used with Accept action"
118
+
typeClusterNetworkPolicyEgressRulestruct { ... }
119
+
```
105
120
106
121
```golang
107
122
@@ -130,19 +145,24 @@ type DomainName string
130
145
typeClusterNetworkPolicyEgressPeerstruct {
131
146
<snipped>
132
147
// DomainNames provides a way to specify domain names as peers.
133
-
//
134
-
// DomainNames is only supported for Allow rules. In order to control
135
-
// access, DomainNames Allow rules should be used with a lower priority
136
-
// egress deny -- this allows the admin to maintain an explicit "allowlist"
137
-
// of reachable domains.
148
+
//
149
+
// DomainNames is only supported for Accept rules in the Admin tier.
150
+
// In order to control access, DomainNames Accept rules should be used
151
+
// with a lower precedence egress deny -- this allows the admin to
152
+
// maintain an explicit "allowlist" of reachable domains.
153
+
//
154
+
// DomainNames cannot be used in the Baseline tier because Kubernetes
155
+
// NetworkPolicy has no FQDN selector, so a Baseline FQDN rule cannot
0 commit comments