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

Add K8sNP endPort support #2190

Merged
merged 3 commits into from
May 26, 2021
Merged

Add K8sNP endPort support #2190

merged 3 commits into from
May 26, 2021

Conversation

GraysonWu
Copy link
Contributor

@GraysonWu GraysonWu commented May 18, 2021

This PR fixes #1638.
Change the process of K8sNP -> InternalNP.
To use endPort in kube-apiserver, add featrue-gates flag.

@codecov-commenter
Copy link

codecov-commenter commented May 19, 2021

Codecov Report

Merging #2190 (f5187aa) into main (cddfccd) will increase coverage by 3.28%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2190      +/-   ##
==========================================
+ Coverage   61.69%   64.98%   +3.28%     
==========================================
  Files         274      274              
  Lines       20673    20674       +1     
==========================================
+ Hits        12754    13434     +680     
+ Misses       6587     5857     -730     
- Partials     1332     1383      +51     
Flag Coverage Δ
e2e-tests 56.23% <100.00%> (?)
kind-e2e-tests 52.39% <100.00%> (-0.28%) ⬇️
unit-tests 41.09% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ntroller/networkpolicy/networkpolicy_controller.go 84.59% <100.00%> (+0.02%) ⬆️
pkg/apiserver/certificate/cacert_controller.go 58.27% <0.00%> (-7.95%) ⬇️
pkg/apiserver/apiserver.go 89.51% <0.00%> (-1.62%) ⬇️
pkg/ovs/openflow/ofctrl_bridge.go 50.36% <0.00%> (+0.36%) ⬆️
pkg/agent/openflow/network_policy.go 76.41% <0.00%> (+0.59%) ⬆️
pkg/agent/cniserver/pod_configuration.go 54.68% <0.00%> (+0.78%) ⬆️
pkg/controller/egress/store/egressgroup.go 1.38% <0.00%> (+1.38%) ⬆️
pkg/ovs/openflow/ofctrl_flow.go 47.36% <0.00%> (+1.75%) ⬆️
pkg/flowaggregator/certificate.go 79.27% <0.00%> (+2.70%) ⬆️
pkg/agent/openflow/cookie/allocator.go 67.74% <0.00%> (+3.22%) ⬆️
... and 38 more

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'll defer to @Dyanngg for final approval

Comment on lines +16 to +17
extraArgs:
feature-gates: "NetworkPolicyEndPort=true"
Copy link
Contributor

Choose a reason for hiding this comment

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

you are enabling EndPort in the Vagrant testbed, which is fine by me, but there is no e2e test for EndPort yet?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe @GraysonWu mentioned that he is looking into adding the feature gate in antrea/ci/jenkins/ and antrea/ci/kind/, maybe you could share a bit more info on that front? Also, some amount of documentation on how the feature gate can be enabled for the k8s-apiserver will be very useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just added e2e test and enabled endport feature gate in Kind.
About Jenkins, I asked zhecheng for more information. Let's see his reply if they support 1.21.

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 @lzhecheng said, the testbed hasn't upgraded to 1.21. He will add that feature gate while upgrading.

@GraysonWu GraysonWu force-pushed the k8s-np-endport branch 2 times, most recently from 6460825 to 454ed24 Compare May 19, 2021 20:06
@Dyanngg
Copy link
Contributor

Dyanngg commented May 19, 2021

@GraysonWu GraysonWu force-pushed the k8s-np-endport branch 2 times, most recently from 56e61d0 to bc42f76 Compare May 19, 2021 23:34
test/e2e/framework.go Outdated Show resolved Hide resolved
test/e2e/framework.go Outdated Show resolved Hide resolved
test/e2e/framework.go Outdated Show resolved Hide resolved
test/e2e/networkpolicy_test.go Outdated Show resolved Hide resolved
test/e2e/networkpolicy_test.go Outdated Show resolved Hide resolved
test/e2e/networkpolicy_test.go Show resolved Hide resolved
antoninbas
antoninbas previously approved these changes May 21, 2021
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

test/e2e/networkpolicy_test.go Outdated Show resolved Hide resolved
test/e2e/networkpolicy_test.go Outdated Show resolved Hide resolved
ci/kind/kind-setup.sh Outdated Show resolved Hide resolved
@@ -806,6 +806,162 @@ func TestIngressPolicyWithoutPortNumber(t *testing.T) {
}
}

func TestIngressPolicyWithEndPort(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

How the test works if the testbed doesn't support 1.21 yet?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question, maybe we can add some mechanism to check if the feature gate is enabled? Didn't find a clean way but a simple look into the api server process seems to do the trick https://stackoverflow.com/questions/50441452/check-if-the-feature-gate-is-enabled-disabled-in-kubernetes

ps aux | grep apiserver | grep feature-gates
root       15458  7.8 19.7 1449248 402504 ?      Ssl  May23 185:47 kube-apiserver --advertise-address=192.168.77.100  .............. --etcd-servers=https://127.0.0.1:2379 --feature-gates=NetworkPolicyEndPort=true...........

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Addressed.

@GraysonWu GraysonWu force-pushed the k8s-np-endport branch 2 times, most recently from 662649c to 69bfa6f Compare May 24, 2021 21:58
test/e2e/fixtures.go Outdated Show resolved Hide resolved
@@ -109,6 +110,16 @@ func skipIfHasWindowsNodes(tb testing.TB) {
}
}

func skipIfKubeApiServerFeatureGateNotEnable(tb testing.TB, featureGateName string) {
_, stdout, _, err := provider.RunCommandOnNode(clusterInfo.controlPlaneNodeName, "ps aux | grep apiserver | grep feature-gates")
Copy link
Member

Choose a reason for hiding this comment

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

the function sounds generic but will work for features that are not enabled by default. If a newer K8s version enables it by default, it will skip a feature by mistake. It may not be a real problem in CI if we test few K8s versions only. But we should add a comment to explain its limitation.

Or for this particular case, you could create a Policy with endport set, check if the created policy still has it. If not, the feature is not enabled and the test can skip.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Addressed your last suggestion.

@GraysonWu GraysonWu force-pushed the k8s-np-endport branch 3 times, most recently from aa798fc to ff436c6 Compare May 25, 2021 19:45
@GraysonWu
Copy link
Contributor Author

/test-e2e

tnqn
tnqn previously approved these changes May 26, 2021
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

@tnqn
Copy link
Member

tnqn commented May 26, 2021

/test-all

network policy -> NetworkPolicy
Change `Fatalf` in defer func to `Errorf`
Remove double quotation

Signed-off-by: wgrayson <[email protected]>
@GraysonWu
Copy link
Contributor Author

/test-all

1 similar comment
@GraysonWu
Copy link
Contributor Author

/test-all

@GraysonWu
Copy link
Contributor Author

/test-conformance

@tnqn
Copy link
Member

tnqn commented May 26, 2021

/test-conformance
/test-networkpolicy

@tnqn
Copy link
Member

tnqn commented May 26, 2021

/test-networkpolicy

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.

Support endPort field for K8s NetworkPolicies
5 participants