Skip to content

Commit

Permalink
Disable hostNetwork with DCGM Exporter when embedded hostengine is used
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamerla committed Dec 8, 2021
1 parent 42fdc42 commit 47319f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/state-dcgm-exporter/0810_scc.openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
allowHostDirVolumePlugin: true
allowHostIPC: false
allowHostNetwork: true
allowHostNetwork: false
allowHostPID: false
allowHostPorts: true
allowPrivilegeEscalation: true
Expand Down
1 change: 0 additions & 1 deletion assets/state-dcgm-exporter/0900_daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ spec:
priorityClassName: system-node-critical
serviceAccount: nvidia-dcgm-exporter
serviceAccountName: nvidia-dcgm-exporter
hostNetwork: true
initContainers:
- name: toolkit-validation
image: "FILLED BY THE OPERATOR"
Expand Down
7 changes: 7 additions & 0 deletions controllers/object_controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,8 @@ func TransformDCGMExporter(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpe
}
// check if DCGM hostengine is enabled as a separate Pod and setup env accordingly
if config.DCGM.IsEnabled() {
// enable hostNetwork for communication with external DCGM using NODE_IP
obj.Spec.Template.Spec.HostNetwork = true
// set DCGM host engine env. NODE_IP will be substituted during pod runtime
dcgmHostPort := int32(DCGMDefaultHostPort)
if config.DCGM.HostPort != 0 {
Expand Down Expand Up @@ -2403,6 +2405,11 @@ func SecurityContextConstraints(n ClusterPolicyController) (gpuv1.State, error)
obj.AllowHostIPC = true
}

// Allow hostNetwork only when a separate standalone DCGM engine is deployed for communication
if obj.Name == "nvidia-dcgm-exporter" && n.singleton.Spec.DCGM.IsEnabled() {
obj.AllowHostNetwork = true
}

if err := controllerutil.SetControllerReference(n.singleton, obj, n.rec.Scheme); err != nil {
return gpuv1.NotReady, err
}
Expand Down

0 comments on commit 47319f1

Please sign in to comment.