Skip to content

Commit 4ea2e3c

Browse files
committed
gpu-config: deploy the GPU configuration manager from ClusterPolicy
Signed-off-by: Henry Wang <henrwang@nvidia.com>
1 parent e764aa0 commit 4ea2e3c

19 files changed

Lines changed: 973 additions & 30 deletions

‎api/nvidia/v1/clusterpolicy_types.go‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ type ClusterPolicySpec struct {
9494
KataManager KataManagerSpec `json:"kataManager,omitempty"`
9595
// CCManager component spec
9696
CCManager CCManagerSpec `json:"ccManager,omitempty"`
97+
// GPUConfigManager component spec. The GPU configuration manager configures GPU settings
98+
// such as the power limit, locked clocks and ECC mode on each node from ConfigMaps in the
99+
// operator namespace, and applies them again after every driver load.
100+
GPUConfigManager GPUConfigManagerSpec `json:"gpuConfigManager,omitempty"`
97101
// HostPaths defines various paths on the host needed by GPU Operator components
98102
HostPaths HostPathsSpec `json:"hostPaths,omitempty"`
99103
// KataSandboxDevicePlugin component spec
@@ -1816,6 +1820,52 @@ type CCManagerSpec struct {
18161820
HostNetwork *bool `json:"hostNetwork,omitempty"`
18171821
}
18181822

1823+
// GPUConfigManagerSpec defines the properties for deploying the GPU configuration manager
1824+
type GPUConfigManagerSpec struct {
1825+
// Enabled indicates if deployment of the GPU configuration manager is enabled
1826+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
1827+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable GPU Configuration Manager deployment through GPU Operator"
1828+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
1829+
Enabled *bool `json:"enabled,omitempty"`
1830+
1831+
// Config selects the ConfigMap (key config.yaml) in the operator namespace with the GPU settings for all nodes.
1832+
// For a node, gpu-config-node-<node name> wins over gpu-config-pool-<pool>, which wins over this one.
1833+
// <pool> is derived from the node's nvidia.com/gpu-config.pool label (lowercased, "_" to "-"; values that
1834+
// can't name a ConfigMap are ignored); set POOL_LABEL_KEY in spec.gpuConfigManager.env to use another label.
1835+
// +kubebuilder:validation:Optional
1836+
Config *GPUConfigManagerConfigSpec `json:"config,omitempty"`
1837+
1838+
// Optional: Define resources requests and limits for each pod
1839+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
1840+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements"
1841+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements"
1842+
Resources *ResourceRequirements `json:"resources,omitempty"`
1843+
1844+
// Optional: List of environment variables. They are also passed to the gpu-config init container
1845+
// of the validator / DRA kubelet plugin, even when the manager is disabled. GPU_CONFIG_NO_MODULE_TIMEOUT
1846+
// sets how long that container waits for the nvidia module before letting allocators start (default 5m).
1847+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
1848+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables"
1849+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text"
1850+
Env []EnvVar `json:"env,omitempty"`
1851+
1852+
// HostNetwork indicates whether the GPU configuration manager pod uses the host's network namespace.
1853+
// +kubebuilder:validation:Optional
1854+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
1855+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA GPU Configuration Manager"
1856+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
1857+
HostNetwork *bool `json:"hostNetwork,omitempty"`
1858+
}
1859+
1860+
// GPUConfigManagerConfigSpec selects the ConfigMap with the GPU settings for all nodes
1861+
type GPUConfigManagerConfigSpec struct {
1862+
// Name of the ConfigMap in the operator namespace with the GPU settings for nodes
1863+
// that have no per-node or per-pool ConfigMap
1864+
// +kubebuilder:validation:Optional
1865+
// +kubebuilder:default:="gpu-config"
1866+
Name string `json:"name,omitempty"`
1867+
}
1868+
18191869
// VFIOManagerSpec defines the properties for deploying VFIO-PCI manager
18201870
type VFIOManagerSpec struct {
18211871
// Enabled indicates if deployment of VFIO Manager is enabled
@@ -2516,6 +2566,22 @@ func (c *CCManagerSpec) IsEnabled() bool {
25162566
return *c.Enabled
25172567
}
25182568

2569+
// IsEnabled returns true if the GPU configuration manager is enabled; it is disabled by default
2570+
func (g *GPUConfigManagerSpec) IsEnabled() bool {
2571+
if g.Enabled == nil {
2572+
return false
2573+
}
2574+
return *g.Enabled
2575+
}
2576+
2577+
// ClusterDocumentName returns the name of the ConfigMap with the GPU settings for all nodes
2578+
func (g *GPUConfigManagerSpec) ClusterDocumentName() string {
2579+
if g.Config == nil || g.Config.Name == "" {
2580+
return "gpu-config"
2581+
}
2582+
return g.Config.Name
2583+
}
2584+
25192585
// +kubebuilder:object:generate=false
25202586
type ConfigWithName interface {
25212587
GetName() string

‎api/nvidia/v1/zz_generated.deepcopy.go‎

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: nvidia-gpu-config-manager
5+
namespace: "FILLED BY THE OPERATOR"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
name: nvidia-gpu-config-manager
5+
namespace: "FILLED BY THE OPERATOR"
6+
rules:
7+
- apiGroups:
8+
- security.openshift.io
9+
resources:
10+
- securitycontextconstraints
11+
verbs:
12+
- use
13+
resourceNames:
14+
- privileged
15+
- apiGroups:
16+
- ""
17+
resources:
18+
- configmaps
19+
verbs:
20+
- list
21+
- watch
22+
- apiGroups:
23+
- apps
24+
resources:
25+
- daemonsets
26+
verbs:
27+
- list
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: nvidia-gpu-config-manager
5+
rules:
6+
- apiGroups:
7+
- ""
8+
resources:
9+
- nodes
10+
verbs:
11+
- get
12+
- patch
13+
- apiGroups:
14+
- ""
15+
resources:
16+
- pods
17+
verbs:
18+
- list
19+
- apiGroups:
20+
- resource.k8s.io
21+
resources:
22+
- resourceclaims
23+
verbs:
24+
- get
25+
- apiGroups:
26+
- resource.k8s.io
27+
resources:
28+
- resourceslices
29+
verbs:
30+
- list
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
name: nvidia-gpu-config-manager
5+
namespace: "FILLED BY THE OPERATOR"
6+
roleRef:
7+
apiGroup: rbac.authorization.k8s.io
8+
kind: Role
9+
name: nvidia-gpu-config-manager
10+
subjects:
11+
- kind: ServiceAccount
12+
name: nvidia-gpu-config-manager
13+
namespace: "FILLED BY THE OPERATOR"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: nvidia-gpu-config-manager
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: ClusterRole
8+
name: nvidia-gpu-config-manager
9+
subjects:
10+
- kind: ServiceAccount
11+
name: nvidia-gpu-config-manager
12+
namespace: "FILLED BY THE OPERATOR"
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: nvidia-gpu-config-manager
5+
namespace: "FILLED BY THE OPERATOR"
6+
labels:
7+
app: nvidia-gpu-config-manager
8+
app.kubernetes.io/component: nvidia-gpu-config-manager
9+
app.kubernetes.io/part-of: gpu-operator
10+
spec:
11+
selector:
12+
matchLabels:
13+
app: nvidia-gpu-config-manager
14+
template:
15+
metadata:
16+
labels:
17+
app: nvidia-gpu-config-manager
18+
app.kubernetes.io/component: nvidia-gpu-config-manager
19+
app.kubernetes.io/part-of: gpu-operator
20+
spec:
21+
nodeSelector:
22+
nvidia.com/gpu.deploy.gpu-config-manager: "true"
23+
tolerations:
24+
- key: nvidia.com/gpu
25+
operator: Exists
26+
effect: NoSchedule
27+
priorityClassName: system-node-critical
28+
serviceAccountName: nvidia-gpu-config-manager
29+
# Keep below k8s-driver-manager's 5-minute wait for this pod to terminate.
30+
terminationGracePeriodSeconds: 90
31+
initContainers:
32+
- name: driver-validation
33+
image: "FILLED BY THE OPERATOR"
34+
imagePullPolicy: IfNotPresent
35+
command: ['sh', '-c']
36+
args: ["nvidia-validator"]
37+
env:
38+
- name: WITH_WAIT
39+
value: "true"
40+
- name: COMPONENT
41+
value: driver
42+
- name: OPERATOR_NAMESPACE
43+
valueFrom:
44+
fieldRef:
45+
fieldPath: metadata.namespace
46+
securityContext:
47+
privileged: true
48+
seLinuxOptions:
49+
level: "s0"
50+
volumeMounts:
51+
- name: driver-install-dir
52+
mountPath: /run/nvidia/driver
53+
mountPropagation: HostToContainer
54+
- name: run-nvidia-validations
55+
mountPath: /run/nvidia/validations
56+
mountPropagation: Bidirectional
57+
- name: host-root
58+
mountPath: /host
59+
readOnly: true
60+
mountPropagation: HostToContainer
61+
- name: host-dev-char
62+
mountPath: /host-dev-char
63+
containers:
64+
- name: nvidia-gpu-config-manager
65+
image: "FILLED BY THE OPERATOR"
66+
imagePullPolicy: IfNotPresent
67+
command: ["gpu-config-manager"]
68+
env:
69+
- name: NODE_NAME
70+
valueFrom:
71+
fieldRef:
72+
fieldPath: spec.nodeName
73+
- name: OPERATOR_NAMESPACE
74+
valueFrom:
75+
fieldRef:
76+
fieldPath: metadata.namespace
77+
- name: GPU_CONFIG_STACK
78+
value: container
79+
- name: GPU_CONFIG_CLUSTER_DOCUMENT
80+
value: "FILLED BY THE OPERATOR"
81+
resources:
82+
requests:
83+
cpu: 100m
84+
memory: 200Mi
85+
securityContext:
86+
privileged: true
87+
runAsUser: 0
88+
volumeMounts:
89+
- name: run-nvidia-validations
90+
mountPath: /run/nvidia/validations
91+
mountPropagation: HostToContainer
92+
- name: driver-install-dir
93+
mountPath: /driver-root
94+
readOnly: true
95+
mountPropagation: HostToContainer
96+
- name: host-root
97+
mountPath: /host
98+
readOnly: true
99+
mountPropagation: HostToContainer
100+
volumes:
101+
- name: run-nvidia-validations
102+
hostPath:
103+
path: /run/nvidia/validations
104+
type: DirectoryOrCreate
105+
- name: driver-install-dir
106+
hostPath:
107+
path: /run/nvidia/driver
108+
type: DirectoryOrCreate
109+
- name: host-root
110+
hostPath:
111+
path: /
112+
- name: host-dev-char
113+
hostPath:
114+
path: /dev/char

‎assets/state-operator-validation/0500_daemonset.yaml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,31 @@ spec:
5656
mountPropagation: Bidirectional
5757
- name: host-dev-char
5858
mountPath: /host-dev-char
59+
# Waits until the GPU configuration manager has configured the GPUs for the current driver load.
60+
# Always rendered; the container checks at runtime whether the manager is enabled.
61+
- name: gpu-config
62+
image: "FILLED BY THE OPERATOR"
63+
command: ['sh', '-c']
64+
args: ["nvidia-validator"]
65+
env:
66+
- name: COMPONENT
67+
value: gpu-config
68+
- name: GPU_CONFIG_STACK
69+
value: container
70+
- name: NODE_NAME
71+
valueFrom:
72+
fieldRef:
73+
fieldPath: spec.nodeName
74+
- name: OPERATOR_NAMESPACE
75+
valueFrom:
76+
fieldRef:
77+
fieldPath: metadata.namespace
78+
securityContext:
79+
privileged: true
80+
volumeMounts:
81+
- name: run-nvidia-validations
82+
mountPath: /run/nvidia/validations
83+
mountPropagation: Bidirectional
5984
- name: toolkit-validation
6085
image: "FILLED BY THE OPERATOR"
6186
command: ['sh', '-c']

0 commit comments

Comments
 (0)