@@ -281,63 +281,85 @@ still an unsolved problem.
281
281
#### CSIStorageCapacity
282
282
283
283
```
284
- // CSIStorageCapacity stores the result of one CSI GetCapacity call for one
285
- // driver, one topology segment, and the parameters of one storage class.
284
+ // CSIStorageCapacity stores the result of one CSI GetCapacity call.
285
+ // For a given StorageClass, this describes the available capacity in a
286
+ // particular topology segment. This can be used when considering where to
287
+ // instantiate new PersistentVolumes.
288
+ //
289
+ // For example this can express things like:
290
+ // - StorageClass "standard" has "1234 GiB" available in "topology.kubernetes.io/zone=us-east1"
291
+ // - StorageClass "localssd" has "10 GiB" available in "kubernetes.io/hostname=knode-abc123"
292
+ //
293
+ // The following three cases all imply that no capacity is available for
294
+ // a certain combination:
295
+ // - no object exists with suitable topology and storage class name
296
+ // - such an object exists, but the capacity is unset
297
+ // - such an object exists, but the capacity is zero
298
+ //
299
+ // The producer of these objects can decide which approach is more suitable.
300
+ //
301
+ // They are consumed by the kube-scheduler if the CSIStorageCapacity beta feature gate
302
+ // is enabled there and a CSI driver opts into capacity-aware scheduling with
303
+ // CSIDriver.StorageCapacity.
286
304
type CSIStorageCapacity struct {
287
- metav1.TypeMeta
288
- // Standard object's metadata. The name has no particular meaning and just has to
289
- // meet the usual requirements (length, characters, unique). To ensure that
290
- // there are no conflicts with other CSI drivers on the cluster, the recommendation
291
- // is to use csisc-<uuid>.
292
- //
293
- // Objects are not namespaced.
294
- //
295
- // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
296
- // +optional
297
- metav1.ObjectMeta
298
-
299
- // Spec contains the fixed properties of one capacity value.
300
- Spec CSIStorageCapacitySpec
301
-
302
- // Status contains the properties that can change over time.
303
- Status CSIStorageCapacityStatus
304
- }
305
-
306
- // CSIStorageCapacitySpec contains the fixed properties of one capacity value.
307
- // one capacity value.
308
- type CSIStorageCapacitySpec struct {
309
- // The CSI driver that provides the storage.
310
- // This must be the string returned by the CSI GetPluginName() call.
311
- DriverName string
312
-
313
- // NodeTopology defines which nodes have access to the storage for which
314
- // capacity was reported. If not set, the storage is accessible from all
315
- // nodes in the cluster.
316
- // +optional
317
- NodeTopology *v1.NodeSelector
318
-
319
- // The storage class name of the StorageClass which provided the
320
- // additional parameters for the GetCapacity call.
321
- StorageClassName string
322
- }
323
-
324
- // CSIStorageCapacityStatus contains the properties that can change over time.
325
- type CSIStorageCapacityStatus struct {
326
- // AvailableCapacity is the value reported by the CSI driver in its GetCapacityResponse
327
- // for a GetCapacityRequest with topology and parameters that match the
328
- // CSIStorageCapacitySpec.
329
- //
330
- // The semantic is currently (CSI spec 1.2) defined as:
331
- // The available capacity, in bytes, of the storage that can be used
332
- // to provision volumes.
333
- AvailableCapacity *resource.Quantity
305
+ metav1.TypeMeta
306
+ // Standard object's metadata. The name has no particular meaning. It must be
307
+ // be a DNS subdomain (dots allowed, 253 characters). To ensure that
308
+ // there are no conflicts with other CSI drivers on the cluster, the recommendation
309
+ // is to use csisc-<uuid>, a generated name, or a reverse-domain name which ends
310
+ // with the unique CSI driver name.
311
+ //
312
+ // Objects are namespaced.
313
+ //
314
+ // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
315
+ // +optional
316
+ metav1.ObjectMeta
317
+
318
+ // NodeTopology defines which nodes have access to the storage
319
+ // for which capacity was reported. If not set, the storage is
320
+ // not accessible from any node in the cluster. If empty, the
321
+ // storage is accessible from all nodes. This field is
322
+ // immutable.
323
+ //
324
+ // +optional
325
+ NodeTopology *metav1.LabelSelector
326
+
327
+ // The name of the StorageClass that the reported capacity applies to.
328
+ // It must meet the same requirements as the name of a StorageClass
329
+ // object (non-empty, DNS subdomain). If that object no longer exists,
330
+ // the CSIStorageCapacity object is obsolete and should be removed by its
331
+ // creator.
332
+ // This field is immutable.
333
+ StorageClassName string
334
+
335
+ // Capacity is the value reported by the CSI driver in its GetCapacityResponse
336
+ // for a GetCapacityRequest with topology and parameters that match the
337
+ // previous fields.
338
+ //
339
+ // The semantic is currently (CSI spec 1.2) defined as:
340
+ // The available capacity, in bytes, of the storage that can be used
341
+ // to provision volumes. If not set, that information is currently
342
+ // unavailable and treated like zero capacity.
343
+ //
344
+ // +optional
345
+ Capacity *resource.Quantity
346
+
347
+ // MaximumVolumeSize is the value reported by the CSI driver in its GetCapacityResponse
348
+ // for a GetCapacityRequest with topology and parameters that match the
349
+ // previous fields.
350
+ //
351
+ // This is defined since CSI spec 1.4.0 as the largest size
352
+ // that may be used in a
353
+ // CreateVolumeRequest.capacity_range.required_bytes field to
354
+ // create a volume with the same parameters as those in
355
+ // GetCapacityRequest. The corresponding value in the Kubernetes
356
+ // API is ResourceRequirements.Requests in a volume claim.
357
+ //
358
+ // +optional
359
+ MaximumVolumeSize *resource.Quantity
334
360
}
335
361
```
336
362
337
- ` AvailableCapacity ` is a pointer because ` TotalCapacity ` and
338
- ` MaximumVolumeSize ` might be added later, in which case ` nil ` for
339
- ` AvailableCapacity ` will become allowed.
340
-
341
363
Compared to the alternatives with a single object per driver (see
342
364
[ ` CSIDriver.Status ` ] ( #csidriverstatus ) below) and one object per
343
365
topology (see [ ` CSIStoragePool ` ] ( #csistoragepool ) ), this approach has
0 commit comments