Skip to content

Commit 937905f

Browse files
committed
Small fixes to website and adding contributing info
- Added section to contributing doc explaining requirements to locally test docs. - Fixed broken links - Added diagram to API explanation - Cross-linked example API objects to user stories
1 parent 429a9e6 commit 937905f

File tree

13 files changed

+184
-138
lines changed

13 files changed

+184
-138
lines changed

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ If your repo has certain guidelines for contribution, put them here ahead of the
2121
1) Clone the repo: `git clone https://github.com/kubernetes-sigs/network-policy-api.git`
2222
2) Run `cd network-policy-api` && `make install`
2323

24+
## Developing the Website
25+
26+
The site documentation is written in Markdown and compiled with
27+
[mkdocs](https://www.mkdocs.org/).
28+
29+
### Setting up local development
30+
31+
1. Install mkdocs and required plugins:
32+
33+
```
34+
pip install mkdocs mkdocs-material mkdocs-awesome-pages-plugin mkdocs-macros-plugin
35+
```
36+
37+
2. To build the docs, run `make docs`.
38+
3. To deploy the docs locally, run `make local-docs`
39+
2440
## Mentorship
2541
2642
- [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers!

mkdocs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ theme:
1313
- search.highlight
1414
- navigation.tabs
1515
- navigation.top
16-
edit_uri: edit/main/site-src/
16+
edit_uri: edit/master/site-src/
1717
plugins:
1818
- search
1919
- awesome-pages
@@ -26,10 +26,13 @@ markdown_extensions:
2626
- pymdownx.emoji:
2727
emoji_index: !!python/name:materialx.emoji.twemoji
2828
emoji_generator: !!python/name:materialx.emoji.to_svg
29+
- pymdownx.details
2930
- pymdownx.highlight
3031
- pymdownx.inlinehilite
3132
- pymdownx.superfences
32-
- pymdownx.snippets
33+
- pymdownx.snippets:
34+
base_path: site-src
35+
check_paths: true
3336
- toc:
3437
permalink: true
3538
nav:

site-src/api-overview.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Currently, there are two main objects in the Network Policy API resource model:
3333

3434
- **BaselineAdminNetworkPolicy (BANP)**
3535

36+
The diagram below demonstrates how these new API objects interact with
37+
each-other and existing NetworkPolicy Objects:
38+
39+
![Alt text](./images/ANP-api-model.png?raw=true "Admin Network Policy API Model")
40+
3641
## General Notes
3742

3843
- Any well defined AdminNetworkPolicy rules should
@@ -116,7 +121,7 @@ The BaselineAdminNetworkPolicy (BANP) resource will allow administrators to
116121
set baseline security rules that describes default connectivity for cluster workloads,
117122
which CAN be overridden by developer NetworkPolicies if needed. The major use case
118123
BANPs solve is the ability to flip the [default security stance of the
119-
cluster](../index.md#story-5-cluster-wide-default-guardrails).
124+
cluster](user-stories.md#story-5-cluster-wide-default-guardrails).
120125

121126
### BaselineAdminNetworkPolicy Rule Actions
122127

site-src/docs/index.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

site-src/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Network Policy API Working Group
22
👋 Welcome to the Network Policy API Project - we are happy to have you here! Before you get started here are some useful links:
33

4+
- [Bi-Weekly Meeting Agenda](https://docs.google.com/document/d/1AtWQy2fNa4qXRag9cCp5_HsefD7bxKe3ea2RPn8jnSs/edit#heading=h.ajvcztp6cza)
45
- [NetworkPolicy v1 Docs](https://kubernetes.io/docs/concepts/services-networking/network-policies/)
56
- [API reference spec](/reference/spec/)
67

@@ -47,4 +48,4 @@ Time (16:00 UTC):
4748
To get started contributing please take time to read over the [contributing guidelines](https://github.com/kubernetes-sigs/network-policy-api/blob/master/CONTRIBUTING.md) as well as the [developer guide](https://github.com/kubernetes/community/blob/master/contributors/devel/README.md). You can then take a look at the open issues labelled 'good-first-issue' [here](https://github.com/kubernetes-sigs/network-policy-api/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
4849

4950
### Code of conduct
50-
Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](code-of-conduct.md).
51+
Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](https://github.com/kubernetes/community/blob/master/code-of-conduct.md).

site-src/reference/examples.md

Lines changed: 13 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -6,155 +6,51 @@ Network Policy API.
66
## Sample AdminNetworkPolicy and BaseLineAdminNetworkPolicy Resources
77

88
These examples will start with the object yaml defintions used to implement the
9-
[core use cases](../intro.md#adminnetworkpolicy-api-user-stories). Please feel
9+
[core use cases](../user-stories.md). Please feel
1010
free to contribute more examples that may seem relevant to other users :-).
1111

1212
### Sample Spec for Story 1: Deny traffic at a cluster level
1313

14-
![Alt text](../../images/explicit_deny.png?raw=true "Explicit Deny")
14+
![Alt text](../images/explicit_deny.png?raw=true "Explicit Deny")
1515

1616
```yaml
17-
apiVersion: policy.networking.k8s.io/v1alpha1
18-
kind: AdminNetworkPolicy
19-
metadata:
20-
name: cluster-wide-deny-example
21-
spec:
22-
priority: 10
23-
subject:
24-
namespaces:
25-
matchLabels:
26-
kubernetes.io/metadata.name: sensitive-ns
27-
ingress:
28-
- action: Deny
29-
from:
30-
- namespaces:
31-
namespaceSelector: {}
32-
name: select-all-deny-all
17+
--8<-- "user-story-examples/user-story-1.yaml"
3318
```
3419

3520
### Sample Spec for Story 2: Allow traffic at a cluster level
3621

37-
![Alt text](../../images/explicit_allow.png?raw=true "Explicit Allow")
22+
![Alt text](../images/explicit_allow.png?raw=true "Explicit Allow")
3823

3924
```yaml
40-
apiVersion: policy.networking.k8s.io/v1alpha1
41-
kind: AdminNetworkPolicy
42-
metadata:
43-
name: cluster-wide-allow-example
44-
spec:
45-
priority: 30
46-
subject:
47-
namespaces: {}
48-
ingress:
49-
- action: Allow
50-
from:
51-
- namespaces:
52-
namespaceSelector:
53-
matchLabels:
54-
kubernetes.io/metadata.name: monitoring-ns
55-
egress:
56-
- action: Allow
57-
to:
58-
- namespaces:
59-
namespaceSelector:
60-
matchlabels:
61-
kubernetes.io/metadata.name: kube-system
62-
pods:
63-
podSelector:
64-
matchlabels:
65-
app: kube-dns
25+
--8<-- "user-story-examples/user-story-2.yaml"
6626
```
6727

6828
### Sample Spec for Story 3: Explicitly Delegate traffic to existing K8s Network Policy
6929

70-
![Alt text](../../images/delegation.png?raw=true "Delegate")
30+
![Alt text](../images/delegation.png?raw=true "Delegate")
7131

7232
```yaml
73-
apiVersion: policy.networking.k8s.io/v1alpha1
74-
kind: AdminNetworkPolicy
75-
metadata:
76-
name: pub-svc-delegate-example
77-
spec:
78-
priority: 20
79-
subject:
80-
namespaces: {}
81-
egress:
82-
- action: Pass
83-
to:
84-
- pods:
85-
namespaceSelector:
86-
matchLabels:
87-
kubernetes.io/metadata.name: bar-ns-1
88-
podSelector:
89-
matchLabels:
90-
app: svc-pub
91-
ports:
92-
- portNumber:
93-
protocol: TCP
94-
port: 8080
33+
--8<-- "user-story-examples/user-story-3.yaml"
9534
```
9635

97-
### Sample Spec for Story 4: Create and Isolate multiple tenants in a cluster
36+
### Sample Spec for Story 4: Create and Isolate multiple tenants in a cluster
9837

99-
![Alt text](../../images/tenants.png?raw=true "Tenants")
38+
![Alt text](../images/tenants.png?raw=true "Tenants")
10039

10140
```yaml
102-
apiVersion: policy.networking.k8s.io/v1alpha1
103-
kind: AdminNetworkPolicy
104-
metadata:
105-
name: tenant-creation-example
106-
spec:
107-
priority: 50
108-
subject:
109-
namespaces:
110-
matchExpressions: {key: "tenant"; operator: Exists}
111-
ingress:
112-
- action: Deny
113-
from:
114-
- namespaces:
115-
notSameLabels:
116-
- tenant
41+
--8<-- "user-story-examples/user-story-4-v1.yaml"
11742
```
11843

11944
This can also be expressed in the following way:
12045

12146
```yaml
122-
apiVersion: policy.networking.k8s.io/v1alpha1
123-
kind: AdminNetworkPolicy
124-
metadata:
125-
name: tenant-creation-example
126-
spec:
127-
priority: 50
128-
subject:
129-
namespaces:
130-
matchExpressions: {key: "tenant"; operator: Exists}
131-
ingress:
132-
- action: Pass # Pass inter-tenant traffic to any defined NetworkPolicies
133-
from:
134-
- namespaces:
135-
sameLabels:
136-
- tenant
137-
- action: Deny # Deny everything else other than same tenant traffic
138-
from:
139-
- namespaces:
140-
namespaceSelector: {}
47+
--8<-- "user-story-examples/user-story-4-v2.yaml"
14148
```
14249

14350
### Sample Spec for Story 5: Cluster Wide Default Guardrails
14451

145-
![Alt text](../../images/baseline.png?raw=true "Default Rules")
52+
![Alt text](../images/baseline.png?raw=true "Default Rules")
14653

14754
```yaml
148-
apiVersion: policy.networking.k8s.io/v1alpha1
149-
kind: BaselineAdminNetworkPolicy
150-
metadata:
151-
name: baseline-rule-example
152-
spec:
153-
subject:
154-
namespaces: {}
155-
ingress:
156-
- action: Deny # zero-trust cluster default security posture
157-
from:
158-
- namespaces:
159-
namespaceSelector: {}
55+
--8<-- "user-story-examples/user-story-5.yaml"
16056
```

site-src/user-stories.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ ports and protocols.
2424

2525
![Alt text](./images/explicit_deny.png?raw=true "Explicit Deny")
2626

27+
??? success "Equivalent API Object"
28+
```yaml
29+
--8<-- "user-story-examples/user-story-1.yaml"
30+
```
31+
2732
#### Story 2: Allow traffic at a cluster level
2833

2934
As a cluster admin, I want to apply non-overridable allow rules to
@@ -36,6 +41,11 @@ traffic from pods in `monitoring-ns` for all ports and protocols.
3641

3742
![Alt text](./images/explicit_allow.png?raw=true "Explicit Allow")
3843

44+
??? success "Equivalent API Object"
45+
```yaml
46+
--8<-- "user-story-examples/user-story-2.yaml"
47+
```
48+
3949
#### Story 3: Explicitly Delegate traffic to existing K8s Network Policy
4050

4151
As a cluster admin, I want to explicitly delegate traffic so that it
@@ -49,6 +59,11 @@ delegated traffic the traffic will be allowed.
4959

5060
![Alt text](./images/delegation.png?raw=true "Delegate")
5161

62+
??? success "Equivalent API Object"
63+
```yaml
64+
--8<-- "user-story-examples/user-story-3.yaml"
65+
```
66+
5267
#### Story 4: Create and Isolate multiple tenants in a cluster
5368

5469
As a cluster admin, I want to build tenants in my cluster that are isolated from
@@ -60,6 +75,17 @@ all ingress traffic is denied to either tenant.
6075

6176
![Alt text](./images/tenants.png?raw=true "Tenants")
6277

78+
??? success "Equivalent API Object"
79+
```yaml
80+
--8<-- "user-story-examples/user-story-4-v1.yaml"
81+
```
82+
83+
This can also be expressed in the following way:
84+
85+
```yaml
86+
--8<-- "user-story-examples/user-story-4-v2.yaml"
87+
```
88+
6389
#### Story 5: Cluster Wide Default Guardrails
6490

6591
As a cluster admin I want to change the default security model for my cluster,
@@ -73,3 +99,8 @@ For Example: In the following diagram all Ingress traffic to every cluster
7399
resource is denied by a baseline deny rule.
74100

75101
![Alt text](./images/baseline.png?raw=true "Default Rules")
102+
103+
??? success "Equivalent API Object"
104+
```yaml
105+
--8<-- "user-story-examples/user-story-5.yaml"
106+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: policy.networking.k8s.io/v1alpha1
2+
kind: AdminNetworkPolicy
3+
metadata:
4+
name: cluster-wide-deny-example
5+
spec:
6+
priority: 10
7+
subject:
8+
namespaces:
9+
matchLabels:
10+
kubernetes.io/metadata.name: sensitive-ns
11+
ingress:
12+
- action: Deny
13+
from:
14+
- namespaces:
15+
namespaceSelector: {}
16+
name: select-all-deny-all
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: policy.networking.k8s.io/v1alpha1
2+
kind: AdminNetworkPolicy
3+
metadata:
4+
name: cluster-wide-allow-example
5+
spec:
6+
priority: 30
7+
subject:
8+
namespaces: {}
9+
ingress:
10+
- action: Allow
11+
from:
12+
- namespaces:
13+
namespaceSelector:
14+
matchLabels:
15+
kubernetes.io/metadata.name: monitoring-ns
16+
egress:
17+
- action: Allow
18+
to:
19+
- namespaces:
20+
namespaceSelector:
21+
matchlabels:
22+
kubernetes.io/metadata.name: kube-system
23+
pods:
24+
podSelector:
25+
matchlabels:
26+
app: kube-dns
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: policy.networking.k8s.io/v1alpha1
2+
kind: AdminNetworkPolicy
3+
metadata:
4+
name: pub-svc-delegate-example
5+
spec:
6+
priority: 20
7+
subject:
8+
namespaces: {}
9+
egress:
10+
- action: Pass
11+
to:
12+
- pods:
13+
namespaceSelector:
14+
matchLabels:
15+
kubernetes.io/metadata.name: bar-ns-1
16+
podSelector:
17+
matchLabels:
18+
app: svc-pub
19+
ports:
20+
- portNumber:
21+
protocol: TCP
22+
port: 8080

0 commit comments

Comments
 (0)