antrea-io / antrea

Kubernetes networking based on Open vSwitch
https://antrea.io
Apache License 2.0
1.67k stars 370 forks source link

loadBalancerSourceRanges not supported in AntreaProxy #5493

Open jayunit100 opened 1 year ago

jayunit100 commented 1 year ago

Describe the bug

As of now antrea doesnt support loadBalancerSourceRanges in the antreaProxy. Since this is also not supported in the kube-proxy, we have no way to provdide this to Windows users.

To Reproduce

Similar to https://github.com/kubernetes/kubernetes/issues/120033 ...

Expected

AntreaProxy would fully support the Kubernetes service spec...

Actual behavior

LoadbalancerSourceRanges that are outside of an packet's IP are allowed into antrea clusters where antreaproxy is used.

Note this isnt a HUGE bug b/c alas, even the windows service proxy doesnt yet implement this

QUESTION:

Could this be done by reusing HNS packet filtering from the HNS ACLs ? Or does it require OVS?


aclPolicy := hns.ACLPolicy{
    Type:            hns.ACL,
    Action:          hns.Block,
    Direction:       hns.In,
    RemoteAddresses: loadBalancerSourceRanges
}
```?
tnqn commented 1 year ago

@hongliangl @wenyingd could you please take a look from Linux and Windows perspectives?

hongliangl commented 1 year ago

After discussing @wenyingd, we have two designs.

Take an example of two LoadBalancer Services

For design 1:

For design 2:

Could you give some suggestions @tnqn? Thanks a lot.

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days

hongliangl commented 1 month ago

For the current design implemented in #6181, see the git commit message. In an offline discussion, @wenyingd proposed a new design for the implementation:

Here are the flows of the latest Antrea main branch code with proxyAll enabled. I believe that everyone is very familiar with them.

...
table=ConntrackState, priority=0 actions=goto_table:PreRoutingClassifier

table=PreRoutingClassifier, priority=200,ip actions=resubmit(,NodePortMark),resubmit(,SessionAffinity),resubmit(,ServiceLB)
table=PreRoutingClassifier, priority=200,ipv6 actions=resubmit(,NodePortMark),resubmit(,SessionAffinity),resubmit(,ServiceLB)
table=PreRoutingClassifier, priority=0 actions=goto_table:NodePortMark

table=NodePortMark, priority=200,ip,nw_dst=10.176.27.91 actions=set_field:0x80000/0x80000->reg4
table=NodePortMark, priority=200,ip,nw_dst=192.168.77.100 actions=set_field:0x80000/0x80000->reg4
table=NodePortMark, priority=200,ip,nw_dst=172.17.0.1 actions=set_field:0x80000/0x80000->reg4
table=NodePortMark, priority=200,ip,nw_dst=169.254.0.252 actions=set_field:0x80000/0x80000->reg4
table=NodePortMark, priority=200,ipv6,ipv6_dst=2620:124:6020:1006:250:56ff:fea7:2787 actions=set_field:0x80000/0x80000->reg4
table=NodePortMark, priority=200,ipv6,ipv6_dst=fd00::192:168:77:100 actions=set_field:0x80000/0x80000->reg4
table=NodePortMark, priority=200,ipv6,ipv6_dst=fc01::aabb:ccdd:eefe actions=set_field:0x80000/0x80000->reg4

table=SessionAffinity, priority=0 actions=set_field:0x10000/0x70000->reg4

table=ServiceLB, priority=200,tcp,reg4=0x10000/0x70000,nw_dst=10.96.0.1,tp_dst=443 actions=set_field:0x200/0x200->reg0,set_field:0x20000/0x70000->reg4,set_field:0x5->reg7,group:5
table=ServiceLB, priority=200,tcp,reg4=0x10000/0x70000,nw_dst=10.96.225.251,tp_dst=80 actions=set_field:0x200/0x200->reg0,set_field:0x30000/0x70000->reg4,set_field:0x6->reg7,group:6
table=ServiceLB, priority=0 actions=goto_table:DSRServiceMark

Here are the draft flows of the design to implement loadBalancerSourceRanges:

...
table=ConntrackState, priority=0 actions=goto_table:LoadBalancerSourceRange

table=LoadBalancerSourceRange, priority=210,tcp,nw_src=192.168.77.0/24,nw_dst=192.168.77.150,tp_dst=80 actions=goto_table:PreRoutingClassifier
table=LoadBalancerSourceRange, priority=210,tcp,nw_src=192.168.78.0/24,nw_dst=192.168.77.150,tp_dst=80 actions=goto_table:PreRoutingClassifier
table=LoadBalancerSourceRange, priority=200,tcp,nw_dst=192.168.77.150,tp_dst=80 actions=drop
table=LoadBalancerSourceRange, priority=0 actions=goto_table:NodePortMark

table=NodePortMark, priority=200,ip,nw_dst=169.254.0.252 actions=set_field:0x80000/0x80000->reg4, goto_table:PreRoutingClassifier
table=NodePortMark, priority=200,ipv6,ipv6_dst=fd00::192:168:77:100 actions=set_field:0x80000/0x80000->reg4, goto_table:PreRoutingClassifier
table=NodePortMark, priority=200,ipv6,ipv6_dst=fc01::aabb:ccdd:eefe actions=set_field:0x80000/0x80000->reg4, goto_table:PreRoutingClassifier
table=NodePortMark, priority=0 actions=goto_table:PreRoutingClassifier

table=PreRoutingClassifier, priority=0,ip actions=resubmit(,SessionAffinity),resubmit(,ServiceLB)
table=PreRoutingClassifier, priority=0,ipv6 actions=resubmit(,SessionAffinity),resubmit(,ServiceLB)

table=SessionAffinity, priority=0 actions=set_field:0x10000/0x70000->reg4

table=ServiceLB, priority=200,tcp,reg4=0x10000/0x70000,nw_dst=10.96.0.1,tp_dst=443 actions=set_field:0x200/0x200->reg0,set_field:0x20000/0x70000->reg4,set_field:0x5->reg7,group:5
table=ServiceLB, priority=200,tcp,reg4=0x10000/0x70000,nw_dst=10.96.225.251,tp_dst=80 actions=set_field:0x200/0x200->reg0,set_field:0x30000/0x70000->reg4,set_field:0x6->reg7,group:6
table=ServiceLB, priority=0 actions=goto_table:DSRServiceMark

We can see key changes:

Look forwarding to your suggestions @tnqn @antoninbas