Skip to content

Commit 1f3a55b

Browse files
committed
Update the user stories to ClusterNetworkPolicy
Fixes the user-story-*.yamls
1 parent de1b4e9 commit 1f3a55b

File tree

7 files changed

+60
-49
lines changed

7 files changed

+60
-49
lines changed

site-src/user-stories.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@
33
**ALL** Network Policy API resources and future API developments should start with
44
a **well-defined** and **intentional** user story(s).
55

6-
## AdminNetworkPolicy + BaselineAdminNetworkPolicy
6+
## ClusterNetworkPolicy (CNP)
77

8-
### v1alpha1 User Stories
8+
### User Stories
9+
10+
The following user stories drive the concepts for the adminstrative resources.
11+
Discussions on the user stories can be found here:
12+
13+
* [API KEP](https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/2091-admin-network-policy)
14+
* [KEP PR](https://github.com/kubernetes/enhancements/pull/2522)
915

10-
The following user stories drive the concepts for the `v1alpha1` version of the
11-
ANP and BANP resources. More information on how the community ended up here
12-
can be found in the [API KEP](https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/2091-admin-network-policy)
13-
and in the accompanying [KEP PR](https://github.com/kubernetes/enhancements/pull/2522)
1416

1517
#### Story 1: Deny traffic at a cluster level
1618

1719
As a cluster admin, I want to apply non-overridable deny rules
1820
to certain pod(s) and(or) Namespace(s) that isolate the selected
1921
resources from all other cluster internal traffic.
2022

21-
For Example: In this diagram there is a AdminNetworkPolicy applied to the
22-
`sensitive-ns` denying ingress from all other in-cluster resources for all
23-
ports and protocols.
23+
For Example: In this diagram there is a `ClusterNetworkPolicy` in the `Admin`
24+
tier applied to the `sensitive-ns` denying ingress from all other in-cluster
25+
resources for all ports and protocols.
2426

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

@@ -35,9 +37,10 @@ As a cluster admin, I want to apply non-overridable allow rules to
3537
certain pods(s) and(or) Namespace(s) that enable the selected resources
3638
to communicate with all other cluster internal entities.
3739

38-
For Example: In this diagram there is a AdminNetworkPolicy applied to every
39-
namespace in the cluster allowing egress traffic to `kube-dns` pods, and ingress
40-
traffic from pods in `monitoring-ns` for all ports and protocols.
40+
For Example: In this diagram there is a `ClusterNetworkPolicy` in the `Admin`
41+
tier applied to every namespace in the cluster allowing egress traffic to
42+
`kube-dns` pods, and ingress traffic from pods in `monitoring-ns` for all ports
43+
and protocols.
4144

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

@@ -52,10 +55,10 @@ As a cluster admin, I want to explicitly delegate traffic so that it
5255
skips any remaining cluster network policies and is handled by standard
5356
namespace scoped network policies.
5457

55-
For Example: In the diagram below egress traffic destined for the service svc-pub
56-
in namespace bar-ns-1 on TCP port 8080 is delegated to the k8s network policies
57-
implemented in foo-ns-1 and foo-ns-2. If no k8s network policies touch the
58-
delegated traffic the traffic will be allowed.
58+
For Example: In the diagram below egress traffic destined for the service
59+
`svc-pub` in namespace `bar-ns-1` on TCP port 8080 is delegated to the k8s
60+
network policies implemented in `foo-ns-1` and `foo-ns-2`. If no k8s network
61+
policies match the delegated traffic, the traffic will be allowed.
5962

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

@@ -66,6 +69,8 @@ delegated traffic the traffic will be allowed.
6669

6770
#### Story 4: Create and Isolate multiple tenants in a cluster
6871

72+
(Currently not implementable)
73+
6974
As a cluster admin, I want to build tenants in my cluster that are isolated from
7075
each other by default. Tenancy may be modeled as 1:1, where 1 tenant is mapped
7176
to a single Namespace, or 1:n, where a single tenant may own more than 1 Namespace.
@@ -93,7 +98,7 @@ so that all intra-cluster traffic (except for certain essential traffic) is
9398
blocked by default. Namespace owners will need to use NetworkPolicies to
9499
explicitly allow known traffic. This follows a whitelist model which is
95100
familiar to many security administrators, and similar
96-
to how [kubernetes suggests network policy be used](https://kubernetes.io/docs/concepts/services-networking/network-policies/#default-policies).
101+
to how [kubernetes suggests network policy be used][k8s-default-policies].
97102

98103
For Example: In the following diagram all Ingress traffic to every cluster
99104
resource is denied by a baseline deny rule.
@@ -104,3 +109,5 @@ resource is denied by a baseline deny rule.
104109
```yaml
105110
--8<-- "user-story-examples/user-story-5.yaml"
106111
```
112+
113+
[k8s-default-policies]: https://kubernetes.io/docs/concepts/services-networking/network-policies/#default-policies
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
apiVersion: policy.networking.k8s.io/v1alpha1
2-
kind: AdminNetworkPolicy
1+
apiVersion: policy.networking.k8s.io/v1alpha2
2+
kind: ClusterNetworkPolicy
33
metadata:
44
name: cluster-wide-deny-example
55
spec:
6+
tier: Admin
67
priority: 10
78
subject:
89
namespaces:
@@ -12,5 +13,5 @@ spec:
1213
- action: Deny
1314
from:
1415
- namespaces:
15-
namespaceSelector: {}
16+
matchLabels: {} # Match all namespaces.
1617
name: select-all-deny-all
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
apiVersion: policy.networking.k8s.io/v1alpha1
2-
kind: AdminNetworkPolicy
1+
apiVersion: policy.networking.k8s.io/v1alpha2
2+
kind: ClusterNetworkPolicy
33
metadata:
44
name: cluster-wide-allow-example
55
spec:
6+
tier: Admin
67
priority: 30
78
subject:
89
namespaces: {}
910
ingress:
10-
- action: Allow
11+
- action: Accept
1112
from:
1213
- namespaces:
13-
namespaceSelector:
14-
matchLabels:
15-
kubernetes.io/metadata.name: monitoring-ns
14+
matchLabels:
15+
kubernetes.io/metadata.name: monitoring-ns
1616
egress:
17-
- action: Allow
18-
to:
19-
- pods:
20-
namespaces:
21-
namespaceSelector:
22-
matchlabels:
23-
kubernetes.io/metadata.name: kube-system
24-
podSelector:
25-
matchlabels:
26-
app: kube-dns
17+
- action: Accept
18+
name: allow-kube-dns-egress
19+
to:
20+
- pods:
21+
namespaceSelector:
22+
matchLabels:
23+
kubernetes.io/metadata.name: kube-system
24+
podSelector:
25+
matchLabels:
26+
app: kube-dns

site-src/user-story-examples/user-story-3.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
apiVersion: policy.networking.k8s.io/v1alpha1
2-
kind: AdminNetworkPolicy
1+
apiVersion: policy.networking.k8s.io/v1alpha2
2+
kind: ClusterNetworkPolicy
33
metadata:
44
name: pub-svc-delegate-example
55
spec:
6+
tier: Admin
67
priority: 20
78
subject:
89
namespaces: {}
910
egress:
10-
- action: Pass
11+
- action: Pass # to be handled by NetworkPolicy.
1112
to:
1213
- pods:
1314
namespaceSelector:

site-src/user-story-examples/user-story-4-v1.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11

2-
apiVersion: policy.networking.k8s.io/v1alpha1
3-
kind: AdminNetworkPolicy
2+
apiVersion: policy.networking.k8s.io/v1alpha2
3+
kind: ClusterNetworkPolicy
44
metadata:
55
name: tenant-creation-example
66
spec:
7+
tier: Admin
78
priority: 50
89
subject:
910
namespaces:

site-src/user-story-examples/user-story-4-v2.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
apiVersion: policy.networking.k8s.io/v1alpha1
2-
kind: AdminNetworkPolicy
1+
apiVersion: policy.networking.k8s.io/v1alpha2
2+
kind: ClusterNetworkPolicy
33
metadata:
44
name: tenant-creation-example
55
spec:
6+
tier: Admin
67
priority: 50
78
subject:
89
namespaces:
@@ -15,5 +16,4 @@ spec:
1516
# See https://network-policy-api.sigs.k8s.io/npeps/npep-122/ for more details.
1617
- action: Deny # Deny everything else other than same tenant traffic
1718
from:
18-
- namespaces:
19-
namespaceSelector: {}
19+
- namespaces: {}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
apiVersion: policy.networking.k8s.io/v1alpha1
2-
kind: BaselineAdminNetworkPolicy
1+
apiVersion: policy.networking.k8s.io/v1alpha2
2+
kind: ClusterNetworkPolicy
33
metadata:
44
name: default
55
spec:
6+
tier: Baseline
7+
priority: 10
68
subject:
79
namespaces: {}
810
ingress:
911
- action: Deny # zero-trust cluster default security posture
1012
from:
11-
- namespaces:
12-
namespaceSelector: {}
13+
- namespaces: {}

0 commit comments

Comments
 (0)