On 07/13/2017 02:33 PM, cmluciano wrote:
> I wanted to resurrect the requirements discussion around egress policy
> requirements. We have this listed for beta support in 1.8 and I want to
> finalize the use-cases before I submit an updated proposal.
>
> Thelatest document
> <
https://docs.google.com/document/d/1-Cq_Y-yuyNklvdnaZF9Qngl3xe0NnArT7Xt_Wno9beg/edit>
> summarizes many use-cases for egress filtering that seem to boil down to
> the following:
>
> 1. I want my pod to not be able to talk to something in the outside
> world".
> 1. A user submitting a CIDR that will be allowed/blocked explicitly
> 1. There was some discussion about implications of using the
> CIDR in relation to the IPv6 roadmap as well
> 2. In prior proposals there was also the possibility of locking down
> certain ports between pod-pod communication.
>
> Do we have any general agreement on which things egress rules should
> handle?
FWIW, OpenShift has either implementations of, or customer requests for,
every use case in that document.
For purposes of this discussion, those use cases can probably be divided
into three groups:
- The "Self-censorship" and "Mandatory self-censorship" use cases
fit very cleanly into the NetworkPolicy model; the project admin
creates NetworkPolicies indicating what their pods are allowed
to access, and the network plugin implements those policies.
This is also more-or-less what is proposed by Dan Williams's
recently-closed-due-to-inactivity PR
(
https://github.com/kubernetes/kubernetes/pull/26720) (although
that includes some complications with CIDR-based rules that
aren't needed for these use cases).
(The doc doesn't explicitly mention "locking down certain ports
between pod-pod communication", but the proposal in #26720 does
implement that; if we're implementing the feature as an extension
of NetworkPolicy, it's pretty obvious that being able to specify
specific ports would be part of it.)
- The two "firewall" use cases imply a permissions system with
separate "cluster admins" and "project admins" which didn't match
Kubernetes's permissions model in the past (although I think parts
of OpenShift's auth/permissions system have now started being
absorbed into Kubernetes proper?). Because of the "cluster admin
overrides project admin"-ness, it also doesn't fit as cleanly into
NetworkPolicy, as NetworkPolicy is currently defined. The PR above
tried to figure out some way to handle this, and I think there was
general agreement that it failed.
Also, FWIW, while we have implemented this feature in OpenShift, it
has turned out to be less popular than expected, because even though
people want this functionality, they don't want it *in OpenShift*;
they want to use their existing firewall, but have it be able to
accept/reject traffic based on what kubernetes Namespace the
traffic comes from. So that leads to...
- The "recognizable source IP" use case. This is vastly different in
terms of kubernetes functionality than the other two, although it
ends up being used primarily for restricting outgoing traffic, so
it's similar in intent. We originally had implemented this as a
sort of one-off thing, but now there are users who basically want to
completely throw away the normal pod-to-external traffic flow
(via NAT to the node IP) and have all pod-to-external traffic end up
with an IP that reflects its source namespace, so they can then
set up external firewall rules. We're still figuring out the best
approach here.
Anyway, for Kubernetes 1.8, I think it would make sense for us to tackle
the "self-censorship" cases, by adding stuff to NetworkPolicy along the
lines of #26720, but with simpler CIDR handling (and with updates to
reflect the v1 changes to NetworkPolicy). We may want to discuss the
other use cases but I'm not sure we want to try to tackle them for 1.8.
And also, if we're implementing CIDR-based egress rules, we should at
least talk about CIDR-based ingress rules as well (although that gets
more complicated because you need to coordinate with whatever sort of
load balancer/ingress mechanism is originally accepting the packet).
-- Dan