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

Implement Antrea proxy #772

Merged
merged 1 commit into from
Jul 1, 2020
Merged

Conversation

weiqiangt
Copy link
Contributor

@weiqiangt weiqiangt commented May 31, 2020

  • Implement Antrea proxy for handling explicit ClusterIP services in OVS instead of using kube-proxy.
  • Add unit tests and e2e tests for Antrea proxy.
  • Add AntreaProxy option in FeatureGate for enabling Antrea proxy in the antrea agent. The default value for Linux is false while a Windows one is true.
  • Enhance kind tests for running with Antrea proxy.
  • Fix Windows service network policy not work issue.

Fixes #463.
Signed-off-by: Weiqiang TANG [email protected]

@antrea-bot
Copy link
Collaborator

Thanks for your PR.
Unit tests and code linters are run automatically every time the PR is updated.
E2e, conformance and network policy tests can only be triggered by a member of the vmware-tanzu organization. Regular contributors to the project should join the org.

The following commands are available:

  • /test-e2e: to trigger e2e tests.
  • /skip-e2e: to skip e2e tests.
  • /test-conformance: to trigger conformance tests.
  • /skip-conformance: to skip conformance tests.
  • /test-networkpolicy: to trigger networkpolicy tests.
  • /skip-networkpolicy: to skip networkpolicy tests.
  • /test-windows-conformance: to trigger windows conformance tests.
  • /skip-windows-conformance: to skip windows conformance tests.
  • /test-all: to trigger all tests.
  • /skip-all: to skip all tests.

These commands can only be run by members of the vmware-tanzu organization.

@weiqiangt
Copy link
Contributor Author

/test-conformance

@weiqiangt
Copy link
Contributor Author

/test-networkpolicy

@weiqiangt weiqiangt force-pushed the weiqiangt/antrea-proxy branch 3 times, most recently from 296b664 to d522aa7 Compare June 5, 2020 06:38
@weiqiangt
Copy link
Contributor Author

/test-windows-conformance

@weiqiangt weiqiangt force-pushed the weiqiangt/antrea-proxy branch 5 times, most recently from 7fb5813 to a33d19c Compare June 9, 2020 08:17
@weiqiangt weiqiangt changed the title [WIP] ANTREA PROXY Implement Antrea proxy Jun 9, 2020
@weiqiangt weiqiangt marked this pull request as ready for review June 9, 2020 08:18
@weiqiangt weiqiangt linked an issue Jun 9, 2020 that may be closed by this pull request
3 tasks
@weiqiangt
Copy link
Contributor Author

/test-all

@weiqiangt
Copy link
Contributor Author

/test-all

@antoninbas
Copy link
Contributor

@weiqiangt @jianjuns just wanted to check if the plan was to enable this mode unconditionally starting with the next Antrea release (0.8.0)? Or have a config switch (temporarily or permanently) to enable / disable the feature? Personally I am fine with enabling unconditionally, I don't if a user would have as a requirement that kube-proxy must be used.

This is relevant to @srikartati who is working on conntrack polling for IPFix flow information export.

@srikartati
Copy link
Member

This is relevant to @srikartati who is working on conntrack polling for IPFix flow information export.

Just to be specific.. looking at supporting Pod-to-Service flows/connections as IPFIX flow records.

@jianjuns
Copy link
Contributor

@weiqiangt @jianjuns just wanted to check if the plan was to enable this mode unconditionally starting with the next Antrea release (0.8.0)? Or have a config switch (temporarily or permanently) to enable / disable the feature? Personally I am fine with enabling unconditionally, I don't if a user would have as a requirement that kube-proxy must be used.

I suggest to add a config option, and maybe keep the default to upstream kube-proxy for Linux nodes, until we are confident on the quality and have enough tests.

@moshe010 moshe010 mentioned this pull request Jun 12, 2020
@weiqiangt weiqiangt force-pushed the weiqiangt/antrea-proxy branch 5 times, most recently from 5b55336 to c97d15a Compare June 15, 2020 05:17
Copy link
Contributor

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

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

Just some suggestions about comments improvement.

# Enable antrea proxy which provides ServiceLB for in-cluster services in antrea agent.
# It should be enabled on Windows, otherwise NetworkPolicy will not take effect on
# Service traffic.
# AntreaProxy: false
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel ok to add relatively mature features to the yamls but not all features. Creating a separate doc sounds good.

serviceConfig *config.ServiceConfig
// endpointsChanges and serviceChanges contains all changes to endpoints and
// services that happened since last syncProxyRules call. For a single object,
// changes are accumulated, i.e. previous is state from before all of them,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you should add the comments about previous/current to endpointsChanges struct or endpointsChangesTracker funcs. Hard to understand from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved.

k8sproxy "github.com/vmware-tanzu/antrea/third_party/proxy"
)

type endpointsChange struct {
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 you should add more comments to this file for structs and funcs. Not easy to understand the code without enough comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

endpointsConfig *config.EndpointsConfig
serviceConfig *config.ServiceConfig
// endpointsChanges and serviceChanges contains all changes to endpoints and
// services that happened since last syncProxyRules call. For a single object,
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 it would be much better if you can add some comments to explain the event sequence before syncProxyRules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@lzhecheng
Copy link
Contributor

/test-windows-networkpolicy

@weiqiangt
Copy link
Contributor Author

/test-all
/test-windows-networkpolicy

@weiqiangt
Copy link
Contributor Author

/test-networkpolicy

@tnqn
Copy link
Member

tnqn commented Jun 30, 2020

@weiqiangt the PR description about enableProxy is out of date, could you update?

tnqn
tnqn previously approved these changes Jun 30, 2020
@weiqiangt
Copy link
Contributor Author

/test-all
/test-windows-networkpolicy

@lzhecheng
Copy link
Contributor

/test-all

@lzhecheng
Copy link
Contributor

/test-conformance
/test-e2e
/test-networkpolicy
/test-windows-networkpolicy

@lzhecheng
Copy link
Contributor

/test-e2e
/test-conformance
/test-networkpolicy

antoninbas
antoninbas previously approved these changes Jun 30, 2020
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

Some small comments, mostly because of some typos in recently-added comments in the code. Otherwise LGTM. Glad that this is ready!

endpointIP := net.ParseIP(endpoint.IP()).To4()
ipVal := binary.BigEndian.Uint32(endpointIP)
portVal := uint16(endpointPort)
// TODO: use goto_table instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe a comment to this effect would have been nice

// affinityTimeout is not zero, it also installs the flow which has a learn
// action to maintain the LB decision.
// The group with the groupID must be installed before, otherwise the
// installation will be failed.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/will be failed/will fail

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.


// endpointsChangesTracker tracks Endpoints changes.
type endpointsChangesTracker struct {
// hostname is used to tell whether the Endpoint locates on current Node.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/locates/is located

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.


// OnEndpointUpdate updates given Service's Endpoints change map based on the
// <previous, current> Endpoints pair. It returns true if items changed,
// otherwise return false.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/return false/it returns false

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.

}

// endpointsToEndpointsMap translates single Endpoints object to EndpointsMap.
// This function is used for incremental updated of EndpointsMap.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/updated/update ?

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.

// endpointsChanges and serviceChanges contains all changes to endpoints and
// services that happened since last syncProxyRules call. For a single object,
// changes are accumulated. Once both endpointsChanges and serviceChanges
// had been synced, syncProxyRules will start syncing rules to the OVS.
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
// had been synced, syncProxyRules will start syncing rules to the OVS.
// have been synced, syncProxyRules will start syncing rules to OVS.

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.

serviceChanges *serviceChangesTracker
// syncProxyRulesMutex protects internal caches and states.
syncProxyRulesMutex sync.Mutex
// serviceMap stores services we expected to be installed.
Copy link
Contributor

Choose a reason for hiding this comment

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

we expect

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.

serviceMap k8sproxy.ServiceMap
// serviceInstalledMap stores services we actually installed.
serviceInstalledMap k8sproxy.ServiceMap
// endpointsMap stores endpoints we expected to be installed.
Copy link
Contributor

Choose a reason for hiding this comment

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

we expect

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.

}
defer teardownTest(t, data)

if enabled, err := proxyEnabled(data); 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.

maybe define skipIfProxyDisabled(t, data) in this file to reduce verbosity of this test and the subsequent ones

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.

)

func proxyEnabled(data *TestData) (bool, error) {
key := "resubmit(,40),resubmit(,41)"
Copy link
Contributor

Choose a reason for hiding this comment

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

as a follow-up to an earlier comment I made, there is already a GetAntreaConfigMap method defined for e2e tests, but I am not sure it's a much better solution than what you are doing at the moment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we use the configmap method, then we will need to parse the config.
For now, I prefer to keep the current code.
In the future, as we may add more experimental features, we can have a particular function to retrieve featuregayte options in e2e tests. How do you think about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good

return endpointsMap
}

// Update updates an EndpointsMap base on current changes and returns stale
Copy link
Contributor

Choose a reason for hiding this comment

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

base -> based

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.

Co-authored-by: Quan Tian <[email protected]>
Signed-off-by: Weiqiang TANG <[email protected]>
@weiqiangt weiqiangt dismissed stale reviews from antoninbas and tnqn via 6a82265 July 1, 2020 01:11
@weiqiangt weiqiangt closed this Jul 1, 2020
@weiqiangt weiqiangt reopened this Jul 1, 2020
@weiqiangt
Copy link
Contributor Author

/test-all
/test-windows-networkpolicy

Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

LGTM, I believe all my comments have been addressed

@lzhecheng
Copy link
Contributor

/test-conformance
/test-windows-networkpolicy

@lzhecheng
Copy link
Contributor

/test-windows-networkpolicy

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.

All comments should have been addressed now, I'm going to merge this after remaining tests pass to give other feature developers to address the conflicts, which might need some efforts given all of them reply on openflow implementation..

@tnqn tnqn merged commit c7d34f8 into antrea-io:master Jul 1, 2020
GraysonWu pushed a commit to GraysonWu/antrea that referenced this pull request Sep 22, 2020
GraysonWu pushed a commit to GraysonWu/antrea that referenced this pull request Sep 23, 2020
@weiqiangt weiqiangt deleted the weiqiangt/antrea-proxy branch December 24, 2020 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide service loadbalancing function to Pods via openflow in antrea-agent