• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NVIDIA / gpu-operator / 29513807383

16 Jul 2026 03:58PM UTC coverage: 32.688% (+0.9%) from 31.812%
29513807383

Pull #2571

github

karthikvetrivel
Add golden render tests for GPUCluster operand manifests

Signed-off-by: Karthik Vetrivel <kvetrivel@nvidia.com>
Pull Request #2571: Add GPUCluster CRD and controller for DRA-based stack

513 of 1343 new or added lines in 31 files covered. (38.2%)

5 existing lines in 4 files now uncovered.

4663 of 14265 relevant lines covered (32.69%)

0.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/api/nvidia/v1alpha1/gpucluster_types.go
1
/**
2
# Copyright (c) NVIDIA CORPORATION.  All rights reserved.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
**/
16

17
package v1alpha1
18

19
import (
20
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21

22
        nvidiav1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1"
23
)
24

25
const (
26
        GPUClusterCRDName = "GPUCluster"
27
)
28

29
const (
30
        // Ignored marks a duplicate GPUCluster that the singleton controller does not reconcile.
31
        Ignored State = "ignored"
32
)
33

34
// NOTE: json tags are required.  Any new fields you add must have json tags for the fields to be serialized.
35

36
// GPUClusterSpec defines the desired state of GPUCluster, the DRA-based
37
// software-enablement stack. Unlike ClusterPolicy, it does not manage the NVIDIA driver
38
// or the device-plugin; the driver is installed separately (host-installed or via an
39
// NVIDIADriver CR) and GPUCluster waits for driver readiness before proceeding.
40
type GPUClusterSpec struct {
41
        // DRADriver defines the spec for the NVIDIA DRA driver stack (gpus + computeDomains).
42
        DRADriver DRADriverSpec `json:"draDriver"`
43

44
        // DCGM defines the spec for the standalone NVIDIA DCGM hostengine. Disabled by default;
45
        // when disabled, dcgm-exporter uses its embedded nv-hostengine. NOTE: the reused enabled
46
        // field carries no server-side default and its IsEnabled() treats nil as enabled, so the
47
        // controller must default nil enabled to disabled here.
48
        DCGM *nvidiav1.DCGMSpec `json:"dcgm,omitempty"`
49

50
        // DCGMExporter defines the spec for NVIDIA DCGM Exporter. Enabled by default, but the
51
        // reused enabled field carries no server-side default; the controller defaults nil enabled.
52
        DCGMExporter *nvidiav1.DCGMExporterSpec `json:"dcgmExporter,omitempty"`
53

54
        // HostPaths defines the host paths used in host-path volumes for various components.
55
        HostPaths nvidiav1.HostPathsSpec `json:"hostPaths,omitempty"`
56

57
        // Daemonsets defines the common configuration applied to all DaemonSets deployed
58
        // by the GPUCluster controller.
59
        Daemonsets nvidiav1.DaemonsetsSpec `json:"daemonsets,omitempty"`
60
}
61

62
// DRADriverSpec defines the spec for the NVIDIA DRA driver stack. There is no top-level
63
// enabled toggle; the gpus capability is always deployed and computeDomains has its own
64
// enabled field.
65
type DRADriverSpec struct {
66
        // NVIDIA DRA driver image repository
67
        Repository string `json:"repository,omitempty"`
68

69
        // NVIDIA DRA driver image name
70
        // +kubebuilder:validation:Pattern=^[a-zA-Z0-9\-]+$
71
        Image string `json:"image,omitempty"`
72

73
        // NVIDIA DRA driver image tag
74
        Version string `json:"version,omitempty"`
75

76
        // Image pull policy
77
        ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
78

79
        // Image pull secrets
80
        ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
81

82
        // FeatureGates is a map of feature gate names to a boolean enabling or disabling each.
83
        // It is rendered as the FEATURE_GATES environment variable on the DRA driver containers.
84
        FeatureGates map[string]bool `json:"featureGates,omitempty"`
85

86
        // GPUs configures the gpu.nvidia.com capability of the DRA driver.
87
        GPUs DRADriverGPUsSpec `json:"gpus,omitempty"`
88

89
        // ComputeDomains configures the compute-domain capability of the DRA driver.
90
        ComputeDomains DRADriverComputeDomainsSpec `json:"computeDomains,omitempty"`
91
}
92

93
// IsComputeDomainsEnabled returns true if the computeDomains capability of the DRA driver is enabled.
NEW
94
func (d *DRADriverSpec) IsComputeDomainsEnabled() bool {
×
NEW
95
        return d.ComputeDomains.Enabled != nil && *d.ComputeDomains.Enabled
×
NEW
96
}
×
97

98
// DRADriverGPUsSpec configures the gpus capability of the DRA driver. It maps onto the
99
// gpus container of the upstream kubelet-plugin DaemonSet. The capability is always
100
// deployed; there is no enabled toggle.
101
type DRADriverGPUsSpec struct {
102
        // KubeletPlugin configures the kubelet-plugin workload for the gpus capability.
103
        KubeletPlugin DRADriverKubeletPluginSpec `json:"kubeletPlugin,omitempty"`
104
}
105

106
// DRADriverComputeDomainsSpec configures the computeDomains capability of the DRA driver.
107
// The kubeletPlugin maps onto the computeDomains container of the upstream kubelet-plugin
108
// DaemonSet; the controller is a separate Deployment.
109
type DRADriverComputeDomainsSpec struct {
110
        // Enabled indicates if the computeDomains capability of the DRA driver is enabled.
111
        // +kubebuilder:default=true
112
        Enabled *bool `json:"enabled,omitempty"`
113

114
        // Controller configures the compute-domain controller Deployment.
115
        Controller DRADriverControllerSpec `json:"controller,omitempty"`
116

117
        // KubeletPlugin configures the kubelet-plugin workload for the computeDomains capability.
118
        KubeletPlugin DRADriverKubeletPluginSpec `json:"kubeletPlugin,omitempty"`
119
}
120

121
// DRADriverKubeletPluginSpec configures a DRA driver kubelet-plugin container. The gpus and
122
// computeDomains blocks map onto the two containers of a single kubelet-plugin DaemonSet.
123
// Scheduling is opinionated and not configurable here.
124
type DRADriverKubeletPluginSpec struct {
125
        // Optional: List of environment variables
126
        Env []nvidiav1.EnvVar `json:"env,omitempty"`
127

128
        // Optional: Define resources requests and limits for the kubelet-plugin container
129
        Resources *nvidiav1.ResourceRequirements `json:"resources,omitempty"`
130

131
        // HealthcheckPort is the port of the container's gRPC health service, checked by the
132
        // startup and liveness probes. Set to a negative value to disable the probes.
133
        HealthcheckPort *int32 `json:"healthcheckPort,omitempty"`
134
}
135

136
// DRADriverControllerSpec defines configuration for the compute-domain controller Deployment.
137
// Scheduling is opinionated and not configurable here.
138
type DRADriverControllerSpec struct {
139
        // Optional: List of environment variables
140
        Env []nvidiav1.EnvVar `json:"env,omitempty"`
141

142
        // Optional: Define resources requests and limits for the controller container
143
        Resources *nvidiav1.ResourceRequirements `json:"resources,omitempty"`
144
}
145

146
// GPUClusterStatus defines the observed state of GPUCluster
147
type GPUClusterStatus struct {
148
        // +kubebuilder:validation:Enum=ignored;ready;notReady;disabled
149
        // State indicates the status of the GPUCluster instance
150
        State State `json:"state"`
151
        // Namespace indicates the namespace in which the operator and operands are installed
152
        Namespace string `json:"namespace,omitempty"`
153
        // Conditions is a list of conditions representing the GPUCluster's current state.
154
        Conditions []metav1.Condition `json:"conditions,omitempty"`
155
}
156

157
// +genclient
158
// +genclient:nonNamespaced
159
//+kubebuilder:object:root=true
160
//+kubebuilder:subresource:status
161
//+kubebuilder:resource:scope=Cluster,shortName={"gc"}
162
//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0
163
//+kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,priority=0
164

165
// GPUCluster is the Schema for the gpuclusters API
166
type GPUCluster struct {
167
        metav1.TypeMeta   `json:",inline"`
168
        metav1.ObjectMeta `json:"metadata,omitempty"`
169

170
        Spec   GPUClusterSpec   `json:"spec,omitempty"`
171
        Status GPUClusterStatus `json:"status,omitempty"`
172
}
173

174
//+kubebuilder:object:root=true
175

176
// GPUClusterList contains a list of GPUCluster
177
type GPUClusterList struct {
178
        metav1.TypeMeta `json:",inline"`
179
        metav1.ListMeta `json:"metadata,omitempty"`
180
        Items           []GPUCluster `json:"items"`
181
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc