-
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
analysis with specific ingress controllers #281
Draft
shireenf-ibm
wants to merge
24
commits into
main
Choose a base branch
from
issue_235_better_support_ingress_analysis
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d2a2d70
example with the issue's problem
shireenf-ibm 75be2e2
considering specific ingress conns
shireenf-ibm 9c83492
Merge branch 'main' into issue_235_better_support_ingress_analysis
shireenf-ibm c944d7d
Merge branch 'main' into issue_235_better_support_ingress_analysis
shireenf-ibm d2d5177
update test output files after merge
shireenf-ibm 767c0d8
Merge branch 'main' into issue_235_better_support_ingress_analysis
shireenf-ibm 48541fb
using only specific ingress controllers (eliminating general ingress …
shireenf-ibm e81012f
Merge branch 'main' into issue_235_better_support_ingress_analysis
shireenf-ibm d208fca
Merge branch 'main' into issue_235_better_support_ingress_analysis
shireenf-ibm 1129d7f
Merge branch 'main' of github.com:np-guard/netpol-analyzer into issue…
shireenf-ibm 5b60262
specifying ingress-controller namespaces with labels + example + doc
shireenf-ibm 5efc8a8
Update pkg/netpol/connlist/connlist.go
shireenf-ibm 7f3ece7
Update pkg/netpol/connlist/connlist.go
shireenf-ibm eea58b7
fixing build issue (common.Connection is an interface)
shireenf-ibm 1a4df6b
update connlist_output.md
shireenf-ibm bff14cf
some updates to ingress_analysis.md
shireenf-ibm 3549166
more updates to ingress_analysis.md
shireenf-ibm b4f2559
more updates to ingress_analysis.md
shireenf-ibm e023f9c
multiple updates
shireenf-ibm ccb758d
fixing nginx-ingress ns name
shireenf-ibm ef07875
Merge branch 'main' of github.com:np-guard/netpol-analyzer into issue…
shireenf-ibm dd608ce
Merge branch 'main' into issue_235_better_support_ingress_analysis
shireenf-ibm 220f9af
Merge branch 'main' into issue_235_better_support_ingress_analysis
shireenf-ibm 86dd8a3
Merge branch 'main' into issue_235_better_support_ingress_analysis
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Ingress Analysis | ||
|
||
Ingress Analysis is performed when input resources include Ingress/Route objects. | ||
|
||
For workloads that are selected by Ingress/Route objects, we analyze if ingress access from ingress-controllers is allowed to them. | ||
|
||
## Supported Ingress Controllers: | ||
|
||
Ingress Controllers considered for ingress analysis: | ||
- Openshift ingress controller ([view official docs](https://docs.openshift.com/container-platform/4.14/networking/ingress-operator.html#nw-ingress-view_configuring-ingress)) | ||
- Nginx ingress controller ([view official docs](https://docs.nginx.com/nginx-ingress-controller/overview)) | ||
|
||
#### Namespace Labels Checked : | ||
|
||
Ingress access to a workload selected by Ingress/Route object may be restricted by network-policies rules. | ||
In order to check if a network-policy rule enables access to such workload we need to check if a rule's namespaceSelector matches any of supported ingress controllers' namespaces. | ||
if at least one label of the following is used in the namespaceSelector, so ingress access from the relevant Ingress-Controller is enabled. | ||
|
||
|Ingress Controller | Namespace labels supported| More Details | | ||
|-------------------|---------------------------|--------------| | ||
|Openshift ingress controller |namespace.name: openshift-ingress-operator|[openshift-ingress-operator namespace link](https://github.com/openshift/cluster-ingress-operator/blob/f9dd81ab522f72233e2608f5e57a43e79a5079b5/manifests/00-namespace.yaml#L10)| | ||
||kubernetes.io/metadata.name: openshift-ingress-operator|| | ||
||openshift.io/cluster-monitoring: "true"|| | ||
|Openshift ingress controller |namespace.name: openshift-ingress|[openshift-ingress-operator namespace link](https://github.com/openshift/cluster-ingress-operator/blob/f9dd81ab522f72233e2608f5e57a43e79a5079b5/pkg/manifests/assets/router/namespace.yaml#L13)| | ||
||kubernetes.io/metadata.name: openshift-ingress|| | ||
||openshift.io/cluster-monitoring: "true"|| | ||
||network.openshift.io/policy-group: ingress|| | ||
||policy-group.network.openshift.io/ingress: ""|| | ||
||pod-security.kubernetes.io/enforce: privileged|| | ||
||pod-security.kubernetes.io/audit: privileged|| | ||
||pod-security.kubernetes.io/warn: privileged|| | ||
|Nginx ingress controller |kubernetes.io/metadata.name: nginx-ingress|[nginx-ingress namespace link](https://github.com/nginxinc/kubernetes-ingress/blob/main/deployments/common/ns-and-sa.yaml)| | ||
|
||
|
||
## Allowed Ingress Connections And Output: | ||
|
||
- Selecting ingress-controller deployment by `podSelector` in a network-policy rule is not supported yet. | ||
If ingress connections from a specific ingress-controller namespace (from above) is allowed to a cluster's peer, we assume it is allowed from any ingress-controller-pod in that namespace. | ||
|
||
- For a supported ingress-controller, the connectivity line is of the form: | ||
|
||
`{<ingress-controller-namespace-name>}` => `dst` : `connections`, where `dst` is a workload in the cluster. | ||
|
||
- If an ingress-controller may belong to more than one namespace, and they all were captured by the policies, only one of them will appear in the output. | ||
|
||
|
||
- If external ingress to a workload is allowed from any ingress-controller or at least all supported ingress-controllers, then the connectivity line is of the form: | ||
|
||
`{ingress-controller}` => `dst` : `connections`, where `dst` is a workload in the cluster. | ||
|
||
- When ingress connection is enabled by Ingress/Route, but restricted by a network-policy rule to be allowed from only one of the supported controllers, then only the connectivity line from the specified ingress-controller namespace will be reported. | ||
|
||
- If ingress connection is enabled by Ingress/Route but denied by network-policy rules, then ingress connection will be blocked and will not appear in the connectivity report. | ||
|
||
- If ingress connection is enabled by Ingress/Route but restricted by network-policy rules to another ingress-controller (that is not supported) then ingress connection will not appear in the connectivity report either. | ||
|
||
- This analysis is currently activated only with `--dirpath` flag, and not on a live cluster. | ||
It assumes that the ingress controller Pod is unknown, and thus using this notation of its namespace. | ||
|
||
|
||
### Possible warning | ||
`Route/Ingress specified workload as a backend, but network policies are blocking external ingress access by nginx or openshift ingress controllers. Connectivity map will not include a possibly allowed connection between the ingress controller and this workload.` | ||
|
||
Since the analysis considers only the mentioned above specific ingress controllers, it checks whether an arbitrary workload in one of the specified namespaces can access the destination workloads specified in Ingress/Route rules. If such access is not permitted by network policies, this connection is removed from the report. It may be an allowed connection if a network policy specifically allows ingress access to that workload from a specific workload/namespace of an actual different ingress controller installed. |
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
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
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
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
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
Oops, something went wrong.
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.
what if such pods already exist in the input resources list?
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.
if such pod already exists but no Route/Ingress found - nothing need to be done (handled in the past).
if we have Ingress/Route , till now assumed there is no ingress-controller deployment, in the resources.
but if such resources exist :
how should it behave?
option 1 : act as the existing ingress pod/s are the only ones considered for ingress analysis? (don't add
fake
ingress pods from other namespaces)but then if (for-example) we have an
nginx-ingress
deployment in the resources.and a policy-rule with
namespaceSelector
selecting one of theopenshift
controller namespaces - this rule will be ignored for ingress-analysis (as any rule which select a not existing namespace/pod)option2 : add fake ingress pods for the other ingress-controllers ?
if this option is the desired :
- if all ingress-controllers are supported should still have the general output line with
{ingress-controller}
as source ? (without the existing pod line)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.
another q: should we assume only one ingress-controller deployment may exist in the resources?
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 think it makes sense to assume only the input ingress controller if there is such, and then avoid adding the fake ingress pods.