Skip to content

Commit 94759f5

Browse files
matmerrjaer-tsun
authored andcommitted
Azure NPM UT Test Refactor (#467)
* add policy yamls for test scenarios * fix policy names * fix jump entry
1 parent e6c4e77 commit 94759f5

18 files changed

+483
-597
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: deny-all-policy
5+
namespace: testnamespace
6+
spec:
7+
policyTypes:
8+
- Egress
9+
podSelector:
10+
matchLabels:
11+
app: "backend"
12+
egress:
13+
- {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: deny-all-policy
5+
namespace: testnamespace
6+
spec:
7+
policyTypes:
8+
- Ingress
9+
podSelector:
10+
matchLabels:
11+
app: "frontend"
12+
ingress:
13+
- from:
14+
- namespaceSelector: {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: allow-all-to-app-frontend
5+
namespace: testnamespace
6+
spec:
7+
podSelector:
8+
matchLabels:
9+
app: "frontend"
10+
ingress:
11+
- {}
12+
policyTypes:
13+
- Ingress
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: allow-backend-to-frontend-on-port-8000-policy
5+
namespace: testnamespace
6+
spec:
7+
policyTypes:
8+
- Ingress
9+
podSelector:
10+
matchLabels:
11+
app: frontend
12+
ingress:
13+
- from:
14+
- podSelector:
15+
matchLabels:
16+
app: backend
17+
ports:
18+
- port: 8000
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: allow-backend-to-frontend-on-port-53-policy
5+
namespace: testnamespace
6+
spec:
7+
policyTypes:
8+
- Egress
9+
podSelector:
10+
matchLabels:
11+
app: frontend
12+
egress:
13+
- ports:
14+
- protocol: TCP
15+
port: 53
16+
- protocol: UDP
17+
port: 53
18+
- to:
19+
- namespaceSelector: {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: deny-all-policy
5+
namespace: testnamespace
6+
spec:
7+
podSelector:
8+
matchLabels:
9+
app: "backend"
10+
ingress:
11+
- from:
12+
- podSelector:
13+
matchLabels:
14+
app: frontend
15+
policyTypes:
16+
- Ingress
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: allow-backdoor-policy
5+
namespace: dangerous
6+
spec:
7+
policyTypes:
8+
- Ingress
9+
podSelector:
10+
matchLabels:
11+
app: "backdoor"
12+
ingress:
13+
- from: []
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: allow-multiple-labels-to-multiple-labels
5+
namespace: acn
6+
spec:
7+
policyTypes:
8+
- Ingress
9+
podSelector:
10+
matchLabels:
11+
app: k8s
12+
team: aks
13+
ingress:
14+
- from:
15+
- podSelector:
16+
matchLabels:
17+
program: cni
18+
team: acn
19+
- podSelector:
20+
matchLabels:
21+
binary: cns
22+
group: container
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: deny-all-policy
5+
namespace: testnamespace
6+
spec:
7+
policyTypes:
8+
- Ingress
9+
podSelector:
10+
matchLabels:
11+
app: "frontend"
12+
ingress:
13+
- from:
14+
- podSelector:
15+
matchLabels:
16+
app: backend
17+
namespaceSelector:
18+
matchLabels:
19+
ns: dev
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: allow-ns-dev-to-app-frontend
5+
namespace: testnamespace
6+
spec:
7+
policyTypes:
8+
- Ingress
9+
podSelector:
10+
matchLabels:
11+
app: "frontend"
12+
ingress:
13+
- from:
14+
- namespaceSelector:
15+
matchLabels:
16+
namespace: "dev"
17+
matchExpressions:
18+
- key: namespace
19+
operator: NotIn
20+
values:
21+
- test0
22+
- test1

0 commit comments

Comments
 (0)