-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat(Policy Assistant): support LoadBalancer and NodePort services in "generate" conformance tests #287
base: main
Are you sure you want to change the base?
feat(Policy Assistant): support LoadBalancer and NodePort services in "generate" conformance tests #287
Conversation
Signed-off-by: Hunter Gregory <[email protected]>
Signed-off-by: Hunter Gregory <[email protected]>
Signed-off-by: Hunter Gregory <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: huntergregory The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for kubernetes-sigs-network-policy-api ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Signed-off-by: Hunter Gregory <[email protected]>
Signed-off-by: Hunter Gregory <[email protected]>
…ead of actual readme Signed-off-by: Hunter Gregory <[email protected]>
Signed-off-by: Hunter Gregory <[email protected]>
Signed-off-by: Hunter Gregory <[email protected]>
Signed-off-by: Hunter Gregory <[email protected]>
Signed-off-by: Hunter Gregory <[email protected]>
Overview
Today in Policy Assistant and Cyclonus, the "generate" conformance tests only test k8s services with type=ClusterIP.
This PR adds 18 test cases in total for traffic to LoadBalancer and NodePort services (for both externalTrafficPolicy values).
Test Cases
For each service type/externalTrafficPolicy, testing 1) default deny ingress and 2) allowing ingress (via Pods and node CIDR if needed). Similar for egress.
LoadBalancer Test Cases
Tests send traffic from each Pod to each LoadBalancer service's external IP.
The source Pod's node is expected to "intercept" this traffic and redirect to the one backend Pod (which may be on another node).
In the case of externalTrafficPolicy =Local, the backend Pod must be on the source node. Therefore, tests ignore inter-node probes.
In the case of externalTrafficPolicy =Cluster, if the backend Pod is on another node, the CNI will SNAT traffic to the node IP. For some NetworkPolicy implementations, the source Pod info is lost in this case; to allow traffic requires a policy that allows traffic from the source node.
NodePort Test Cases
Tests send traffic from each Pod to each NodePort service's node port.
In the case of externalTrafficPolicy =Local, tests send traffic to the destination Pod's node.
In the case of externalTrafficPolicy =Cluster, tests send traffic to the source Pod's node (since this externalTrafficPolicy supports redirecting traffic to another node).
Verifying this change
New Test Cases
Verified traffic goes to correct services and that tests pass for two NetworkPolicy implementations.
There are 18 test cases. For Azure NPM, 2 must be ignored (see command below). For Cilium, 3 cases should be ignored since Cilium doesn't support
ipBlock
by default.Old Test Cases
Verified that nothing seems to break. Only ClusterIP services are created.
Example runs for two NetworkPolicy implementations
Cilium:
Azure NPM:
CLI Outputs
All 18 test cases (none are ignored here):
Result of Tests
Example run using the Azure NPM cluster: