-
Notifications
You must be signed in to change notification settings - Fork 2
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
don't remove representative peers in any-namespace #352
Merged
shireenf-ibm
merged 13 commits into
new_exposure_analysis_first_branch
from
sub_task_special_refinement_case
May 21, 2024
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
84ddee3
always keep representative peers which match all-namespaces
shireenf-ibm fb29b62
Merge branch 'new_exposure_analysis_first_branch' of github.com:np-gu…
shireenf-ibm 8ef848a
update test output after merge
shireenf-ibm 3c9e430
examples with rules exposing pod to an existing ns
shireenf-ibm e134fa1
Update pkg/netpol/eval/exposure.go
shireenf-ibm 722964f
don't refine rep. peers matching any pod in a namespace + changing so…
shireenf-ibm e4276e4
adding same test with nil podSelector instead of empty one
shireenf-ibm b7c498a
adding test with inaccurate output
shireenf-ibm 124a4f6
fixing comment syntax
shireenf-ibm 256ed88
Update pkg/netpol/connlist/connlist_test.go
shireenf-ibm 58c5df1
gofmt
shireenf-ibm 025ee8f
updating comments in yaml
shireenf-ibm 7e0595f
tiny fix
shireenf-ibm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test_outputs/connlist/exposure_test_conn_to_all_pods_in_an_existing_ns_connlist_output.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
digraph { | ||
subgraph "cluster_backend" { | ||
color="black" | ||
fontcolor="black" | ||
"backend/backend-app[Deployment]" [label="backend-app[Deployment]" color="blue" fontcolor="blue"] | ||
label="backend" | ||
} | ||
subgraph "cluster_hello_world" { | ||
color="black" | ||
fontcolor="black" | ||
"hello-world/workload-a[Deployment]" [label="workload-a[Deployment]" color="blue" fontcolor="blue"] | ||
label="hello-world" | ||
} | ||
"0.0.0.0-255.255.255.255" [label="0.0.0.0-255.255.255.255" color="red2" fontcolor="red2"] | ||
"entire-cluster" [label="entire-cluster" color="red2" fontcolor="red2" shape=diamond] | ||
"0.0.0.0-255.255.255.255" -> "backend/backend-app[Deployment]" [label="All Connections" color="gold2" fontcolor="darkgreen"] | ||
"backend/backend-app[Deployment]" -> "0.0.0.0-255.255.255.255" [label="All Connections" color="gold2" fontcolor="darkgreen"] | ||
"backend/backend-app[Deployment]" -> "entire-cluster" [label="All Connections" color="gold2" fontcolor="darkgreen" weight=0.5] | ||
"backend/backend-app[Deployment]" -> "hello-world/workload-a[Deployment]" [label="TCP 8050" color="gold2" fontcolor="darkgreen"] | ||
"entire-cluster" -> "backend/backend-app[Deployment]" [label="All Connections" color="gold2" fontcolor="darkgreen" weight=1] | ||
"hello-world/workload-a[Deployment]" -> "backend/backend-app[Deployment]" [label="All Connections" color="gold2" fontcolor="darkgreen"] | ||
"hello-world/workload-a[Deployment]" -> "entire-cluster" [label="All Connections" color="gold2" fontcolor="darkgreen" weight=0.5] | ||
} |
Binary file added
BIN
+38.4 KB
...nnlist/exposure_test_conn_to_all_pods_in_an_existing_ns_connlist_output.dot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions
95
...nnlist/exposure_test_conn_to_all_pods_in_an_existing_ns_connlist_output.dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions
18
test_outputs/connlist/exposure_test_conn_to_all_pods_in_an_existing_ns_connlist_output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
0.0.0.0-255.255.255.255 => backend/backend-app[Deployment] : All Connections | ||
backend/backend-app[Deployment] => 0.0.0.0-255.255.255.255 : All Connections | ||
backend/backend-app[Deployment] => hello-world/workload-a[Deployment] : TCP 8050 | ||
hello-world/workload-a[Deployment] => backend/backend-app[Deployment] : All Connections | ||
|
||
Exposure Analysis Result: | ||
Egress Exposure: | ||
backend/backend-app[Deployment] => 0.0.0.0-255.255.255.255 : All Connections | ||
backend/backend-app[Deployment] => entire-cluster : All Connections | ||
hello-world/workload-a[Deployment] => entire-cluster : All Connections | ||
|
||
Ingress Exposure: | ||
backend/backend-app[Deployment] <= 0.0.0.0-255.255.255.255 : All Connections | ||
backend/backend-app[Deployment] <= entire-cluster : All Connections | ||
|
||
Workloads not protected by network policies: | ||
backend/backend-app[Deployment] is not protected on Egress | ||
backend/backend-app[Deployment] is not protected on Ingress |
24 changes: 24 additions & 0 deletions
24
test_outputs/connlist/exposure_test_conn_to_new_pod_in_an_existing_ns_connlist_output.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
digraph { | ||
subgraph "cluster_backend" { | ||
color="black" | ||
fontcolor="black" | ||
"backend/backend-app[Deployment]" [label="backend-app[Deployment]" color="blue" fontcolor="blue"] | ||
"pod with {app=backend-new}_in_backend" [label="pod with {app=backend-new}" color="red2" fontcolor="red2"] | ||
label="backend" | ||
} | ||
subgraph "cluster_hello_world" { | ||
color="black" | ||
fontcolor="black" | ||
"hello-world/workload-a[Deployment]" [label="workload-a[Deployment]" color="blue" fontcolor="blue"] | ||
label="hello-world" | ||
} | ||
"0.0.0.0-255.255.255.255" [label="0.0.0.0-255.255.255.255" color="red2" fontcolor="red2"] | ||
"entire-cluster" [label="entire-cluster" color="red2" fontcolor="red2" shape=diamond] | ||
"0.0.0.0-255.255.255.255" -> "backend/backend-app[Deployment]" [label="All Connections" color="gold2" fontcolor="darkgreen"] | ||
"backend/backend-app[Deployment]" -> "0.0.0.0-255.255.255.255" [label="All Connections" color="gold2" fontcolor="darkgreen"] | ||
"backend/backend-app[Deployment]" -> "entire-cluster" [label="All Connections" color="gold2" fontcolor="darkgreen" weight=0.5] | ||
"entire-cluster" -> "backend/backend-app[Deployment]" [label="All Connections" color="gold2" fontcolor="darkgreen" weight=1] | ||
"hello-world/workload-a[Deployment]" -> "backend/backend-app[Deployment]" [label="All Connections" color="gold2" fontcolor="darkgreen"] | ||
"hello-world/workload-a[Deployment]" -> "entire-cluster" [label="All Connections" color="gold2" fontcolor="darkgreen" weight=0.5] | ||
"pod with {app=backend-new}_in_backend" -> "hello-world/workload-a[Deployment]" [label="TCP 8050" color="gold2" fontcolor="darkgreen" weight=1] | ||
} |
Binary file added
BIN
+45.2 KB
...onnlist/exposure_test_conn_to_new_pod_in_an_existing_ns_connlist_output.dot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it differentiate between
(which is any namespace)
to
(which is the network policy namespace)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and what about
this creates exposure to all pods in a certain namespace..
does this require indication as exposure?
it's not as matching pod with certain labels..
do we have any example test capturing this case with current implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it does
examples:
tests/test_conn_with_pod_selector_in_any_ns
with :(output:
test_outputs\connlist\exposure_test_conn_with_pod_selector_in_any_ns_connlist_output.dot.png
)tests/test_conn_with_only_pod_selector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have following example:
test:
tests\test_conn_to_all_pods_in_a_new_ns
with:
output:
test_outputs\connlist\exposure_test_conn_to_all_pods_in_a_new_ns_connlist_output.dot.png
in this example the
backend
ns is not in the manifests and we have no real pods in this ns so we see an exposure to representative peersbackend\[all pods]
.if we had a real pod in the namespace backend : it would be a match and we won't see the exposure line.(like all cases where the podSelector was not used, if there is a pod in the namespace the it is a match)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add another example where there is a real pod in the namespace backend
ok, the question is - should we consider changing this behavior (when the policy permits all pods in a real namespace)? if all pods in a namespace are permitted, it might be relevant as exposure info, even if there is a certain real pod in the namespace. (BTW there could be a real pod in that namespace on which there is a certain policy that blocks such a connection for this pod.. in such a case the connection to this pod is not in the report, nor the exposure to this namespace). [consider adding such an example as well]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add an example to see the behavior and update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added an example locally, the exposure analysis of bar still shows the line:
bar/workload-a[Deployment] => foo/[all pods] : All Connections
even that we have default-deny-in-foo for ingress
should fix the bug in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create new item and implement in a separate PR .
analysis should generate representative peers by also considering policies that capture them, and separate into sub-sections (sub-peers) that are having different connectivity by the policies (for example pods in ns with certain labels, and pods in ns without these labels).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's have this change in this PR , including adding the relevant examples , and mark by the example which has inaccurate output, a TODO comment, to make sure it is fixed in the next PR .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done