Skip to content

Commit

Permalink
feat(Netpol Assistant): data structures simulating connectivity matri…
Browse files Browse the repository at this point in the history
…x for ANP/BANP
  • Loading branch information
huntergregory committed Oct 18, 2023
1 parent 262dc04 commit f7208d9
Show file tree
Hide file tree
Showing 23 changed files with 2,526 additions and 786 deletions.
53 changes: 9 additions & 44 deletions cmd/cyclonus/README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
# Cyclonus
# NetworkPolicy Assistant (derived from Cyclonus)

## Network policy explainer, prober, and test case generator
Explains your configuration of (Baseline)AdminNetworkPolicy and v1 NetworkPolicy. Additionally, can test conformance of (B)ANP and v1 NetworkPolicy via a connectivity matrix. Derived from the great work of @mattfenwick et al. in [Cyclonus](https://github.com/mattfenwick/cyclonus).

Parse, explain, and probe network policies to understand their implications and help design
policies that suit your needs!
More details here: [Cyclonus](https://github.com/mattfenwick/cyclonus).

## Quickstart
## Usage

Users: check out our [Quickstart guide](./docs/quickstart.md)
CLI currently under development. Will build off of `cyclonus analyze` (visualization) and `cyclonus generate` (conformance tests).

Developers: check out our [Developer guide](./docs/developer-guide.md)
## Development

Cyclonus functionality:
Integration tests located at *test/integration/integration_test.go*. The tests verify:

- [run a single network policy test on a cluster](./docs/probe.md)
- [run network policy conformance tests on a cluster](./docs/generator.md)
- [understand test runs](./docs/test-runs.md)
- [analyze network policies](./docs/analyze.md)


## Integrations

Cyclonus is available as a [**krew/kubectl plugin**](https://github.com/mattfenwick/kubectl-cyclonus):

- [Set up krew](https://krew.sigs.k8s.io/docs/user-guide/quickstart/)
- install: `kubectl krew install cyclonus`
- use: `kubectl cyclonus -h`

**Antrea testing**: [Cyclonus runs network policy tests for Antrea on a daily basis](https://github.com/vmware-tanzu/antrea/actions/workflows/netpol_cyclonus.yml).

**Cilium testing**: [Cyclonus runs network policy tests for Cilium on a daily basis](https://github.com/cilium/cilium/pull/14889).

**Sonobuoy plugin**: [run Cyclonus tests through Sonobuoy](./hack/sonobuoy).


## Motivation and History

Testing network policies for CNI providers on Kubernetes has historically been very difficult, requiring a lot of boiler plate.
This was recently improved upstream via truth table based tests
([see KEP](https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/1611-network-policy-validation)).
Cyclonus is the next evolution of the truth table tests which are part of upstream Kubernetes.
Cyclonus generates hundreds of network policies, their connectivity tables, and outputs results in the same, easy to read format.

## Thanks to contributors

- @dougsland
- @jayunit100
- @johnSchnake
- @enhaocui
- @matmerr
1. Building/translating NetPol spec into interim data structures (matchers).
2. Simulation of expected connectivity for ANP, BANP, and v1 NetPols.
66 changes: 35 additions & 31 deletions cmd/cyclonus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,61 @@ require (
github.com/jstemmer/go-junit-report v0.9.1
github.com/mattfenwick/collections v0.1.7
github.com/olekukonko/tablewriter v0.0.4
github.com/onsi/ginkgo/v2 v2.1.4
github.com/onsi/gomega v1.19.0
github.com/onsi/ginkgo/v2 v2.9.1
github.com/onsi/gomega v1.27.4
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.0.0
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.1
golang.org/x/exp v0.0.0-20220706164943-b4a6d9510983
k8s.io/api v0.24.2
k8s.io/apimachinery v0.24.2
k8s.io/client-go v0.24.2
sigs.k8s.io/yaml v1.2.0
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
sigs.k8s.io/network-policy-api v0.1.1
sigs.k8s.io/yaml v1.3.0
)

require (
cloud.google.com/go v0.81.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-runewidth v0.0.7 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
Loading

0 comments on commit f7208d9

Please sign in to comment.