-
Notifications
You must be signed in to change notification settings - Fork 1
/
jenkins-network-policies.yaml
83 lines (83 loc) · 1.56 KB
/
jenkins-network-policies.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#Default deny all traffic
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
namespace: jenkins
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
---
#Allow access to DNS on all pods, DNS is located on each nodde and also using the default kube-system service
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-dns-access
namespace: jenkins
spec:
podSelector:
matchLabels: {}
egress:
- to:
- namespaceSelector:
matchLabels:
name: kube-system
- ipBlock:
cidr: 192.168.121.0/24
- ipBlock:
cidr: 10.96.0.10/32
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
- protocol: TCP
port: 9253
- protocol: TCP
port: 9153
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-to-jenkins-port8080
namespace: jenkins
spec:
podSelector:
matchLabels:
app.kubernetes.io/instance: jenkins
ingress:
- ports:
- port: 8080
- port: 50000
egress:
- to:
- ipBlock:
cidr: 192.168.121.0/24
ports:
- protocol: TCP
port: 22
---
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: only-allow-internet
namespace: jenkins
spec:
podSelector:
matchLabels:
app.kubernetes.io/instance: jenkins
egress:
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
- 192.168.0.0/16
- 172.16.0.0/20
ports:
- protocol: TCP
port: 443
- protocol: TCP
port: 80