Skip to content

Commit 5bcb5b5

Browse files
committed
Initial FQDN Selector NPEP with User stories
1 parent bf98cec commit 5bcb5b5

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

npep/npep-133.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# NPEP-133: FQDN Selector for Egress Traffic
2+
3+
* Issue:
4+
[#133](https://github.com/kubernetes-sigs/network-policy-api/issues/133)
5+
* Status: Provisional
6+
7+
## TLDR
8+
9+
This enhancement proposes adding a new optional selector to specify egress peers
10+
using [Fully Qualified Domain Names](https://www.wikipedia.org/wiki/Fully_qualified_domain_name)
11+
(FQDNs).
12+
13+
## Goals
14+
15+
* Provide a selector to specify egress peers using a Fully Qualified Domain Name
16+
(for example `kubernetes.io`).
17+
* Support basic wildcard matching capabilities when specifying FQDNs (for example `*.cloud-provider.io`)
18+
* Currently only `ALLOW` type rules are proposed.
19+
* Correctly enforcing DENY rules based on FQDN selectors is difficult as there
20+
is no guarantee a Network Policy plugin is aware of all IPs backing a FQDN
21+
policy.
22+
* Currently only AdminNetworkPolicy is the intended scope for this proposal.
23+
* Since Kubernetes NetworkPolicy does not have a FQDN selector, adding this
24+
capability to BaselineAdminNetworkPolicy could result in writing baseline
25+
rules that can't be replicated by an overriding NetworkPolicy. For example,
26+
if BANP allows traffic to `example.io`, but the namespace admin installs a
27+
Kubernetes Network Policy, the namespace admin has no way to replicate the
28+
`example.io` selector using just Kubernetes Network Policies.
29+
30+
## Non-Goals
31+
32+
* This enhancement does not include a FQDN selector for allowing ingress
33+
traffic.
34+
* This enhancement does not include any L7 matching or filtering capabilities,
35+
like matching HTTP traffic or URL paths.
36+
* This selector should not control what DNS records are resolvable from a
37+
particular workload.
38+
* This enhancement does not provide a mechanism for selecting in-cluster
39+
endpoints using FQDNs. To select Pods, Nodes, or the API Server,
40+
AdminNetworkPolicy has other more specific selectors.
41+
* Using the FQDN selector to refer to other Kubernetes endpoints, while not
42+
explicitly disallowed, is not defined by this spec and left up to individual
43+
providers. Trying to allow traffic to the following domains is NOT
44+
guaranteed to work:
45+
* `my-svc.my-namespace.svc.cluster.local` (the generated DNS record for a
46+
Service)
47+
* `my-pod.my-namespace.svc.cluster.local` (the generated DNS record for a
48+
Pod)
49+
* This enhancement does not specify the details of how traffic is routed to the
50+
specified destination. For example, it does not prescribe details around NAT
51+
or egress gateways.
52+
* This enhancement does not require any mechanism for securing DNS resolution
53+
(e.g. DNSSEC or DNS-over-TLS). Unsecured DNS requests are expected to be
54+
sufficient for looking up FQDNs.
55+
56+
## Introduction
57+
58+
FQDN-based egress controls are a common enterprise security practice.
59+
Administrators often prefer to write security policies using DNS names such as
60+
“www.kubernetes.io” instead of capturing all the IP addresses the DNS name might
61+
resolve to. Keeping up with changing IP addresses is a maintenance burden, and
62+
hampers the readability of the network policies.
63+
64+
## User Stories
65+
66+
* As a cluster admin, I want to allow all Pods in the cluster to send traffic to
67+
an external service specified by a well-known domain name. For example, all
68+
Pods must be able to talk to `my-service.com`.
69+
70+
* As a cluster admin, I want to allow Pods in the "monitoring" namespace to be
71+
able to send traffic to a logs-sink, hosted at `logs-storage.com`
72+
73+
* As a cluster admin, I want to allow all Pods in the cluster to send traffic to
74+
any of the managed services provided by my Cloud Provider. Since the cloud
75+
provider has a well known parent domain, I want to allow Pods to send traffic
76+
to all sub-domains using a wild-card selector -- `*.my-cloud-provider.com`
77+
78+
### Future User Stories
79+
80+
These are some user stories we want to keep in mind, but due to limitations of
81+
the existing Network Policy API, cannot be implemented currently. The design
82+
goal in this case is to ensure we do not make these unimplementable down the line.
83+
84+
* As a cluster admin, I want to block all cluster egress traffic by default, and
85+
require namespace admins to create NetworkPolicies explicitly allowing egress
86+
to the domains they need to talk to.
87+
88+
The Cluster admin would use a `BaselineAdminNetworkPolicy` object to switch
89+
the default disposition of the cluster. Namespace admins would then use
90+
a FQDN selector in the Kubernetes `NetworkPolicy` objects to allow
91+
`my-service.com`.
92+
93+
## API
94+
95+
TODO
96+
97+
## Alternatives
98+
99+
### IP Block Selector
100+
101+
IP blocks are an important tool for specifying Network Policies. However, they
102+
do not address all user needs and have a few short-comings when compared to FQDN
103+
selectors:
104+
105+
* IP-based selectors can become verbose if a single logical service has numerous
106+
IPs backing it.
107+
* IP-based selectors pose an ongoing maintanance burden for administrators, who
108+
need to be aware of changing IPs.
109+
* IP-based selectors can result in policies that are difficult to read and
110+
audit.
111+
112+
### L7 Policy
113+
114+
Another alternative is to provide a true L7 selector, similar to the policies
115+
provided by Service Mesh providers. While L7 selectors can offer more
116+
expressibility, they often come trade-offs that are not suitable for all users:
117+
118+
* L7 selectors necessarily support a select set of protocols. Customers may be
119+
using a custom protocol for application-level communication, but still want
120+
the ability to specify endpoints using DNS.
121+
* L7 selectors often require proxies to perform deep packet inspection and
122+
enforce the policies. These proxies can introduce un-desireable latencies in
123+
the datapath of applications.
124+
125+
## References
126+
127+
* [NPEP #126](https://github.com/kubernetes-sigs/network-policy-api/issues/126):
128+
Egress Control in ANP
129+
130+
### Implementations
131+
132+
* [Antrea](https://antrea.io/docs/main/docs/antrea-network-policy/#fqdn-based-filtering)
133+
* [Calico](https://docs.tigera.io/calico-enterprise/latest/network-policy/domain-based-policy)
134+
* [Cilium](https://docs.cilium.io/en/latest/security/policy/language/#dns-based)
135+
* [Open Shift](https://docs.openshift.com/container-platform/latest/networking/openshift_sdn/configuring-egress-firewall.html)
136+
137+
The following is a best-effort breakdown of capabilities of different
138+
NetworkPolicy providers, as of 2023-09-25. This information may be out-of-date,
139+
or inaccurate.
140+
141+
| | Antrea | Calico | Cilium | OpenShift <br/> (current) | OpenShift <br/> (future) |
142+
| -------------- | ------------------------------ | ------------ | ------------ | ------------------------- | ------------------------ |
143+
| Implementation | DNS Snooping <br/> + Async DNS | DNS Snooping | DNS Snooping | Async DNS | DNS Snooping |
144+
| Wildcards || ️✔ ||||
145+
| Egress Rules || ️✔ ||||
146+
| Ingress Rules || ️❌ ||||
147+
| Allow Rules || ️✔ ||||
148+
| Deny Rules || ️❌(?) ||| ❌(?) |

0 commit comments

Comments
 (0)