Skip to content

Commit eaf7f9a

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

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea/
2+
.vscode/
23
vendor/
34
site/

npep/npep-133.md

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

0 commit comments

Comments
 (0)