Repository navigation
Fix Services-vs-NetworkPolicy - #14466
Conversation
| otx.AddFlow("table=81, priority=100, ip, ct_state=+trk+est, actions=output:NXM_NX_REG2[]") | ||
| otx.AddFlow("table=81, priority=0, actions=drop") | ||
| otx.AddFlow("table=21, priority=200, ip, nw_dst=%s, actions=ct(commit,table=30)", np.node.networkInfo.ClusterNetwork.String()) | ||
| otx.AddFlow("table=80, priority=200, ip, ct_state=+rpl, actions=output:NXM_NX_REG2[]") |
There was a problem hiding this comment.
So this basically reverts #13877; we added the ct_zone because the table=21 rule was causing problems with pod-to-external connections, but actually we only need to call commit there on pod-to-pod connections anyway (so they get tracked so we can recognize replies to them as replies). So by only calling commit in a case where iptables will never see the packet anyway, we can avoid needing to fiddle with a zone. The table=80 rule didn't need to be calling commit anyway, it just needed to call ct() on the packet so we can then read its ct_state, but the new rules added in ovscontroller.go end up calling ct() on all packets now, so we don't need to do it again here.
| otx.AddFlow("table=30, priority=300, ip, nw_dst=%s, actions=output:2", localSubnetGateway) | ||
| otx.AddFlow("table=30, priority=100, ip, nw_dst=%s, actions=goto_table:60", serviceNetworkCIDR) | ||
| if oc.useConnTrack { | ||
| otx.AddFlow("table=30, priority=300, ip, nw_dst=%s, ct_state=+rpl, actions=ct(nat),goto_table:70", localSubnetCIDR) |
There was a problem hiding this comment.
This is kind of a hack; we call ct(nat) on all pod-reply-to-pod packets; if they're DNATted this will undo that and if they're not it's a no-op. In earlier versions of the patch we were setting ct_state on the outgoing packets and then only un-DNATting the replies with ct_state set. But then we have to worry about our use of ct_state conflicting with other uses, etc. So this avoids that
|
@openshift/networking PTAL |
|
Regarding the Q, I vote we require the iptables proxier. Regarding the router, do we need to do anything if idling is not supported (i.e. if EnableUnidling = false in the config?). We have to document that this means the userspace proxy and idling are not supported with NetworkPolicy (at the moment) and then I think we need to implement the service rules in ovs so that we can support the userspace proxy before we move out of tech preview. |
3c4b5a2 to
2a081e7
Compare
Done
I assume not?
Filed https://trello.com/c/LO5B6TKY about supporting userspace proxy |
|
[test] |
|
Test failure: |
3212b17 to
a888264
Compare
a888264 to
88b46f1
Compare
88b46f1 to
a15ce2f
Compare
|
[test]. I am not going to even try to justify https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/2212/ by filing flakes |
|
[test] |
isn't related to this change? |
|
@smarterclayton The majority of this PR only affects the networkpolicy plugin, which doesn't get tested by jenkins yet. (Merging this PR is one of the prereqs for enabling the jenkins networkpolicy tests.) It's possible that some of the code reorg could have broken the multitenant plugin and thus the tests, but given that the conformance-gce and conformance-install-update failures also look spurious, and that the networking-minimal test also failed even harder during its cleanup: I'm assuming that this is just "something went horribly wrong with jenkins" |
|
[test] |
a15ce2f to
08aec76
Compare
|
OK. Once again, jenkins had multiple failures (everything but "integration" this time!), including random compile failures, random connectivity failures, and random ansible failures. And in particular, networking-minimal got killed somehow again: Working theory: the openvswitch 2.7.0 package which we were installing to get OVS NAT support has some horrible memory leak in it that eventually breaks everything? (Possibly even causing problems with other VMs on the same machine? I don't know the details of how the different test suites are run...) I've repushed without "58834dc Grab a newer OVS binary for the dind image". (It's acceptable for this to merge without that for now; it just means we won't be able to merge #12991 [it won't pass tests].) If that makes things work I'll try replacing the 2.7.0 package with a 2.6.x one... |
|
Still failing? |
| node.watchServices() | ||
| if !node.useConnTrack { | ||
| go kwait.Forever(node.watchServices, 0) | ||
| } |
There was a problem hiding this comment.
Doh. A bad rebase after the shared informers PR ended up turning the node process into a fork bomb when not using networkpolicy.
Require OVS 2.6 when using the NetworkPolicy plugin, and tweak the OVS and iptables rules to avoid masquerading pod-to-service connections, so that we can then correctly match NetworkPolicies against those connections.
08aec76 to
22afa39
Compare
22afa39 to
f9b8548
Compare
|
The failures here were unrelated [test]
…On Fri, Jun 16, 2017 at 4:16 PM, OpenShift Bot ***@***.***> wrote:
continuous-integration/openshift-jenkins/test FAILURE (
https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/2325/)
(Base Commit: d40783e
<d40783e>)
(PR Branch Commit: f9b8548
<f9b8548>
)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14466 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p1nMSz1253-QwTcHFXuSI2cVToKuks5sEuKggaJpZM4NvFv9>
.
|
|
Evaluated for origin test up to f9b8548 |
|
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/2339/) (Base Commit: ee67917) (PR Branch Commit: f9b8548) |
|
[merge][severity:blocker] |
|
Evaluated for origin merge up to f9b8548 |
|
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/1039/) (Base Commit: 18f6c93) (PR Branch Commit: f9b8548) (Extended Tests: blocker) (Image: devenv-rhel7_6374) |
This fixes the "you can't use service IPs to connect to a pod if that connection is only allowed by a NetworkPolicy with a podSelector" bug, by making it so that we don't masquerade pod->service connections when using the networkpolicy plugin, so that we can do the policy checks after the service IP rewrite rather than before like we do now (and like we do in the multitenant plugin).
To recap: suppose pod 1 (10.128.0.2) wants to connect to service 172.30.99.99:1234, which is implemented by pod 2 (10.128.0.3) on port 80. If we just used kubernetes' default masquerading rules, we'd get:
So we add another iptables rule, causing the packet to get masqueraded:
The original plan was to change this to:
But we were never able to get that to work right. Eventually we settled on:
actions=ct(nat), making it 172.30.99.99:1234 -> 10.128.0.2:49152After discussion in the scrum yesterday, this only changes the masquerading behavior when using the networkpolicy plugin; we'll change it for subnet/multitenant in 3.7 after the code has gotten a little more testing.
Also, there is one piece missing here: if you use this with the userspace proxier, then all pod->service connections will be allowed, even if they shouldn't be; this is because we no longer check the policy before passing the connection to the proxier, and when it comes back, if you're using the userspace proxier, the source IP will be the node's IP, and in that case we'll accept it unconditionally (because you have to do that, in order for health checks to work, etc). So we need to do one of:
It seems like neither of those solutions works for the case of the hybrid proxier on routers though... right?