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 v1alpha1 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 // +k8s:prerelease-lifecycle-gen:introduced=1.9 29 // +k8s:prerelease-lifecycle-gen:deprecated=1.21 30 // +k8s:prerelease-lifecycle-gen:replacement=storage.k8s.io,v1,VolumeAttachment 31 32 // VolumeAttachment captures the intent to attach or detach the specified volume 33 // to/from the specified node. 34 // 35 // VolumeAttachment objects are non-namespaced. 36 type VolumeAttachment struct { 37 metav1.TypeMeta `json:",inline"` 38 39 // Standard object metadata. 40 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 41 // +optional 42 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 43 44 // spec represents specification of the desired attach/detach volume behavior. 45 // Populated by the Kubernetes system. 46 Spec VolumeAttachmentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` 47 48 // status represents status of the VolumeAttachment request. 49 // Populated by the entity completing the attach or detach 50 // operation, i.e. the external-attacher. 51 // +optional 52 Status VolumeAttachmentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 53 } 54 55 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 56 // +k8s:prerelease-lifecycle-gen:introduced=1.9 57 // +k8s:prerelease-lifecycle-gen:deprecated=1.21 58 // +k8s:prerelease-lifecycle-gen:replacement=storage.k8s.io,v1,VolumeAttachmentList 59 60 // VolumeAttachmentList is a collection of VolumeAttachment objects. 61 type VolumeAttachmentList struct { 62 metav1.TypeMeta `json:",inline"` 63 64 // Standard list metadata 65 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 66 // +optional 67 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 68 69 // items is the list of VolumeAttachments 70 Items []VolumeAttachment `json:"items" protobuf:"bytes,2,rep,name=items"` 71 } 72 73 // VolumeAttachmentSpec is the specification of a VolumeAttachment request. 74 type VolumeAttachmentSpec struct { 75 // attacher indicates the name of the volume driver that MUST handle this 76 // request. This is the name returned by GetPluginName(). 77 Attacher string `json:"attacher" protobuf:"bytes,1,opt,name=attacher"` 78 79 // source represents the volume that should be attached. 80 Source VolumeAttachmentSource `json:"source" protobuf:"bytes,2,opt,name=source"` 81 82 // nodeName represents the node that the volume should be attached to. 83 NodeName string `json:"nodeName" protobuf:"bytes,3,opt,name=nodeName"` 84 } 85 86 // VolumeAttachmentSource represents a volume that should be attached. 87 // Right now only PersistenVolumes can be attached via external attacher, 88 // in future we may allow also inline volumes in pods. 89 // Exactly one member can be set. 90 type VolumeAttachmentSource struct { 91 // persistentVolumeName represents the name of the persistent volume to attach. 92 // +optional 93 PersistentVolumeName *string `json:"persistentVolumeName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeName"` 94 95 // inlineVolumeSpec contains all the information necessary to attach 96 // a persistent volume defined by a pod's inline VolumeSource. This field 97 // is populated only for the CSIMigration feature. It contains 98 // translated fields from a pod's inline VolumeSource to a 99 // PersistentVolumeSpec. This field is alpha-level and is only 100 // honored by servers that enabled the CSIMigration feature. 101 // +optional 102 InlineVolumeSpec *v1.PersistentVolumeSpec `json:"inlineVolumeSpec,omitempty" protobuf:"bytes,2,opt,name=inlineVolumeSpec"` 103 } 104 105 // VolumeAttachmentStatus is the status of a VolumeAttachment request. 106 type VolumeAttachmentStatus struct { 107 // attached indicates the volume is successfully attached. 108 // This field must only be set by the entity completing the attach 109 // operation, i.e. the external-attacher. 110 Attached bool `json:"attached" protobuf:"varint,1,opt,name=attached"` 111 112 // attachmentMetadata is populated with any 113 // information returned by the attach operation, upon successful attach, that must be passed 114 // into subsequent WaitForAttach or Mount calls. 115 // This field must only be set by the entity completing the attach 116 // operation, i.e. the external-attacher. 117 // +optional 118 AttachmentMetadata map[string]string `json:"attachmentMetadata,omitempty" protobuf:"bytes,2,rep,name=attachmentMetadata"` 119 120 // attachError represents the last error encountered during attach operation, if any. 121 // This field must only be set by the entity completing the attach 122 // operation, i.e. the external-attacher. 123 // +optional 124 AttachError *VolumeError `json:"attachError,omitempty" protobuf:"bytes,3,opt,name=attachError,casttype=VolumeError"` 125 126 // detachError represents the last error encountered during detach operation, if any. 127 // This field must only be set by the entity completing the detach 128 // operation, i.e. the external-attacher. 129 // +optional 130 DetachError *VolumeError `json:"detachError,omitempty" protobuf:"bytes,4,opt,name=detachError,casttype=VolumeError"` 131 } 132 133 // VolumeError captures an error encountered during a volume operation. 134 type VolumeError struct { 135 // time represents the time the error was encountered. 136 // +optional 137 Time metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"` 138 139 // message represents the error encountered during Attach or Detach operation. 140 // This string maybe logged, so it should not contain sensitive 141 // information. 142 // +optional 143 Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"` 144 } 145 146 // +genclient 147 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 148 // +k8s:prerelease-lifecycle-gen:introduced=1.19 149 // +k8s:prerelease-lifecycle-gen:deprecated=1.21 150 // +k8s:prerelease-lifecycle-gen:replacement=storage.k8s.io,v1beta1,CSIStorageCapacity 151 152 // CSIStorageCapacity stores the result of one CSI GetCapacity call. 153 // For a given StorageClass, this describes the available capacity in a 154 // particular topology segment. This can be used when considering where to 155 // instantiate new PersistentVolumes. 156 // 157 // For example this can express things like: 158 // - StorageClass "standard" has "1234 GiB" available in "topology.kubernetes.io/zone=us-east1" 159 // - StorageClass "localssd" has "10 GiB" available in "kubernetes.io/hostname=knode-abc123" 160 // 161 // The following three cases all imply that no capacity is available for 162 // a certain combination: 163 // - no object exists with suitable topology and storage class name 164 // - such an object exists, but the capacity is unset 165 // - such an object exists, but the capacity is zero 166 // 167 // The producer of these objects can decide which approach is more suitable. 168 // 169 // They are consumed by the kube-scheduler when a CSI driver opts into 170 // capacity-aware scheduling with CSIDriverSpec.StorageCapacity. The scheduler 171 // compares the MaximumVolumeSize against the requested size of pending volumes 172 // to filter out unsuitable nodes. If MaximumVolumeSize is unset, it falls back 173 // to a comparison against the less precise Capacity. If that is also unset, 174 // the scheduler assumes that capacity is insufficient and tries some other 175 // node. 176 type CSIStorageCapacity struct { 177 metav1.TypeMeta `json:",inline"` 178 179 // Standard object's metadata. The name has no particular meaning. It must be 180 // be a DNS subdomain (dots allowed, 253 characters). To ensure that 181 // there are no conflicts with other CSI drivers on the cluster, the recommendation 182 // is to use csisc-<uuid>, a generated name, or a reverse-domain name which ends 183 // with the unique CSI driver name. 184 // 185 // Objects are namespaced. 186 // 187 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 188 // +optional 189 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 190 191 // nodeTopology defines which nodes have access to the storage 192 // for which capacity was reported. If not set, the storage is 193 // not accessible from any node in the cluster. If empty, the 194 // storage is accessible from all nodes. This field is 195 // immutable. 196 // 197 // +optional 198 NodeTopology *metav1.LabelSelector `json:"nodeTopology,omitempty" protobuf:"bytes,2,opt,name=nodeTopology"` 199 200 // storageClassName represents the name of the StorageClass that the reported capacity applies to. 201 // It must meet the same requirements as the name of a StorageClass 202 // object (non-empty, DNS subdomain). If that object no longer exists, 203 // the CSIStorageCapacity object is obsolete and should be removed by its 204 // creator. 205 // This field is immutable. 206 StorageClassName string `json:"storageClassName" protobuf:"bytes,3,name=storageClassName"` 207 208 // capacity is the value reported by the CSI driver in its GetCapacityResponse 209 // for a GetCapacityRequest with topology and parameters that match the 210 // previous fields. 211 // 212 // The semantic is currently (CSI spec 1.2) defined as: 213 // The available capacity, in bytes, of the storage that can be used 214 // to provision volumes. If not set, that information is currently 215 // unavailable. 216 // 217 // +optional 218 Capacity *resource.Quantity `json:"capacity,omitempty" protobuf:"bytes,4,opt,name=capacity"` 219 220 // maximumVolumeSize is the value reported by the CSI driver in its GetCapacityResponse 221 // for a GetCapacityRequest with topology and parameters that match the 222 // previous fields. 223 // 224 // This is defined since CSI spec 1.4.0 as the largest size 225 // that may be used in a 226 // CreateVolumeRequest.capacity_range.required_bytes field to 227 // create a volume with the same parameters as those in 228 // GetCapacityRequest. The corresponding value in the Kubernetes 229 // API is ResourceRequirements.Requests in a volume claim. 230 // 231 // +optional 232 MaximumVolumeSize *resource.Quantity `json:"maximumVolumeSize,omitempty" protobuf:"bytes,5,opt,name=maximumVolumeSize"` 233 } 234 235 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 236 // +k8s:prerelease-lifecycle-gen:introduced=1.19 237 // +k8s:prerelease-lifecycle-gen:deprecated=1.21 238 // +k8s:prerelease-lifecycle-gen:replacement=storage.k8s.io,v1beta1,CSIStorageCapacityList 239 240 // CSIStorageCapacityList is a collection of CSIStorageCapacity objects. 241 type CSIStorageCapacityList struct { 242 metav1.TypeMeta `json:",inline"` 243 244 // Standard list metadata 245 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 246 // +optional 247 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 248 249 // items is the list of CSIStorageCapacity objects. 250 Items []CSIStorageCapacity `json:"items" protobuf:"bytes,2,rep,name=items"` 251 } 252 253 // +genclient 254 // +genclient:nonNamespaced 255 // +k8s:prerelease-lifecycle-gen:introduced=1.29 256 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 257 258 // VolumeAttributesClass represents a specification of mutable volume attributes 259 // defined by the CSI driver. The class can be specified during dynamic provisioning 260 // of PersistentVolumeClaims, and changed in the PersistentVolumeClaim spec after provisioning. 261 type VolumeAttributesClass struct { 262 metav1.TypeMeta `json:",inline"` 263 264 // Standard object's metadata. 265 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 266 // +optional 267 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 268 269 // Name of the CSI driver 270 // This field is immutable. 271 DriverName string `json:"driverName" protobuf:"bytes,2,opt,name=driverName"` 272 273 // parameters hold volume attributes defined by the CSI driver. These values 274 // are opaque to the Kubernetes and are passed directly to the CSI driver. 275 // The underlying storage provider supports changing these attributes on an 276 // existing volume, however the parameters field itself is immutable. To 277 // invoke a volume update, a new VolumeAttributesClass should be created with 278 // new parameters, and the PersistentVolumeClaim should be updated to reference 279 // the new VolumeAttributesClass. 280 // 281 // This field is required and must contain at least one key/value pair. 282 // The keys cannot be empty, and the maximum number of parameters is 512, with 283 // a cumulative max size of 256K. If the CSI driver rejects invalid parameters, 284 // the target PersistentVolumeClaim will be set to an "Infeasible" state in the 285 // modifyVolumeStatus field. 286 Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"` 287 } 288 289 // +k8s:prerelease-lifecycle-gen:introduced=1.29 290 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 291 292 // VolumeAttributesClassList is a collection of VolumeAttributesClass objects. 293 type VolumeAttributesClassList struct { 294 metav1.TypeMeta `json:",inline"` 295 296 // Standard list metadata 297 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 298 // +optional 299 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 300 301 // items is the list of VolumeAttributesClass objects. 302 Items []VolumeAttributesClass `json:"items" protobuf:"bytes,2,rep,name=items"` 303 } 304