Skip to content

Commit dcd8ad8

Browse files
anik120Per G. da Silva
and
Per G. da Silva
authored
✨ Introduce NetworkPolicy for core component workloads. (#3579)
* Introduce NetworkPolicy for core component workloads. [RFC](https://docs.google.com/document/d/10MZ4t2XgRydGa-NRs4uXFNVoTHH9SPKd7mV9IwT_i7M/edit?usp=sharing) Signed-off-by: Per G. da Silva <[email protected]> * specify namespace with selectors * Fix formatting Signed-off-by: Per G. da Silva <[email protected]> * template network policy Signed-off-by: Per G. da Silva <[email protected]> * restrict kube-apiserver and dns traffic Signed-off-by: Per G. da Silva <[email protected]> * Address reviewer comments Signed-off-by: Per G. da Silva <[email protected]> --------- Signed-off-by: Per G. da Silva <[email protected]> Co-authored-by: Per G. da Silva <[email protected]>
1 parent 8723097 commit dcd8ad8

5 files changed

+104
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: default-deny-all-traffic
5+
namespace: {{ .Values.namespace }}
6+
spec:
7+
podSelector: { }
8+
policyTypes:
9+
- Ingress
10+
- Egress
11+
---
12+
apiVersion: networking.k8s.io/v1
13+
kind: NetworkPolicy
14+
metadata:
15+
name: olm-operator
16+
namespace: {{ .Values.namespace }}
17+
spec:
18+
podSelector:
19+
matchLabels:
20+
app: olm-operator
21+
ingress:
22+
- {{ .Values.networkPolicy.metrics | toYaml | nindent 6 | trimSuffix "\n" }}
23+
egress:
24+
- {{ .Values.networkPolicy.kubeAPIServer | toYaml | nindent 6 | trimSuffix "\n" }}
25+
- {{ .Values.networkPolicy.dns | toYaml | nindent 6 | trimSuffix "\n" }}
26+
policyTypes:
27+
- Ingress
28+
- Egress
29+
---
30+
apiVersion: networking.k8s.io/v1
31+
kind: NetworkPolicy
32+
metadata:
33+
name: catalog-operator
34+
namespace: {{ .Values.namespace }}
35+
spec:
36+
podSelector:
37+
matchLabels:
38+
app: catalog-operator
39+
ingress:
40+
- {{ .Values.networkPolicy.metrics | toYaml | nindent 6 | trimSuffix "\n" }}
41+
egress:
42+
- {{ .Values.networkPolicy.kubeAPIServer | toYaml | nindent 6 | trimSuffix "\n" }}
43+
- {{ .Values.networkPolicy.dns | toYaml | nindent 6 | trimSuffix "\n" }}
44+
- ports: # This is another distinct rule in the egress list
45+
- protocol: TCP
46+
port: {{ .Values.catalogGrpcPodPort }}
47+
policyTypes:
48+
- Ingress
49+
- Egress
50+
---
51+
apiVersion: networking.k8s.io/v1
52+
kind: NetworkPolicy
53+
metadata:
54+
name: packageserver
55+
namespace: {{ .Values.namespace }}
56+
spec:
57+
podSelector:
58+
matchLabels:
59+
app: packageserver
60+
ingress:
61+
- ports:
62+
- protocol: TCP
63+
port: {{ .Values.package.service.internalPort }}
64+
egress:
65+
- {{ .Values.networkPolicy.dns | toYaml | nindent 6 | trimSuffix "\n" }}
66+
- ports:
67+
- protocol: TCP
68+
port: {{ .Values.catalogGrpcPodPort }}
69+
policyTypes:
70+
- Ingress
71+
- Egress
72+
---
73+
apiVersion: networking.k8s.io/v1
74+
kind: NetworkPolicy
75+
metadata:
76+
name: default-allow-all
77+
namespace: {{ .Values.operator_namespace }}
78+
spec:
79+
podSelector: { }
80+
policyTypes:
81+
- Ingress
82+
- Egress
83+
ingress:
84+
- { }
85+
egress:
86+
- { }

deploy/chart/values.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ writeStatusName: '""'
1919
imagestream: false
2020
debug: false
2121
installType: upstream
22+
catalogGrpcPodPort: 50051
23+
2224
olm:
2325
replicaCount: 1
2426
image:
@@ -75,3 +77,19 @@ package:
7577
monitoring:
7678
enabled: false
7779
namespace: monitoring
80+
81+
networkPolicy:
82+
dns:
83+
ports:
84+
- protocol: TCP
85+
port: 53
86+
- protocol: UDP
87+
port: 53
88+
kubeAPIServer:
89+
ports:
90+
- protocol: TCP
91+
port: 6443
92+
metrics:
93+
ports:
94+
- protocol: TCP
95+
port: metrics

0 commit comments

Comments
 (0)