1 /* 2 Copyright 2017 The Kubernetes Authors. 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 v1 18 19 import ( 20 v1 "k8s.io/api/core/v1" 21 "k8s.io/apimachinery/pkg/api/resource" 22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 ) 24 25 // +genclient 26 // +genclient:nonNamespaced 27 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 28 29 // StorageClass describes the parameters for a class of storage for 30 // which PersistentVolumes can be dynamically provisioned. 31 // 32 // StorageClasses are non-namespaced; the name of the storage class 33 // according to etcd is in ObjectMeta.Name. 34 type StorageClass struct { 35 metav1.TypeMeta `json:",inline"` 36 37 // Standard object's metadata. 38 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 39 // +optional 40 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 41 42 // provisioner indicates the type of the provisioner. 43 Provisioner string `json:"provisioner" protobuf:"bytes,2,opt,name=provisioner"` 44 45 // parameters holds the parameters for the provisioner that should 46 // create volumes of this storage class. 47 // +optional 48 Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"` 49 50 // reclaimPolicy controls the reclaimPolicy for dynamically provisioned PersistentVolumes of this storage class. 51 // Defaults to Delete. 52 // +optional 53 ReclaimPolicy *v1.PersistentVolumeReclaimPolicy `json:"reclaimPolicy,omitempty" protobuf:"bytes,4,opt,name=reclaimPolicy,casttype=k8s.io/api/core/v1.PersistentVolumeReclaimPolicy"` 54 55 // mountOptions controls the mountOptions for dynamically provisioned PersistentVolumes of this storage class. 56 // e.g. ["ro", "soft"]. Not validated - 57 // mount of the PVs will simply fail if one is invalid. 58 // +optional 59 // +listType=atomic 60 MountOptions []string `json:"mountOptions,omitempty" protobuf:"bytes,5,opt,name=mountOptions"` 61 62 // allowVolumeExpansion shows whether the storage class allow volume expand. 63 // +optional 64 AllowVolumeExpansion *bool `json:"allowVolumeExpansion,omitempty" protobuf:"varint,6,opt,name=allowVolumeExpansion"` 65 66 // volumeBindingMode indicates how PersistentVolumeClaims should be 67 // provisioned and bound. When unset, VolumeBindingImmediate is used. 68 // This field is only honored by servers that enable the VolumeScheduling feature. 69 // +optional 70 VolumeBindingMode *VolumeBindingMode `json:"volumeBindingMode,omitempty" protobuf:"bytes,7,opt,name=volumeBindingMode"` 71 72 // allowedTopologies restrict the node topologies where volumes can be dynamically provisioned. 73 // Each volume plugin defines its own supported topology specifications. 74 // An empty TopologySelectorTerm list means there is no topology restriction. 75 // This field is only honored by servers that enable the VolumeScheduling feature. 76 // +optional 77 // +listType=atomic 78 AllowedTopologies []v1.TopologySelectorTerm `json:"allowedTopologies,omitempty" protobuf:"bytes,8,rep,name=allowedTopologies"` 79 } 80 81 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 82 83 // StorageClassList is a collection of storage classes. 84 type StorageClassList struct { 85 metav1.TypeMeta `json:",inline"` 86 87 // Standard list metadata 88 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 89 // +optional 90 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 91 92 // items is the list of StorageClasses 93 Items []StorageClass `json:"items" protobuf:"bytes,2,rep,name=items"` 94 } 95 96 // VolumeBindingMode indicates how PersistentVolumeClaims should be bound. 97 // +enum 98 type VolumeBindingMode string 99 100 const ( 101 // VolumeBindingImmediate indicates that PersistentVolumeClaims should be 102 // immediately provisioned and bound. This is the default mode. 103 VolumeBindingImmediate VolumeBindingMode = "Immediate" 104 105 // VolumeBindingWaitForFirstConsumer indicates that PersistentVolumeClaims 106 // should not be provisioned and bound until the first Pod is created that 107 // references the PeristentVolumeClaim. The volume provisioning and 108 // binding will occur during Pod scheduing. 109 VolumeBindingWaitForFirstConsumer VolumeBindingMode = "WaitForFirstConsumer" 110 ) 111 112 // +genclient 113 // +genclient:nonNamespaced 114 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 115 116 // VolumeAttachment captures the intent to attach or detach the specified volume 117 // to/from the specified node. 118 // 119 // VolumeAttachment objects are non-namespaced. 120 type VolumeAttachment struct { 121 metav1.TypeMeta `json:",inline"` 122 123 // Standard object metadata. 124 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 125 // +optional 126 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 127 128 // spec represents specification of the desired attach/detach volume behavior. 129 // Populated by the Kubernetes system. 130 Spec VolumeAttachmentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` 131 132 // status represents status of the VolumeAttachment request. 133 // Populated by the entity completing the attach or detach 134 // operation, i.e. the external-attacher. 135 // +optional 136 Status VolumeAttachmentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 137 } 138 139 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 140 141 // VolumeAttachmentList is a collection of VolumeAttachment objects. 142 type VolumeAttachmentList struct { 143 metav1.TypeMeta `json:",inline"` 144 145 // Standard list metadata 146 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 147 // +optional 148 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 149 150 // items is the list of VolumeAttachments 151 Items []VolumeAttachment `json:"items" protobuf:"bytes,2,rep,name=items"` 152 } 153 154 // VolumeAttachmentSpec is the specification of a VolumeAttachment request. 155 type VolumeAttachmentSpec struct { 156 // attacher indicates the name of the volume driver that MUST handle this 157 // request. This is the name returned by GetPluginName(). 158 Attacher string `json:"attacher" protobuf:"bytes,1,opt,name=attacher"` 159 160 // source represents the volume that should be attached. 161 Source VolumeAttachmentSource `json:"source" protobuf:"bytes,2,opt,name=source"` 162 163 // nodeName represents the node that the volume should be attached to. 164 NodeName string `json:"nodeName" protobuf:"bytes,3,opt,name=nodeName"` 165 } 166 167 // VolumeAttachmentSource represents a volume that should be attached. 168 // Right now only PersistenVolumes can be attached via external attacher, 169 // in future we may allow also inline volumes in pods. 170 // Exactly one member can be set. 171 type VolumeAttachmentSource struct { 172 // persistentVolumeName represents the name of the persistent volume to attach. 173 // +optional 174 PersistentVolumeName *string `json:"persistentVolumeName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeName"` 175 176 // inlineVolumeSpec contains all the information necessary to attach 177 // a persistent volume defined by a pod's inline VolumeSource. This field 178 // is populated only for the CSIMigration feature. It contains 179 // translated fields from a pod's inline VolumeSource to a 180 // PersistentVolumeSpec. This field is beta-level and is only 181 // honored by servers that enabled the CSIMigration feature. 182 // +optional 183 InlineVolumeSpec *v1.PersistentVolumeSpec `json:"inlineVolumeSpec,omitempty" protobuf:"bytes,2,opt,name=inlineVolumeSpec"` 184 } 185 186 // VolumeAttachmentStatus is the status of a VolumeAttachment request. 187 type VolumeAttachmentStatus struct { 188 // attached indicates the volume is successfully attached. 189 // This field must only be set by the entity completing the attach 190 // operation, i.e. the external-attacher. 191 Attached bool `json:"attached" protobuf:"varint,1,opt,name=attached"` 192 193 // attachmentMetadata is populated with any 194 // information returned by the attach operation, upon successful attach, that must be passed 195 // into subsequent WaitForAttach or Mount calls. 196 // This field must only be set by the entity completing the attach 197 // operation, i.e. the external-attacher. 198 // +optional 199 AttachmentMetadata map[string]string `json:"attachmentMetadata,omitempty" protobuf:"bytes,2,rep,name=attachmentMetadata"` 200 201 // attachError represents the last error encountered during attach operation, if any. 202 // This field must only be set by the entity completing the attach 203 // operation, i.e. the external-attacher. 204 // +optional 205 AttachError *VolumeError `json:"attachError,omitempty" protobuf:"bytes,3,opt,name=attachError,casttype=VolumeError"` 206 207 // detachError represents the last error encountered during detach operation, if any. 208 // This field must only be set by the entity completing the detach 209 // operation, i.e. the external-attacher. 210 // +optional 211 DetachError *VolumeError `json:"detachError,omitempty" protobuf:"bytes,4,opt,name=detachError,casttype=VolumeError"` 212 } 213 214 // VolumeError captures an error encountered during a volume operation. 215 type VolumeError struct { 216 // time represents the time the error was encountered. 217 // +optional 218 Time metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"` 219 220 // message represents the error encountered during Attach or Detach operation. 221 // This string may be logged, so it should not contain sensitive 222 // information. 223 // +optional 224 Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"` 225 } 226 227 // +genclient 228 // +genclient:nonNamespaced 229 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 230 231 // CSIDriver captures information about a Container Storage Interface (CSI) 232 // volume driver deployed on the cluster. 233 // Kubernetes attach detach controller uses this object to determine whether attach is required. 234 // Kubelet uses this object to determine whether pod information needs to be passed on mount. 235 // CSIDriver objects are non-namespaced. 236 type CSIDriver struct { 237 metav1.TypeMeta `json:",inline"` 238 239 // Standard object metadata. 240 // metadata.Name indicates the name of the CSI driver that this object 241 // refers to; it MUST be the same name returned by the CSI GetPluginName() 242 // call for that driver. 243 // The driver name must be 63 characters or less, beginning and ending with 244 // an alphanumeric character ([a-z0-9A-Z]) with dashes (-), dots (.), and 245 // alphanumerics between. 246 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 247 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 248 249 // spec represents the specification of the CSI Driver. 250 Spec CSIDriverSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` 251 } 252 253 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 254 255 // CSIDriverList is a collection of CSIDriver objects. 256 type CSIDriverList struct { 257 metav1.TypeMeta `json:",inline"` 258 259 // Standard list metadata 260 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 261 // +optional 262 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 263 264 // items is the list of CSIDriver 265 Items []CSIDriver `json:"items" protobuf:"bytes,2,rep,name=items"` 266 } 267 268 // CSIDriverSpec is the specification of a CSIDriver. 269 type CSIDriverSpec struct { 270 // attachRequired indicates this CSI volume driver requires an attach 271 // operation (because it implements the CSI ControllerPublishVolume() 272 // method), and that the Kubernetes attach detach controller should call 273 // the attach volume interface which checks the volumeattachment status 274 // and waits until the volume is attached before proceeding to mounting. 275 // The CSI external-attacher coordinates with CSI volume driver and updates 276 // the volumeattachment status when the attach operation is complete. 277 // If the CSIDriverRegistry feature gate is enabled and the value is 278 // specified to false, the attach operation will be skipped. 279 // Otherwise the attach operation will be called. 280 // 281 // This field is immutable. 282 // 283 // +optional 284 AttachRequired *bool `json:"attachRequired,omitempty" protobuf:"varint,1,opt,name=attachRequired"` 285 286 // podInfoOnMount indicates this CSI volume driver requires additional pod information (like podName, podUID, etc.) 287 // during mount operations, if set to true. 288 // If set to false, pod information will not be passed on mount. 289 // Default is false. 290 // 291 // The CSI driver specifies podInfoOnMount as part of driver deployment. 292 // If true, Kubelet will pass pod information as VolumeContext in the CSI NodePublishVolume() calls. 293 // The CSI driver is responsible for parsing and validating the information passed in as VolumeContext. 294 // 295 // The following VolumeContext will be passed if podInfoOnMount is set to true. 296 // This list might grow, but the prefix will be used. 297 // "csi.storage.k8s.io/pod.name": pod.Name 298 // "csi.storage.k8s.io/pod.namespace": pod.Namespace 299 // "csi.storage.k8s.io/pod.uid": string(pod.UID) 300 // "csi.storage.k8s.io/ephemeral": "true" if the volume is an ephemeral inline volume 301 // defined by a CSIVolumeSource, otherwise "false" 302 // 303 // "csi.storage.k8s.io/ephemeral" is a new feature in Kubernetes 1.16. It is only 304 // required for drivers which support both the "Persistent" and "Ephemeral" VolumeLifecycleMode. 305 // Other drivers can leave pod info disabled and/or ignore this field. 306 // As Kubernetes 1.15 doesn't support this field, drivers can only support one mode when 307 // deployed on such a cluster and the deployment determines which mode that is, for example 308 // via a command line parameter of the driver. 309 // 310 // This field was immutable in Kubernetes < 1.29 and now is mutable. 311 // 312 // +optional 313 PodInfoOnMount *bool `json:"podInfoOnMount,omitempty" protobuf:"bytes,2,opt,name=podInfoOnMount"` 314 315 // volumeLifecycleModes defines what kind of volumes this CSI volume driver supports. 316 // The default if the list is empty is "Persistent", which is the usage defined by the 317 // CSI specification and implemented in Kubernetes via the usual PV/PVC mechanism. 318 // 319 // The other mode is "Ephemeral". In this mode, volumes are defined inline inside the pod spec 320 // with CSIVolumeSource and their lifecycle is tied to the lifecycle of that pod. 321 // A driver has to be aware of this because it is only going to get a NodePublishVolume call for such a volume. 322 // 323 // For more information about implementing this mode, see 324 // https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html 325 // A driver can support one or more of these modes and more modes may be added in the future. 326 // 327 // This field is beta. 328 // This field is immutable. 329 // 330 // +optional 331 // +listType=set 332 VolumeLifecycleModes []VolumeLifecycleMode `json:"volumeLifecycleModes,omitempty" protobuf:"bytes,3,opt,name=volumeLifecycleModes"` 333 334 // storageCapacity indicates that the CSI volume driver wants pod scheduling to consider the storage 335 // capacity that the driver deployment will report by creating 336 // CSIStorageCapacity objects with capacity information, if set to true. 337 // 338 // The check can be enabled immediately when deploying a driver. 339 // In that case, provisioning new volumes with late binding 340 // will pause until the driver deployment has published 341 // some suitable CSIStorageCapacity object. 342 // 343 // Alternatively, the driver can be deployed with the field 344 // unset or false and it can be flipped later when storage 345 // capacity information has been published. 346 // 347 // This field was immutable in Kubernetes <= 1.22 and now is mutable. 348 // 349 // +optional 350 // +featureGate=CSIStorageCapacity 351 StorageCapacity *bool `json:"storageCapacity,omitempty" protobuf:"bytes,4,opt,name=storageCapacity"` 352 353 // fsGroupPolicy defines if the underlying volume supports changing ownership and 354 // permission of the volume before being mounted. 355 // Refer to the specific FSGroupPolicy values for additional details. 356 // 357 // This field was immutable in Kubernetes < 1.29 and now is mutable. 358 // 359 // Defaults to ReadWriteOnceWithFSType, which will examine each volume 360 // to determine if Kubernetes should modify ownership and permissions of the volume. 361 // With the default policy the defined fsGroup will only be applied 362 // if a fstype is defined and the volume's access mode contains ReadWriteOnce. 363 // 364 // +optional 365 FSGroupPolicy *FSGroupPolicy `json:"fsGroupPolicy,omitempty" protobuf:"bytes,5,opt,name=fsGroupPolicy"` 366 367 // tokenRequests indicates the CSI driver needs pods' service account 368 // tokens it is mounting volume for to do necessary authentication. Kubelet 369 // will pass the tokens in VolumeContext in the CSI NodePublishVolume calls. 370 // The CSI driver should parse and validate the following VolumeContext: 371 // "csi.storage.k8s.io/serviceAccount.tokens": { 372 // "<audience>": { 373 // "token": <token>, 374 // "expirationTimestamp": <expiration timestamp in RFC3339>, 375 // }, 376 // ... 377 // } 378 // 379 // Note: Audience in each TokenRequest should be different and at 380 // most one token is empty string. To receive a new token after expiry, 381 // RequiresRepublish can be used to trigger NodePublishVolume periodically. 382 // 383 // +optional 384 // +listType=atomic 385 TokenRequests []TokenRequest `json:"tokenRequests,omitempty" protobuf:"bytes,6,opt,name=tokenRequests"` 386 387 // requiresRepublish indicates the CSI driver wants `NodePublishVolume` 388 // being periodically called to reflect any possible change in the mounted 389 // volume. This field defaults to false. 390 // 391 // Note: After a successful initial NodePublishVolume call, subsequent calls 392 // to NodePublishVolume should only update the contents of the volume. New 393 // mount points will not be seen by a running container. 394 // 395 // +optional 396 RequiresRepublish *bool `json:"requiresRepublish,omitempty" protobuf:"varint,7,opt,name=requiresRepublish"` 397 398 // seLinuxMount specifies if the CSI driver supports "-o context" 399 // mount option. 400 // 401 // When "true", the CSI driver must ensure that all volumes provided by this CSI 402 // driver can be mounted separately with different `-o context` options. This is 403 // typical for storage backends that provide volumes as filesystems on block 404 // devices or as independent shared volumes. 405 // Kubernetes will call NodeStage / NodePublish with "-o context=xyz" mount 406 // option when mounting a ReadWriteOncePod volume used in Pod that has 407 // explicitly set SELinux context. In the future, it may be expanded to other 408 // volume AccessModes. In any case, Kubernetes will ensure that the volume is 409 // mounted only with a single SELinux context. 410 // 411 // When "false", Kubernetes won't pass any special SELinux mount options to the driver. 412 // This is typical for volumes that represent subdirectories of a bigger shared filesystem. 413 // 414 // Default is "false". 415 // 416 // +featureGate=SELinuxMountReadWriteOncePod 417 // +optional 418 SELinuxMount *bool `json:"seLinuxMount,omitempty" protobuf:"varint,8,opt,name=seLinuxMount"` 419 } 420 421 // FSGroupPolicy specifies if a CSI Driver supports modifying 422 // volume ownership and permissions of the volume to be mounted. 423 // More modes may be added in the future. 424 type FSGroupPolicy string 425 426 const ( 427 // ReadWriteOnceWithFSTypeFSGroupPolicy indicates that each volume will be examined 428 // to determine if the volume ownership and permissions 429 // should be modified. If a fstype is defined and the volume's access mode 430 // contains ReadWriteOnce, then the defined fsGroup will be applied. 431 // This mode should be defined if it's expected that the 432 // fsGroup may need to be modified depending on the pod's SecurityPolicy. 433 // This is the default behavior if no other FSGroupPolicy is defined. 434 ReadWriteOnceWithFSTypeFSGroupPolicy FSGroupPolicy = "ReadWriteOnceWithFSType" 435 436 // FileFSGroupPolicy indicates that CSI driver supports volume ownership 437 // and permission change via fsGroup, and Kubernetes will change the permissions 438 // and ownership of every file in the volume to match the user requested fsGroup in 439 // the pod's SecurityPolicy regardless of fstype or access mode. 440 // Use this mode if Kubernetes should modify the permissions and ownership 441 // of the volume. 442 FileFSGroupPolicy FSGroupPolicy = "File" 443 444 // NoneFSGroupPolicy indicates that volumes will be mounted without performing 445 // any ownership or permission modifications, as the CSIDriver does not support 446 // these operations. 447 // This mode should be selected if the CSIDriver does not support fsGroup modifications, 448 // for example when Kubernetes cannot change ownership and permissions on a volume due 449 // to root-squash settings on a NFS volume. 450 NoneFSGroupPolicy FSGroupPolicy = "None" 451 ) 452 453 // VolumeLifecycleMode is an enumeration of possible usage modes for a volume 454 // provided by a CSI driver. More modes may be added in the future. 455 type VolumeLifecycleMode string 456 457 // TokenRequest contains parameters of a service account token. 458 type TokenRequest struct { 459 // audience is the intended audience of the token in "TokenRequestSpec". 460 // It will default to the audiences of kube apiserver. 461 Audience string `json:"audience" protobuf:"bytes,1,opt,name=audience"` 462 463 // expirationSeconds is the duration of validity of the token in "TokenRequestSpec". 464 // It has the same default value of "ExpirationSeconds" in "TokenRequestSpec". 465 // 466 // +optional 467 ExpirationSeconds *int64 `json:"expirationSeconds,omitempty" protobuf:"varint,2,opt,name=expirationSeconds"` 468 } 469 470 const ( 471 // VolumeLifecyclePersistent explicitly confirms that the driver implements 472 // the full CSI spec. It is the default when CSIDriverSpec.VolumeLifecycleModes is not 473 // set. Such volumes are managed in Kubernetes via the persistent volume 474 // claim mechanism and have a lifecycle that is independent of the pods which 475 // use them. 476 VolumeLifecyclePersistent VolumeLifecycleMode = "Persistent" 477 478 // VolumeLifecycleEphemeral indicates that the driver can be used for 479 // ephemeral inline volumes. Such volumes are specified inside the pod 480 // spec with a CSIVolumeSource and, as far as Kubernetes is concerned, have 481 // a lifecycle that is tied to the lifecycle of the pod. For example, such 482 // a volume might contain data that gets created specifically for that pod, 483 // like secrets. 484 // But how the volume actually gets created and managed is entirely up to 485 // the driver. It might also use reference counting to share the same volume 486 // instance among different pods if the CSIVolumeSource of those pods is 487 // identical. 488 VolumeLifecycleEphemeral VolumeLifecycleMode = "Ephemeral" 489 ) 490 491 // +genclient 492 // +genclient:nonNamespaced 493 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 494 495 // CSINode holds information about all CSI drivers installed on a node. 496 // CSI drivers do not need to create the CSINode object directly. As long as 497 // they use the node-driver-registrar sidecar container, the kubelet will 498 // automatically populate the CSINode object for the CSI driver as part of 499 // kubelet plugin registration. 500 // CSINode has the same name as a node. If the object is missing, it means either 501 // there are no CSI Drivers available on the node, or the Kubelet version is low 502 // enough that it doesn't create this object. 503 // CSINode has an OwnerReference that points to the corresponding node object. 504 type CSINode struct { 505 metav1.TypeMeta `json:",inline"` 506 507 // Standard object's metadata. 508 // metadata.name must be the Kubernetes node name. 509 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 510 511 // spec is the specification of CSINode 512 Spec CSINodeSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` 513 } 514 515 // CSINodeSpec holds information about the specification of all CSI drivers installed on a node 516 type CSINodeSpec struct { 517 // drivers is a list of information of all CSI Drivers existing on a node. 518 // If all drivers in the list are uninstalled, this can become empty. 519 // +patchMergeKey=name 520 // +patchStrategy=merge 521 // +listType=map 522 // +listMapKey=name 523 Drivers []CSINodeDriver `json:"drivers" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,1,rep,name=drivers"` 524 } 525 526 // CSINodeDriver holds information about the specification of one CSI driver installed on a node 527 type CSINodeDriver struct { 528 // name represents the name of the CSI driver that this object refers to. 529 // This MUST be the same name returned by the CSI GetPluginName() call for 530 // that driver. 531 Name string `json:"name" protobuf:"bytes,1,opt,name=name"` 532 533 // nodeID of the node from the driver point of view. 534 // This field enables Kubernetes to communicate with storage systems that do 535 // not share the same nomenclature for nodes. For example, Kubernetes may 536 // refer to a given node as "node1", but the storage system may refer to 537 // the same node as "nodeA". When Kubernetes issues a command to the storage 538 // system to attach a volume to a specific node, it can use this field to 539 // refer to the node name using the ID that the storage system will 540 // understand, e.g. "nodeA" instead of "node1". This field is required. 541 NodeID string `json:"nodeID" protobuf:"bytes,2,opt,name=nodeID"` 542 543 // topologyKeys is the list of keys supported by the driver. 544 // When a driver is initialized on a cluster, it provides a set of topology 545 // keys that it understands (e.g. "company.com/zone", "company.com/region"). 546 // When a driver is initialized on a node, it provides the same topology keys 547 // along with values. Kubelet will expose these topology keys as labels 548 // on its own node object. 549 // When Kubernetes does topology aware provisioning, it can use this list to 550 // determine which labels it should retrieve from the node object and pass 551 // back to the driver. 552 // It is possible for different nodes to use different topology keys. 553 // This can be empty if driver does not support topology. 554 // +optional 555 // +listType=atomic 556 TopologyKeys []string `json:"topologyKeys" protobuf:"bytes,3,rep,name=topologyKeys"` 557 558 // allocatable represents the volume resources of a node that are available for scheduling. 559 // This field is beta. 560 // +optional 561 Allocatable *VolumeNodeResources `json:"allocatable,omitempty" protobuf:"bytes,4,opt,name=allocatable"` 562 } 563 564 // VolumeNodeResources is a set of resource limits for scheduling of volumes. 565 type VolumeNodeResources struct { 566 // count indicates the maximum number of unique volumes managed by the CSI driver that can be used on a node. 567 // A volume that is both attached and mounted on a node is considered to be used once, not twice. 568 // The same rule applies for a unique volume that is shared among multiple pods on the same node. 569 // If this field is not specified, then the supported number of volumes on this node is unbounded. 570 // +optional 571 Count *int32 `json:"count,omitempty" protobuf:"varint,1,opt,name=count"` 572 } 573 574 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 575 576 // CSINodeList is a collection of CSINode objects. 577 type CSINodeList struct { 578 metav1.TypeMeta `json:",inline"` 579 580 // Standard list metadata 581 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 582 // +optional 583 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 584 585 // items is the list of CSINode 586 Items []CSINode `json:"items" protobuf:"bytes,2,rep,name=items"` 587 } 588 589 // +genclient 590 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 591 592 // CSIStorageCapacity stores the result of one CSI GetCapacity call. 593 // For a given StorageClass, this describes the available capacity in a 594 // particular topology segment. This can be used when considering where to 595 // instantiate new PersistentVolumes. 596 // 597 // For example this can express things like: 598 // - StorageClass "standard" has "1234 GiB" available in "topology.kubernetes.io/zone=us-east1" 599 // - StorageClass "localssd" has "10 GiB" available in "kubernetes.io/hostname=knode-abc123" 600 // 601 // The following three cases all imply that no capacity is available for 602 // a certain combination: 603 // - no object exists with suitable topology and storage class name 604 // - such an object exists, but the capacity is unset 605 // - such an object exists, but the capacity is zero 606 // 607 // The producer of these objects can decide which approach is more suitable. 608 // 609 // They are consumed by the kube-scheduler when a CSI driver opts into 610 // capacity-aware scheduling with CSIDriverSpec.StorageCapacity. The scheduler 611 // compares the MaximumVolumeSize against the requested size of pending volumes 612 // to filter out unsuitable nodes. If MaximumVolumeSize is unset, it falls back 613 // to a comparison against the less precise Capacity. If that is also unset, 614 // the scheduler assumes that capacity is insufficient and tries some other 615 // node. 616 type CSIStorageCapacity struct { 617 metav1.TypeMeta `json:",inline"` 618 619 // Standard object's metadata. 620 // The name has no particular meaning. It must be a DNS subdomain (dots allowed, 253 characters). 621 // To ensure that there are no conflicts with other CSI drivers on the cluster, 622 // the recommendation is to use csisc-<uuid>, a generated name, or a reverse-domain name 623 // which ends with the unique CSI driver name. 624 // 625 // Objects are namespaced. 626 // 627 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 628 // +optional 629 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 630 631 // nodeTopology defines which nodes have access to the storage 632 // for which capacity was reported. If not set, the storage is 633 // not accessible from any node in the cluster. If empty, the 634 // storage is accessible from all nodes. This field is 635 // immutable. 636 // 637 // +optional 638 NodeTopology *metav1.LabelSelector `json:"nodeTopology,omitempty" protobuf:"bytes,2,opt,name=nodeTopology"` 639 640 // storageClassName represents the name of the StorageClass that the reported capacity applies to. 641 // It must meet the same requirements as the name of a StorageClass 642 // object (non-empty, DNS subdomain). If that object no longer exists, 643 // the CSIStorageCapacity object is obsolete and should be removed by its 644 // creator. 645 // This field is immutable. 646 StorageClassName string `json:"storageClassName" protobuf:"bytes,3,name=storageClassName"` 647 648 // capacity is the value reported by the CSI driver in its GetCapacityResponse 649 // for a GetCapacityRequest with topology and parameters that match the 650 // previous fields. 651 // 652 // The semantic is currently (CSI spec 1.2) defined as: 653 // The available capacity, in bytes, of the storage that can be used 654 // to provision volumes. If not set, that information is currently 655 // unavailable. 656 // 657 // +optional 658 Capacity *resource.Quantity `json:"capacity,omitempty" protobuf:"bytes,4,opt,name=capacity"` 659 660 // maximumVolumeSize is the value reported by the CSI driver in its GetCapacityResponse 661 // for a GetCapacityRequest with topology and parameters that match the 662 // previous fields. 663 // 664 // This is defined since CSI spec 1.4.0 as the largest size 665 // that may be used in a 666 // CreateVolumeRequest.capacity_range.required_bytes field to 667 // create a volume with the same parameters as those in 668 // GetCapacityRequest. The corresponding value in the Kubernetes 669 // API is ResourceRequirements.Requests in a volume claim. 670 // 671 // +optional 672 MaximumVolumeSize *resource.Quantity `json:"maximumVolumeSize,omitempty" protobuf:"bytes,5,opt,name=maximumVolumeSize"` 673 } 674 675 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 676 677 // CSIStorageCapacityList is a collection of CSIStorageCapacity objects. 678 type CSIStorageCapacityList struct { 679 metav1.TypeMeta `json:",inline"` 680 681 // Standard list metadata 682 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 683 // +optional 684 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 685 686 // items is the list of CSIStorageCapacity objects. 687 Items []CSIStorageCapacity `json:"items" protobuf:"bytes,2,rep,name=items"` 688 } 689