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

[DISCUSSION] Create NetworkPolicy explainer #22

Open
mattfenwick opened this issue Aug 27, 2020 · 4 comments
Open

[DISCUSSION] Create NetworkPolicy explainer #22

mattfenwick opened this issue Aug 27, 2020 · 4 comments

Comments

@mattfenwick
Copy link
Collaborator

Input: 1 or more NetworkPolicies

Output: semantic explanation of policies, indicating what pods/namespaces/etc. will be targeted by the policy

Use case: as a developer or infra engineer, I want a debugging or sanity check tool to help me understand the impact of my network policies

@mattfenwick
Copy link
Collaborator Author

I've taken a first pass at this here, still a lot of work to do on that but would love some feedback on what kinds of support other people use when working on network policies!

@jayunit100
Copy link
Owner

if you want to make a PR into hack/explainer/ or whatever feel free to. would be great to have this and at least look at it during the mtng for a few minutes next wk.

@jayunit100
Copy link
Owner

jayunit100 commented Aug 27, 2020

paste the output in here when you get a chance to thanks !

@jayunit100 jayunit100 changed the title Create NetworkPolicy explainer [idea] Create NetworkPolicy explainer Aug 29, 2020
@mattfenwick
Copy link
Collaborator Author

mattfenwick commented Aug 29, 2020

Here's a PoC implementation.

Example output from a bunch of network policies:

{"Namespace": "default", "PodSelector": ["MatchLabels",["app: bookstore","role: db"],"MatchExpression",null]}
  ingress:
  - pods matching ["MatchLabels",["app: bookstore","role: search"],"MatchExpression",null] in all namespaces
    all ports all protocols
  - pods matching ["MatchLabels",["app: bookstore","role: api"],"MatchExpression",null] in all namespaces
    all ports all protocols
  - pods matching ["MatchLabels",["app: inventory","role: web"],"MatchExpression",null] in all namespaces
    all ports all protocols

{"Namespace": "default", "PodSelector": ["MatchLabels",["app: foo"],"MatchExpression",null]}
  ingress:
  egress:
  - anywhere: all pods in all namespaces and all IPs
    port 53 on protocol TCP
  - anywhere: all pods in all namespaces and all IPs
    port 53 on protocol UDP
  - all pods in all namespaces
    port 53 on protocol TCP
  - all pods in all namespaces
    port 53 on protocol UDP

{"Namespace": "default", "PodSelector": ["MatchLabels",["app: web"],"MatchExpression",null]}
  ingress:
  - anywhere: all pods in all namespaces and all IPs
    all ports all protocols
  - all pods in all namespaces
    all ports all protocols
  - anywhere: all pods in all namespaces and all IPs
    all ports all protocols
  - all pods in all namespaces
    all ports all protocols
  - all pods in namespaces matching ["MatchLabels",["purpose: production"],"MatchExpression",null]
    all ports all protocols
  - pods matching ["MatchLabels",["type: monitoring"],"MatchExpression",null] in namespaces matching ["MatchLabels",["team: operations"],"MatchExpression",null]
    all ports all protocols
  - anywhere: all pods in all namespaces and all IPs
    all ports all protocols

{"Namespace": "default", "PodSelector": ["MatchLabels",["all: web"],"MatchExpression",null]}
  ingress:

{"Namespace": "default", "PodSelector": ["MatchLabels",["app: bookstore","role: api"],"MatchExpression",null]}
  ingress:
  - pods matching ["MatchLabels",["app: bookstore"],"MatchExpression",null] in all namespaces
    all ports all protocols

{"Namespace": "default", "PodSelector": ["MatchLabels",null,"MatchExpression",null]}
  ingress:
  - all pods in namespace default
    all ports all protocols
  egress:

{"Namespace": "default", "PodSelector": ["MatchLabels",["a: b"],"MatchExpression",null]}
  ingress:
  - pods matching ["MatchLabels",["role: client"],"MatchExpression",null] in namespaces matching ["MatchLabels",["user: alice"],"MatchExpression",null]
    all ports all protocols
  - all pods in namespaces matching ["MatchLabels",["user: alice"],"MatchExpression",null]
    all ports all protocols
  - pods matching ["MatchLabels",["role: client"],"MatchExpression",null] in all namespaces
    all ports all protocols

{"Namespace": "default", "PodSelector": ["MatchLabels",["app: apiserver"],"MatchExpression",null]}
  ingress:
  - pods matching ["MatchLabels",["role: monitoring"],"MatchExpression",null] in all namespaces
    port 5000 on protocol TCP

@jayunit100 jayunit100 changed the title [idea] Create NetworkPolicy explainer [DISCUSSION] Create NetworkPolicy explainer Sep 15, 2020
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

No branches or pull requests

2 participants