Skip to content

Commit f31eb80

Browse files
committed
add walkthrough doc
1 parent 4ac8460 commit f31eb80

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

docs/walkthrough.md

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Cyclonus: kubernetes network policy spec and CNI conformance
2+
3+
Cyclonus is a kubernetes network policy tool which can:
4+
5+
- show you what, precisely, your network policies mean according to the kubernetes spec
6+
- verify that your CNI conforms to the kubernetes network policy standard
7+
8+
# Why Cyclonus?
9+
10+
See [Cyclonus motivation and history](https://github.com/mattfenwick/cyclonus#motivation-and-history).
11+
12+
Example of subtle/confusing policies:
13+
14+
- https://kubernetes.io/docs/concepts/services-networking/network-policies/#behavior-of-to-and-from-selectors
15+
- [isolation semantics](https://kubernetes.io/docs/concepts/services-networking/network-policies/#the-two-sorts-of-pod-isolation)
16+
- [inability to directly block traffic](https://kubernetes.io/docs/concepts/services-networking/network-policies/#what-you-can-t-do-with-network-policies-at-least-not-yet)
17+
18+
# Cyclonus secret sauce
19+
20+
Visualization of a network policy's meaning -- TODO explain
21+
22+
Network policy engine: executable network policy specification -- TODO explain
23+
24+
# Code walkthrough
25+
26+
## Network policy engine
27+
28+
[`package matcher`](../pkg/matcher)
29+
30+
Goals:
31+
- models:
32+
- network policy
33+
- traffic: request from source->destination, using a port and protocol
34+
- leverage models:
35+
- ingest k8s network policy
36+
- given some network policies, will traffic be blocked or allowed?
37+
- generate human-readable explanation of network policies
38+
39+
Key types:
40+
- Policy
41+
- BuildNetworkPolicies
42+
- Policy.Simplify
43+
- Policy.IsTrafficAllowed
44+
- Policy.ExplainTable
45+
- Target
46+
- BuildTarget
47+
- Traffic
48+
49+
## Kubernetes wrapper and mock
50+
51+
[`package kube`](../pkg/kube)
52+
53+
Goals: leverage kubernetes API server to:
54+
- update state of cluster
55+
- run commands (similar to `kubectl exec`)
56+
57+
key types:
58+
- Kubernetes
59+
- ExecuteRemoteCommand
60+
- MockKubernetes
61+
62+
## Network policy test scenario generator
63+
64+
[`package generator`](../pkg/generator)
65+
66+
Goals:
67+
- model of network policy test scenario -- data collection, cluster perturbation
68+
- generate network policy test scenarios, whic explore various features of network
69+
policies including subtle areas of syntax and semantics
70+
- organize test scenarios by features used, to enable focus in testing and analysis of results
71+
72+
Key types:
73+
- Tag (string)
74+
- TestCase
75+
- TestCaseGenerator
76+
77+
## Connectivity test
78+
79+
[`package connectivity`](../pkg/connectivity)
80+
81+
Goals:
82+
- execute test case on a kubernetes cluster
83+
- meaningfully compare actual to expected results
84+
85+
How is a test case executed?
86+
1. blank slate; collect connectivity table
87+
2. for each (1+) perturbation:
88+
- update cluster state
89+
- collect connectivity data
90+
91+
Key types:
92+
- ComparisonTable
93+
- Interpreter
94+
- Interpreter.ExecuteTestCase
95+
- Result / StepResult
96+
- Printer
97+
98+
### Connectivity test: data collection
99+
100+
[`package probe`](../pkg/connectivity/probe)
101+
102+
Goals:
103+
- describe desired state of cluster before collection of connectivity data
104+
- use kube package to collect data for connectivity table
105+
106+
Key types:
107+
- Connectivity
108+
- Job
109+
- Job.KubeExecCommand
110+
- Resources
111+
- Resources.CreateResourcesInKube
112+
- Runner / KubeJobRunner / SimulatedJobRunner
113+
- RunJobs
114+
- TruthTable
115+
116+
117+
# CLI usage
118+
119+
[`cyclonus analyze`](./command-analyze.md): leverage executable network policy specification
120+
121+
[`cyclonus generate`](./command-generate.md): CNI network policy conformance test suite
122+
123+
[`cyclonus probe`](./command-probe.md): run a custom network policy test
124+
125+
# Next steps
126+
127+
Work with community to build out Cyclonus functionality and evolve in tandem with kubernetes network policy:
128+
https://github.com/kubernetes-sigs/network-policy-api/tree/master/cmd/cyclonus .
129+
130+
# Acknowledgements
131+
132+
Collaborators:
133+
- Jay
134+
- Amim
135+
- Ricardo
136+
137+
#sig-network
138+
139+
CNI teams:
140+
- Antrea
141+
- ovn-kubernetes
142+
- Cilium
143+
- Calico

0 commit comments

Comments
 (0)