Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine Endpoint selection for Multi-cluster Service #4693

Merged
merged 2 commits into from
Mar 14, 2023

Conversation

luolanzone
Copy link
Contributor

In order to decouple Multi-cluster with Antrea Proxy and refine Endpoint selection for Multi-cluster Service, following changes are included in this PR:

  1. Revert previous changes for local Endpoint selection.
  2. Add a new flow for the Service's ClusterIP in the EndpointDNAT table with
    group action. When an Endpoint of a Multi-cluster Service is a local Service
    ClusterIP and being selected, it will go to the corresponding exported Service's
    group to select the final Endpoint. This can avoid that the traffic goes out of the
    OVS bridge from antrea-gw0 (and handled by kube-proxy when it is running) and
    comes back again.

The proposal details can be found in the comment:
#4508 (comment)

@luolanzone
Copy link
Contributor Author

@jianjuns @tnqn could you take a look at this PR, I am still working on unit test. thanks.
Btw, should I merge the reverted commit and new commit into one? or keep the reverted commit standalone?

pkg/agent/openflow/client.go Outdated Show resolved Hide resolved
// UninstallServiceFlows removes flows installed by InstallServiceFlows.
UninstallServiceFlows(svcIP net.IP, svcPort uint16, protocol binding.Protocol) error

// InstallServiceClusterIPFlows install flows for accessing Endpoints which is Service's ClusterIP, and has an action
// to Service's corresponding group.
InstallServiceClusterIPFlows(svcIP net.IP, svcPort uint16, protocol binding.Protocol, groupID binding.GroupIDType) error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought it over again, perhaps it's simpler to just generate one more flow in InstallServiceFlows directly.

func InstallServiceFlows() {
...
if svcType == v1.ServiceTypeClusterIP && !nested {
      flows = append(flows, c.featureService. endpointRedirectFlowForServiceIP(svcIP, svcPort, protocol, groupID))
}
...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, I will update it.

pkg/agent/openflow/fields.go Outdated Show resolved Hide resolved
pkg/agent/proxy/proxier.go Outdated Show resolved Hide resolved
pkg/agent/proxy/proxier.go Outdated Show resolved Hide resolved
@luolanzone luolanzone added the area/multi-cluster Issues or PRs related to multi cluster. label Mar 9, 2023
@luolanzone luolanzone force-pushed the mc-local-ep-new-action branch 2 times, most recently from daac839 to 7e43f5c Compare March 9, 2023 05:57
@luolanzone luolanzone changed the title [WIP]Refine Endpoint selection for Multi-cluster Service Refine Endpoint selection for Multi-cluster Service Mar 9, 2023
pkg/agent/openflow/fields.go Outdated Show resolved Hide resolved
pkg/agent/openflow/pipeline.go Show resolved Hide resolved
pkg/agent/proxy/proxier.go Outdated Show resolved Hide resolved
pkg/agent/proxy/proxier.go Outdated Show resolved Hide resolved
pkg/agent/proxy/topology.go Outdated Show resolved Hide resolved
pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
pkg/agent/openflow/client.go Show resolved Hide resolved
// Install ClusterIP flows for the Service.
groupID := p.groupCounter.AllocateIfNotExist(svcPortName, internalPolicyLocal)
if err := p.ofClient.InstallServiceFlows(groupID, svcInfo.ClusterIP(), uint16(svcInfo.Port()), svcInfo.OFProtocol, uint16(affinityTimeout), externalPolicyLocal, corev1.ServiceTypeClusterIP); err != nil {
if err := p.ofClient.InstallServiceFlows(groupID, svcInfo.ClusterIP(), uint16(svcInfo.Port()), svcInfo.OFProtocol, uint16(affinityTimeout), externalPolicyLocal, corev1.ServiceTypeClusterIP, hasNestedService); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the new parameter should be a pointer

  • nil, do nothing in InstallServiceFlows. The Service is not related to nested Service, like NodePort or LoadBalancer.
  • true, install extra flow in EndpointDNATTable. The Service could be used as Endpoint of MC Service.
  • false, add extra action NestedServiceRegMark to the flow in ServiceLBTable. The Service is a MC Service.

In addition, this pointer should be always nil when MC is not enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this make the case more complicated, we only need to handle true or false case. There is actually no difference for nil and false since NodePort or LoadBalancer Service also have ClusterIP which can be exported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember that you said at least now only ClusterIP can be used as the Endpoint of MC Service according to Kubernetes KEP-xxxx. If so, I think we should only enhance the flow of pure ClusterIP Service and skip the ClusterIP in NodePort or LoadBalancer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I mean ClusterIP, not ClusterIP type of Service, since both NodePort and LoadBalancer have ClusterIP, I mean ClusterIP can be exported instead of NodeIP:NodePort or "LBIP:Port". KEP-1645 also suggested to use ClusterIP of NodePort and LoadBalancer Services.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we support that using ClusterIP of NodePort or LoadBalancer as Endpoint of MC-Service currently?

pkg/agent/openflow/pipeline.go Show resolved Hide resolved
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, there are integration test failures.

pkg/agent/proxy/proxier.go Outdated Show resolved Hide resolved
@luolanzone luolanzone force-pushed the mc-local-ep-new-action branch 2 times, most recently from 823e868 to 32f91ce Compare March 9, 2023 10:59
pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
Comment on lines 32 to 34
// NestedServiceSupport means the Service has an annotation "multicluster.antrea.io/imported-service"
// which means its Endpoints might be another Serivce's ClusterIP.
NestedServiceSupport bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// NestedServiceSupport means the Service has an annotation "multicluster.antrea.io/imported-service"
// which means its Endpoints might be another Serivce's ClusterIP.
NestedServiceSupport bool
// IsNested means the Service's Endpoints could be another Service's ClusterIP.
// Currently it's true for Multicluster Service, determined by whether there is a Multicluster specific annotation.
IsNested bool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +704 to +709
if svcType == v1.ServiceTypeClusterIP && !nested {
flows = append(flows, c.featureService.endpointRedirectFlowForServiceIP(svcIP, svcPort, protocol, groupID))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if svcType == v1.ServiceTypeClusterIP && !nested {
flows = append(flows, c.featureService.endpointRedirectFlowForServiceIP(svcIP, svcPort, protocol, groupID))
}
if svcType == v1.ServiceTypeClusterIP && nested != nil && !*nested {
flows = append(flows, c.featureService.endpointRedirectFlowForServiceIP(svcIP, svcPort, protocol, groupID))
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this way, I think we can skip the ClusterIP flow of NodePort or LoadBalancer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in previous comment, I feel there is no need to skip it. They will be be supported via ClusterIP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only gap here is that we didn't officially announce that we support these two kinds of Service in multi-cluster docs, I probably will update it after double check MC controller codes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't officially announce and support that , maybe we shouldn't introduce extra flows which are not used totally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned, there are probably just doc updates involved to support NodePort or LoadBalancer with ClusterIP, so I prefer not to skip it, otherwise we may change this part back soon. If you have further concern, we can sync offline, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ClusterIP from NodePort or LoadBalancer will be supported eventually, I'm ok with that.

pkg/agent/openflow/pipeline.go Show resolved Hide resolved
pkg/agent/proxy/proxier.go Outdated Show resolved Hide resolved
@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e

@@ -22,16 +22,25 @@ import (
k8sproxy "antrea.io/antrea/third_party/proxy"
)

const AntreaMCServiceAnnotation = "multicluster.antrea.io/imported-service"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define it in pkg/agent/multicluster? Even consider defining a func there like IsMulticlusterService.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, add a new func.

pkg/agent/openflow/fields.go Outdated Show resolved Hide resolved
@tnqn tnqn added this to the Antrea v1.11 release milestone Mar 10, 2023
@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e

@luolanzone
Copy link
Contributor Author

/test-all

tnqn
tnqn previously approved these changes Mar 10, 2023
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jianjuns
Copy link
Contributor

@hongliangl : any further comments?
@luolanzone : please resolve the conflict.

…o#4508)"

This reverts commit 6cdbca3.

Signed-off-by: Lan Luo <luola@vmware.com>
Add a new flow for the Service's ClusterIP in the EndpointDNAT table with
group action. When an Endpoint of a Multi-cluster Service is a local Service
ClusterIP and being selected, it will go to the corresponding exported Service's
group to select the final Endpoint. This can avoid that the traffic goes out of the
OVS bridge from antrea-gw0 (and handled by kube-proxy when it is running) and
comes back again.

The proposal details can be found in the comment:
antrea-io#4508 (comment)

Signed-off-by: Lan Luo <luola@vmware.com>
@luolanzone
Copy link
Contributor Author

Conflicts resolved.

/test-multicluster-e2e
/test-all

@tnqn
Copy link
Member

tnqn commented Mar 13, 2023

/test-multicluster-e2e

1 similar comment
@jianjuns
Copy link
Contributor

/test-multicluster-e2e

@luolanzone
Copy link
Contributor Author

Seems the testbed is not stable again, the e2es take much longer time which is 2 times than before, and NP tests failed with timeout, I will check with @hjiajing.

@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e

4 similar comments
@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e

@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e

@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e

@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e

@luolanzone
Copy link
Contributor Author

I have tried to trigger MC e2e locally with this branch, the results looks fine, all tests are passed. The latest triggered jenkins job might be back to normal. @tnqn you may either merged this or wait for the latest build result from Jenkins. Thanks.

--- PASS: TestConnectivity (340.06s)
    --- PASS: TestConnectivity/TestMCService (63.24s)
        --- PASS: TestConnectivity/TestMCService/Case=MCServiceConnectivity (0.75s)
        --- PASS: TestConnectivity/TestMCService/Case=ScaleDownMCServiceEndpoints (3.02s)
        --- PASS: TestConnectivity/TestMCService/Case=ANPToServices (12.61s)
        --- PASS: TestConnectivity/TestMCService/Case=StretchedNetworkPolicy (12.62s)
        --- PASS: TestConnectivity/TestMCService/Case=StretchedNetworkPolicyReject (6.66s)
        --- PASS: TestConnectivity/TestMCService/Case=StretchedNetworkPolicyUpdatePod (3.54s)
        --- PASS: TestConnectivity/TestMCService/Case=StretchedNetworkPolicyUpdateNS (6.67s)
        --- PASS: TestConnectivity/TestMCService/Case=StretchedNetworkPolicyUpdatePolicy (3.35s)
    --- PASS: TestConnectivity/TestAntreaPolicy (264.22s)
PASS
ok  	antrea.io/antrea/multicluster/test/e2e	342.245s

@tnqn tnqn merged commit 25ece2f into antrea-io:main Mar 14, 2023
jainpulkit22 pushed a commit to urharshitha/antrea that referenced this pull request Apr 28, 2023
* Revert "Refine Endpoint selection for multi-cluster Service (antrea-io#4508)"

This reverts commit 6cdbca3.

Signed-off-by: Lan Luo <luola@vmware.com>

* Refine Endpoint selection for MC Service

Add a new flow for the Service's ClusterIP in the EndpointDNAT table with
group action. When an Endpoint of a Multi-cluster Service is a local Service
ClusterIP and being selected, it will go to the corresponding exported Service's
group to select the final Endpoint. This can avoid that the traffic goes out of the
OVS bridge from antrea-gw0 (and handled by kube-proxy when it is running) and
comes back again.

The proposal details can be found in the comment:
antrea-io#4508 (comment)

Signed-off-by: Lan Luo <luola@vmware.com>

---------

Signed-off-by: Lan Luo <luola@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/multi-cluster Issues or PRs related to multi cluster.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants