Skip to content

Commit 3668886

Browse files
authored
Merge pull request #708 from Gacko/surhz
chart: add network policies
2 parents a9d18cb + 245564a commit 3668886

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if .Values.controller.networkPolicy.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: NetworkPolicy
4+
metadata:
5+
name: {{ include "nvidia-dra-driver-gpu.name" . }}-controller
6+
namespace: {{ include "nvidia-dra-driver-gpu.namespace" . }}
7+
labels:
8+
{{- include "nvidia-dra-driver-gpu.labels" . | nindent 4 }}
9+
spec:
10+
podSelector:
11+
matchLabels:
12+
{{- include "nvidia-dra-driver-gpu.selectorLabels" (dict "context" . "componentName" "controller") | nindent 6 }}
13+
policyTypes:
14+
- Egress
15+
egress:
16+
# Some CNIs are not capable of controlling access to host network resources nor plain IP addresses,
17+
# as they are identity based and these resources are not being covered this way.
18+
#
19+
# Therefore, we cannot filter egress traffic by destination using native network policies and pod selectors.
20+
- ports:
21+
- protocol: TCP
22+
port: 443
23+
- protocol: TCP
24+
port: 6443
25+
{{- end }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if .Values.kubeletPlugin.networkPolicy.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: NetworkPolicy
4+
metadata:
5+
name: {{ include "nvidia-dra-driver-gpu.name" . }}-kubelet-plugin
6+
namespace: {{ include "nvidia-dra-driver-gpu.namespace" . }}
7+
labels:
8+
{{- include "nvidia-dra-driver-gpu.labels" . | nindent 4 }}
9+
spec:
10+
podSelector:
11+
matchLabels:
12+
{{- include "nvidia-dra-driver-gpu.selectorLabels" (dict "context" . "componentName" "kubelet-plugin") | nindent 6 }}
13+
policyTypes:
14+
- Egress
15+
egress:
16+
# Some CNIs are not capable of controlling access to host network resources nor plain IP addresses,
17+
# as they are identity based and these resources are not being covered this way.
18+
#
19+
# Therefore, we cannot filter egress traffic by destination using native network policies and pod selectors.
20+
- ports:
21+
- protocol: TCP
22+
port: 443
23+
- protocol: TCP
24+
port: 6443
25+
{{- end }}

deployments/helm/nvidia-dra-driver-gpu/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ controller:
190190
- matchExpressions:
191191
- key: "node-role.kubernetes.io/control-plane"
192192
operator: "Exists"
193+
# Network policy settings
194+
networkPolicy:
195+
# If the network policy is enabled or not
196+
enabled: false
193197

194198
kubeletPlugin:
195199
priorityClassName: "system-node-critical"
@@ -245,3 +249,7 @@ kubeletPlugin:
245249
operator: In
246250
values:
247251
- "true"
252+
# Network policy settings
253+
networkPolicy:
254+
# If the network policy is enabled or not
255+
enabled: false

0 commit comments

Comments
 (0)