-
Notifications
You must be signed in to change notification settings - Fork 674
Support k8s egress policies #2624
Comments
Having egress policies would be very beneficial to my organisation. We are trying to restrict access from pods to an ExternalName Services (e.g. an AWS RDS instance) as noted in this StackOverflow post. Is there any ballpark timescale for when this might be implemented? It does seem as if the discussion regarding egress policies has stalled, and the proposal document has not been updated in a while. Project Calico provides egress policy via their own policy extensions. Could Weave to do anything similar? For reference, this is the post on the K8S slack community that lead me to this issue. |
@iblocks-shaun Thanks for the info. We will take into consideration the egress policies during the next release planning which should happen during the second half of March. |
@brb : Any update on this issue/feature? We are also interested in specifying egress policies and restricting access from pods to ExternalName Services like AWS RDS being a big need right now for us. |
@Cryptophobia Sorry, but the issue hasn't been prioritized yet. However, contributions are more than welcome. |
@brb Can anyone point me to what sections of the code need to be updated for this to be added as a feature? |
The current Network Policy Controller is under https://github.com/weaveworks/weave/tree/master/npc, with main program at https://github.com/weaveworks/weave/tree/master/prog/weave-npc Note that there's no way in Kubernetes to define an egress policy, so that would need to be stored in an annotation or something else free-form until the official version is agreed and included. |
Also, it's worth mentioning the design doc https://github.com/weaveworks/weave/blob/master/docs/weavenpc-design.md |
Since 1.8 release, it seems the K8s documentation has egress examples: kubernetes/enhancements#366 ... so I'm just posting this here, in case that's news to some, to indicate that K8s is eventually moving toward the egress support (which seems to be limited to design principles for now?). |
Thanks @RRAlex, the api definitions for egress policies were added as beta in Kubernetes 1.8; see kubernetes/enhancements#367 This remains on the todo list for Weave Net. |
We are very interested in this. Would love to see this done soon! 👍 |
Any status on this? No support for egress policies is a blocker for us :/ |
or could we start from point: is this currently possible implement to weave, if yes how(like theory behind the solution)? Because at least I could implement something but I do not have any idea where to start because I have not implemented anything to weave. |
Good question @zetaab |
@zetaab Yes, it's possible to implement it. You would need to extend weave-npc (src, design doc) to make it manage appropriate iptables rules of the filter table and ipsets. I could guide you with implementation after you have familiarized yourself with the existing design and concepts of weave-npc. Also, AFAIK, @bjhaid has been working on this feature. Perhaps you could synchronize with @bjhaid first. |
Can we give this feature some priority? I can try to take a look as well if help is needed. NetworkPolicies are a feature that everyone wants and K8s is moving that way. Flannel supports them by integrating with Canal. Not sure if using Canal is possible with Weave since weave uses weave-npc. Calico supports them: https://docs.projectcalico.org/v2.0/getting-started/kubernetes/tutorials/advanced-policy |
I think quite many enterprise companies wants egress networkpolicies as well. The common problem in kubernetes is that if you want connect to databases outside kubernetes - you need to open whole cluster towards databases. If we have lets say team1 and team2 using same cluster, we do not want that team2 cannot even connect to team1 database. Egress networkpolicies could help here, and thats why I want these. |
@bjhaid I guess there is some misunderstanding, as I've been working on the ingress policy and unfortunately I've never intended to work on the egress part (I'm Martynas, btw;-). |
We also need egress badly. The lack of this in weave will force us to move to calico (or cilium, but that still seems a bit young) in a about a month or so, we don't have time to extend weave ourselves. So to confirm, at this moment nobody is working on this and there is no priority from weaveworks or other devs? |
@mrdima We're considering to add this to the next milestone. I will update once a decision has been made. |
@brb did you get to a decision on this in the end? We are considering moving off Weave to another network provider in order to get egress support but I'd rather not have to go through the pain of re-provisioning clusters if it is just around the corner. |
I'm going to work on this (no ETA at the moment, sorry). To everyone who raised an interest in the feature: what is your use case? Do you want to filter off-cluster traffic (e.g. deny the internet, but allow github.com) or in-cluster traffic (e.g. allow only podA -> podB)? If the latter, do you plan to use ipBlock (CIDR) selector or pod/namespace label selectors? |
My primary interest is having other things running in AWS in different VPCs and being able to only allow egress to a specific CIDR outside of the cluster in a 10.x.x.x network. For pod->pod traffic I would tend to use ingress to block who can talk to a pod instead of using egress to block pod to pod. I will echo @carpenterm statement that I may need to move off weave in the next month to gain egress network policies. |
@brb In our use case we would like to be able to filter in-cluster traffic (podA -> podB). Ideally we would want to be able to do it with pod/namespace label selectors as that would be easiest. Lets say we have third-party applications on our cluster. We would like for them not to be able to discover other apps running inside the cluster. Does that mean ipBlock (CIDR) selectors can be automatic per namespace? |
This use-case is already supported by ingress NetworkPolicy:
Not sure whether I understood your question. ipBlock is specified by user and does not change automatically, see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#ipblock-v1beta1-extensions. |
@brb, Yes, most of the use-case is supported by ingress NetworkPolicy but for egress we would want to block CIDR ranges like specific database ranges (AWS RDS) from discoverability. This is where we would need weave-net to support it. |
My use case is to block exfiltration of data from pods that have no reasons to talk to the outside world beyond their upstream (ingress) pod. ie: if someone gets to the backend database, he has to go through where he came from and, thus, an executed (exploit) script can't simply push data to the internet at large. |
Another use case would be, when you have to run untrusted code. Let's say you have 3 namespaces with trusted code, and 1 namespace where you run untrusted code. With one 1 egress rule you can block that entire untrusted namespace from making connections to other systems. Without egress rule support, you need to do it the other way: create ingress rules for each trusted namespace to block incoming traffic from the untrusted namespace. |
@jeroenjacobs1205 : That is also a good use case and it will be relevant for our environment as well. The egress rule support definitely makes a lot of the "inverse" ingress rules simpler. |
Thanks for the use cases. Short update from my side: I made some progress and most functionality has been implemented. Going to provide images for testing next week. |
I've published the test images: Please let me know about any bugs you encounter. |
Any feedback regarding the test images? The Egress PR is ready for a code review: #3313. |
@brb - I tried these test images to enforce egress policies with weavenet and it did work.. |
After rolling out the egress-test images over 2.3.0 I'm seeing a lot of the following:
For what seems like new pods. Rolling back to 2.3.0 causes NPC to fail on all nodes with
Kubernetes 1.9.8 No debug logs available right now as I don't have the time. |
Without the logs I can't help much. After rolling back to 2.3.0 you need either to restart each machine or to manually remove iptables rules which involve |
I found a little bit of time to try again. It's not a global problem and seems to be limited to a few of my nodes. They should all be identical from the kubelet configuration all the way down to the hypervisor, and only differ in the work put on them. There's no difference in weave (kube and npc) debug logs between working and failing nodes. I still have a few ideas where I can poke them to see if I can reproduce it, but I can only do that during off-hours since the cluster is quite busy... |
For me weave-npc does not even start up with the provided test image. It fails creating an already existing ipset:
The rollback to 2.3.0 worked after restarting the node. |
@lukaskorte Thanks for testing and providing the logs. I've fixed your issue and published new images: |
@brb, thanks this one is working great! Egress policy is working as expected. I tested it with an ipBlock like this:
|
From @awh on September 21, 2016 9:6
The k8s network SIG is developing an egress policy specification which we should support.
Copied from original issue: weaveworks-experiments/weave-npc#9
The text was updated successfully, but these errors were encountered: