Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions npm/testpolicies/allow-all-from-app-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: testnamespace
spec:
policyTypes:
- Egress
podSelector:
matchLabels:
app: "backend"
egress:
- {}
14 changes: 14 additions & 0 deletions npm/testpolicies/allow-all-ns-to-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: testnamespace
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app: "frontend"
ingress:
- from:
- namespaceSelector: {}
13 changes: 13 additions & 0 deletions npm/testpolicies/allow-all-to-app-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-all-to-app-frontend
namespace: testnamespace
spec:
podSelector:
matchLabels:
app: "frontend"
ingress:
- {}
policyTypes:
- Ingress
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-backend-to-frontend-on-port-8000-policy
namespace: testnamespace
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app: frontend
ingress:
- from:
- podSelector:
matchLabels:
app: backend
ports:
- port: 8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-backend-to-frontend-on-port-53-policy
namespace: testnamespace
spec:
policyTypes:
- Egress
podSelector:
matchLabels:
app: frontend
egress:
- ports:
- protocol: TCP
port: 53
- protocol: UDP
port: 53
- to:
- namespaceSelector: {}
16 changes: 16 additions & 0 deletions npm/testpolicies/allow-backend-to-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: testnamespace
spec:
podSelector:
matchLabels:
app: "backend"
ingress:
- from:
- podSelector:
matchLabels:
app: frontend
policyTypes:
- Ingress
13 changes: 13 additions & 0 deletions npm/testpolicies/allow-internal-and-external.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-backdoor-policy
namespace: dangerous
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app: "backdoor"
ingress:
- from: []
22 changes: 22 additions & 0 deletions npm/testpolicies/allow-multiple-labels-to-multiple-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-multiple-labels-to-multiple-labels
namespace: acn
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app: k8s
team: aks
ingress:
- from:
- podSelector:
matchLabels:
program: cni
team: acn
- podSelector:
matchLabels:
binary: cns
group: container
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: testnamespace
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app: "frontend"
ingress:
- from:
- podSelector:
matchLabels:
app: backend
namespaceSelector:
matchLabels:
ns: dev
22 changes: 22 additions & 0 deletions npm/testpolicies/allow-ns-dev-to-app-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-ns-dev-to-app-frontend
namespace: testnamespace
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app: "frontend"
ingress:
- from:
- namespaceSelector:
matchLabels:
namespace: "dev"
matchExpressions:
- key: namespace
operator: NotIn
values:
- test0
- test1
15 changes: 15 additions & 0 deletions npm/testpolicies/allow-ns-test-namespace-to-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: testnamespace
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app: "frontend"
ingress:
- from:
- podSelector:
matchLabels: {}
34 changes: 34 additions & 0 deletions npm/testpolicies/complex-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: k8s-example-policy
namespace: default
spec:
podSelector:
matchLabels:
role: db
policyTypes:
- Ingress
- Egress
ingress:
- from:
- ipBlock:
cidr: 172.17.0.0/16
except:
- 172.17.1.0/24
- namespaceSelector:
matchLabels:
project: myproject
- podSelector:
matchLabels:
role: frontend
ports:
- protocol: TCP
port: 6379
egress:
- to:
- ipBlock:
cidr: 10.0.0.0/24
ports:
- protocol: TCP
port: 5978
11 changes: 11 additions & 0 deletions npm/testpolicies/deny-all-from-app-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: testnamespace
spec:
policyTypes:
- Egress
podSelector:
matchLabels:
app: "backend"
10 changes: 10 additions & 0 deletions npm/testpolicies/deny-all-from-ns-unsafe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: unsafe
spec:
policyTypes:
- Egress
podSelector: {}
egress: []
10 changes: 10 additions & 0 deletions npm/testpolicies/deny-all-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: testnamespace
spec:
policyTypes:
- Ingress
podSelector: {}
ingress: []
11 changes: 11 additions & 0 deletions npm/testpolicies/deny-all-to-app-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: testnamespace
spec:
podSelector:
matchLabels:
app: "frontend"
policyTypes:
- Ingress
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-policy
namespace: testnamespace
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app: "frontend"
matchExpressions:
- key: k0
operator: DoesNotExist
values: []
- key: k1
operator: In
values:
- v0
- v1
ingress:
- from:
- namespaceSelector: {}
Loading