github.com/openebs/api@v1.12.0/design/cstor/v1/cstorvolume_policy.md (about) 1 # Proposed v1 CStorVolumeConfig, CStorVolumePolicy and CStorVolumeAttachment Schema 2 3 ## Table of Contents 4 5 * [Introduction](#introduction) 6 * [Goals](#goals) 7 * [VolumeConfig Schema Proposal](#volume-config-schema-proposal) 8 * [VolumePolicy Schema Proposal](#volume-policy-schema-proposal) 9 * [VolumeAttachment Schema Proposal](#volume-attachment-schema-proposal) 10 11 ## Introduction 12 13 This proposal highlights enhancements and migration of current `CStorVolumeConfig` and `CStorVolumePolicy` schema and 14 proposes feature changes. 15 16 # Goals 17 18 The major goal of this document is to stabilize the APIs schema for `CStorVolumeConfig` and `CStorVolumePolicy`, 19 based on various learning and feedbacks for various volume related day 2 operations and how to make them easy to 20 perform. 21 22 # Volume Config Schema Proposal 23 24 ## CStorVolumeConfig APIs 25 26 ```go 27 28 // +genclient 29 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 30 // +k8s:openapi-gen=true 31 32 // CStorVolumeConfig describes a cstor volume config resource created as 33 // custom resource. CStorVolumeConfig is a request for creating cstor volume 34 // related resources like deployment, svc etc. 35 type CStorVolumeConfig struct { 36 metav1.TypeMeta `json:",inline"` 37 metav1.ObjectMeta `json:"metadata,omitempty"` 38 // Spec defines a specification of a cstor volume config required 39 // to provisione cstor volume resources 40 Spec CStorVolumeConfigSpec `json:"spec"` 41 42 // Publish contains info related to attachment of a volume to a node. 43 // i.e. NodeId etc. 44 Publish CStorVolumeConfigPublish `json:"publish,omitempty"` 45 46 // Status represents the current information/status for the cstor volume 47 // config, populated by the controller. 48 Status CStorVolumeConfigStatus `json:"status"` 49 VersionDetails VersionDetails `json:"versionDetails"` 50 } 51 52 // CStorVolumeConfigSpec is the spec for a CStorVolumeConfig resource 53 type CStorVolumeConfigSpec struct { 54 // Capacity represents the actual resources of the underlying 55 // cstor volume. 56 Capacity corev1.ResourceList `json:"capacity"` 57 // CStorVolumeRef has the information about where CstorVolumeClaim 58 // is created from. 59 CStorVolumeRef *corev1.ObjectReference `json:"cstorVolumeRef,omitempty"` 60 // CStorVolumeSource contains the source volumeName@snapShotname 61 // combaination. This will be filled only if it is a clone creation. 62 CStorVolumeSource string `json:"cstorVolumeSource,omitempty"` 63 // Provision represents the initial volume configuration for the underlying 64 // cstor volume based on the persistent volume request by user. 65 Provision VolumeProvision `json:"provision"` 66 // Policy contains volume specific required policies target and replicas 67 Policy CStorVolumePolicySpec `json:"policy"` 68 } 69 70 type VolumeProvision struct { 71 // Capacity represents initial capacity of volume replica required during 72 // volume clone operations to maintain some metadata info related to child 73 // resources like snapshot, cloned volumes. 74 Capacity corev1.ResourceList `json:"capacity"` 75 // ReplicaCount represents initial cstor volume replica count, its will not 76 // be updated later on based on scale up/down operations, only readonly 77 // operations and validations. 78 ReplicaCount int `json:"replicaCount"` 79 } 80 81 // CStorVolumeConfigPublish contains info related to attachment of a volume to a node. 82 // i.e. NodeId etc. 83 type CStorVolumeConfigPublish struct { 84 // NodeID contains publish info related to attachment of a volume to a node. 85 NodeID string `json:"nodeId,omitempty"` 86 } 87 88 // CStorVolumeConfigPhase represents the current phase of CStorVolumeConfig. 89 type CStorVolumeConfigPhase string 90 91 const ( 92 //CStorVolumeConfigPhasePending indicates that the cvc is still waiting for 93 //the cstorvolume to be created and bound 94 CStorVolumeConfigPhasePending CStorVolumeConfigPhase = "Pending" 95 96 //CStorVolumeConfigPhaseBound indiacates that the cstorvolume has been 97 //provisioned and bound to the cstor volume config 98 CStorVolumeConfigPhaseBound CStorVolumeConfigPhase = "Bound" 99 100 //CStorVolumeConfigPhaseFailed indiacates that the cstorvolume provisioning 101 //has failed 102 CStorVolumeConfigPhaseFailed CStorVolumeConfigPhase = "Failed" 103 ) 104 105 // CStorVolumeConfigStatus is for handling status of CstorVolume Claim. 106 // defines the observed state of CStorVolumeConfig 107 type CStorVolumeConfigStatus struct { 108 // Phase represents the current phase of CStorVolumeConfig. 109 Phase CStorVolumeConfigPhase `json:"phase"` 110 111 // PoolInfo represents current pool names where volume replicas exists 112 PoolInfo []string `json:"poolInfo"` 113 114 // Capacity the actual resources of the underlying volume. 115 Capacity corev1.ResourceList `json:"capacity,omitempty"` 116 117 Conditions []CStorVolumeConfigCondition `json:"condition,omitempty"` 118 } 119 120 // CStorVolumeConfigCondition contains details about state of cstor volume 121 type CStorVolumeConfigCondition struct { 122 // Current Condition of cstor volume config. If underlying persistent volume is being 123 // resized then the Condition will be set to 'ResizeStarted' etc 124 Type CStorVolumeConfigConditionType `json:"type"` 125 // Last time we probed the condition. 126 // +optional 127 LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"` 128 // Last time the condition transitioned from one status to another. 129 // +optional 130 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` 131 // Reason is a brief CamelCase string that describes any failure 132 Reason string `json:"reason"` 133 // Human-readable message indicating details about last transition. 134 Message string `json:"message"` 135 } 136 137 // CStorVolumeConfigConditionType is a valid value of CstorVolumeConfigCondition.Type 138 type CStorVolumeConfigConditionType string 139 140 // These constants are CVC condition types related to resize operation. 141 const ( 142 // CStorVolumeConfigResizePending ... 143 CStorVolumeConfigResizing CStorVolumeConfigConditionType = "Resizing" 144 // CStorVolumeConfigResizeFailed ... 145 CStorVolumeConfigResizeFailed CStorVolumeConfigConditionType = "VolumeResizeFailed" 146 // CStorVolumeConfigResizeSuccess ... 147 CStorVolumeConfigResizeSuccess CStorVolumeConfigConditionType = "VolumeResizeSuccessful" 148 // CStorVolumeConfigResizePending ... 149 CStorVolumeConfigResizePending CStorVolumeConfigConditionType = "VolumeResizePending" 150 ) 151 152 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 153 // +k8s:openapi-gen=true 154 155 // CStorVolumeConfigList is a list of CStorVolumeConfig resources 156 type CStorVolumeConfigList struct { 157 metav1.TypeMeta `json:",inline"` 158 metav1.ListMeta `json:"metadata"` 159 160 Items []CStorVolumeConfig `json:"items"` 161 } 162 ``` 163 164 165 # Volume Policy Schema Proposal 166 167 ## CStorVolumePolicy APIs 168 169 ```go 170 171 // +genclient 172 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 173 // +k8s:openapi-gen=true 174 175 // CStorVolumePolicy describes a configuration required for cstor volume 176 // resources 177 type CStorVolumePolicy struct { 178 metav1.TypeMeta `json:",inline"` 179 metav1.ObjectMeta `json:"metadata,omitempty"` 180 // Spec defines a configuration info of a cstor volume required 181 // to provisione cstor volume resources 182 Spec CStorVolumePolicySpec `json:"spec"` 183 Status CStorVolumePolicyStatus `json:"status"` 184 } 185 186 // CStorVolumePolicySpec ... 187 type CStorVolumePolicySpec struct { 188 // replicaAffinity is set to true then volume replica resources need to be 189 // distributed across the pool instances 190 Provision Provision `json:"provision"` 191 192 // TargetSpec represents configuration related to cstor target and its resources 193 Target TargetSpec `json:"target"` 194 195 // ReplicaSpec represents configuration related to replicas resources 196 Replica ReplicaSpec `json:"replica"` 197 198 // ReplicaPoolInfo holds the pool information of volume replicas. 199 // Ex: If volume is provisioned on which CStor pool volume replicas exist 200 ReplicaPoolInfo []ReplicaPoolInfo `json:"replicaPoolInfo"` 201 } 202 203 // TargetSpec represents configuration related to cstor target and its resources 204 type TargetSpec struct { 205 // QueueDepth sets the queue size at iSCSI target which limits the 206 // ongoing IO count from client 207 QueueDepth string `json:"queueDepth,omitempty"` 208 209 // IOWorkers sets the number of threads that are working on above queue 210 IOWorkers int64 `json:"luWorkers,omitempty"` 211 212 // Monitor enables or disables the target exporter sidecar 213 Monitor bool `json:"monitor,omitempty"` 214 215 // ReplicationFactor represents maximum number of replicas 216 // that are allowed to connect to the target 217 ReplicationFactor int64 `json:"replicationFactor,omitempty"` 218 219 // Resources are the compute resources required by the cstor-target 220 // container. 221 Resources *corev1.ResourceRequirements `json:"resources,omitempty"` 222 223 // AuxResources are the compute resources required by the cstor-target pod 224 // side car containers. 225 AuxResources *corev1.ResourceRequirements `json:"auxResources,omitempty"` 226 227 // Tolerations, if specified, are the target pod's tolerations 228 Tolerations []corev1.Toleration `json:"tolerations,omitempty"` 229 230 // PodAffinity if specified, are the target pod's affinities 231 PodAffinity *corev1.PodAffinity `json:"affinity,omitempty"` 232 233 // NodeSelector is the labels that will be used to select 234 // a node for target pod scheduleing 235 // Required field 236 NodeSelector map[string]string `json:"nodeSelector,omitempty"` 237 238 // PriorityClassName if specified applies to this target pod 239 // If left empty, no priority class is applied. 240 PriorityClassName string `json:"priorityClassName,omitempty"` 241 } 242 243 // ReplicaSpec represents configuration related to replicas resources 244 type ReplicaSpec struct { 245 // IOWorkers represents number of threads that executes client IOs 246 IOWorkers string `json:"zvolWorkers,omitempty"` 247 // Controls the compression algorithm used for this volumes 248 // examples: on|off|gzip|gzip-N|lz4|lzjb|zle 249 // 250 // Setting compression to "on" indicates that the current default compression 251 // algorithm should be used.The default balances compression and decompression 252 // speed, with compression ratio and is expected to work well on a wide variety 253 // of workloads. Unlike all other setātings for this property, on does not 254 // select a fixed compression type. As new compression algorithms are added 255 // to ZFS and enabled on a pool, the default compression algorithm may change. 256 // The current default compression algorithm is either lzjb or, if the 257 // `lz4_compress feature is enabled, lz4. 258 259 // The lz4 compression algorithm is a high-performance replacement for the lzjb 260 // algorithm. It features significantly faster compression and decompression, 261 // as well as a moderately higher compression ratio than lzjb, but can only 262 // be used on pools with the lz4_compress 263 264 // feature set to enabled. See zpool-features(5) for details on ZFS feature 265 // flags and the lz4_compress feature. 266 267 // The lzjb compression algorithm is optimized for performance while providing 268 // decent data compression. 269 270 // The gzip compression algorithm uses the same compression as the gzip(1) 271 // command. You can specify the gzip level by using the value gzip-N, 272 // where N is an integer from 1 (fastest) to 9 (best compression ratio). 273 // Currently, gzip is equivalent to gzip-6 (which is also the default for gzip(1)). 274 275 // The zle compression algorithm compresses runs of zeros. 276 Compression string `json:"compression,omitempty"` 277 } 278 279 // Provision represents different provisioning policy for cstor volumes 280 type Provision struct { 281 // replicaAffinity is set to true then volume replica resources need to be 282 // distributed across the cstor pool instances based on the given topology 283 ReplicaAffinity bool `json:"replicaAffinity"` 284 // BlockSize is the logical block size in multiple of 512 bytes 285 // BlockSize specifies the block size of the volume. The blocksize 286 // cannot be changed once the volume has been written, so it should be 287 // set at volume creation time. The default blocksize for volumes is 4 Kbytes. 288 // Any power of 2 from 512 bytes to 128 Kbytes is valid. 289 BlockSize uint32 `json:"blockSize"` 290 } 291 292 // ReplicaPoolInfo represents the pool information of volume replica 293 type ReplicaPoolInfo struct { 294 // PoolName represents the pool name where volume replica exists 295 PoolName string `json:"poolName"` 296 // UID also can be added 297 } 298 299 // CStorVolumePolicyStatus is for handling status of CstorVolumePolicy 300 type CStorVolumePolicyStatus struct { 301 Phase string `json:"phase"` 302 } 303 304 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 305 // +k8s:openapi-gen=true 306 307 // CStorVolumePolicyList is a list of CStorVolumePolicy resources 308 type CStorVolumePolicyList struct { 309 metav1.TypeMeta `json:",inline"` 310 metav1.ListMeta `json:"metadata"` 311 312 Items []CStorVolumePolicy `json:"items"` 313 } 314 315 ``` 316 317 # Volume Attachment Schema Proposal 318 319 ## CStorVolumeAttachment APIs 320 ```go 321 322 // +genclient 323 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 324 // +resource:path=csivolume 325 326 // CStorVolumeAttachment represents a CSI based volume 327 type CStorVolumeAttachment struct { 328 metav1.TypeMeta `json:",inline"` 329 metav1.ObjectMeta `json:"metadata,omitempty"` 330 331 Spec CStorVolumeAttachmentSpec `json:"spec"` 332 Status CStorVolumeAttachmentStatus `json:"status"` 333 } 334 335 // CStorVolumeAttachmentSpec is the spec for a CStorVolume resource 336 type CStorVolumeAttachmentSpec struct { 337 // Volume specific info 338 Volume VolumeInfo `json:"volume"` 339 340 // ISCSIInfo specific to ISCSI protocol, 341 // this is filled only if the volume type 342 // is iSCSI 343 ISCSI ISCSIInfo `json:"iscsi"` 344 } 345 346 // VolumeInfo contains the volume related info 347 // for all types of volumes in CStorVolumeAttachmentSpec 348 type VolumeInfo struct { 349 // Name of the CSI volume 350 Name string `json:"name"` 351 352 // Capacity of the volume 353 Capacity string `json:"capacity,omitempty"` 354 355 // OwnerNodeID is the Node ID which 356 // is also the owner of this Volume 357 OwnerNodeID string `json:"ownerNodeID"` 358 359 // FSType of a volume will specify the 360 // format type - ext4(default), xfs of PV 361 FSType string `json:"fsType,omitempty"` 362 363 // AccessMode of a volume will hold the 364 // access mode of the volume 365 AccessModes []string `json:"accessModes,omitempty"` 366 367 // AccessType of a volume will indicate if the volume will be used as a 368 // block device or mounted on a path 369 AccessType string `json:"accessType,omitempty"` 370 371 // StagingPath of the volume will hold the 372 // path on which the volume is mounted 373 // on that node 374 StagingTargetPath string `json:"stagingTargetPath,omitempty"` 375 376 // TargetPath of the volume will hold the 377 // path on which the volume is bind mounted 378 // on that node 379 TargetPath string `json:"targetPath,omitempty"` 380 381 // ReadOnly specifies if the volume needs 382 // to be mounted in ReadOnly mode 383 ReadOnly bool `json:"readOnly,omitempty"` 384 385 // MountOptions specifies the options with 386 // which mount needs to be attempted 387 MountOptions []string `json:"mountOptions,omitempty"` 388 389 // Device Path specifies the device path 390 // which is returned when the iSCSI 391 // login is successful 392 DevicePath string `json:"devicePath,omitempty"` 393 } 394 395 // ISCSIInfo has ISCSI protocol specific info, 396 // this can be used only if the volume type exposed 397 // by the vendor is iSCSI 398 type ISCSIInfo struct { 399 // Iqn of this volume 400 Iqn string `json:"iqn"` 401 402 // TargetPortal holds the target portal 403 // of this volume 404 TargetPortal string `json:"targetPortal"` 405 406 // IscsiInterface of this volume 407 IscsiInterface string `json:"iscsiInterface"` 408 409 // Lun specify the lun number 0, 1.. on 410 // iSCSI Volume. (default: 0) 411 Lun string `json:"lun"` 412 } 413 414 // CStorVolumeAttachmentStatus status represents the current mount status of the volume 415 type CStorVolumeAttachmentStatus string 416 417 // CStorVolumeAttachmentStatusMounting indicated that a mount operation has been triggered 418 // on the volume and is under progress 419 const ( 420 // CStorVolumeAttachmentStatusUninitialized indicates that no operation has been 421 // performed on the volume yet on this node 422 CStorVolumeAttachmentStatusUninitialized CStorVolumeAttachmentStatus = "" 423 // CStorVolumeAttachmentStatusMountUnderProgress indicates that the volume is busy and 424 // unavailable for use by other goroutines, an iSCSI login followed by mount 425 // is under progress on this volume 426 CStorVolumeAttachmentStatusMountUnderProgress CStorVolumeAttachmentStatus = "MountUnderProgress" 427 // CStorVolumeAttachmentStatusMounteid indicated that the volume has been successfulled 428 // mounted on the node 429 CStorVolumeAttachmentStatusMounted CStorVolumeAttachmentStatus = "Mounted" 430 // CStorVolumeAttachmentStatusUnMounted indicated that the volume has been successfuly 431 // unmounted and logged out of the node 432 CStorVolumeAttachmentStatusUnmounted CStorVolumeAttachmentStatus = "Unmounted" 433 // CStorVolumeAttachmentStatusRaw indicates that the volume is being used in raw format 434 // by the application, therefore CSI has only performed iSCSI login 435 // operation on this volume and avoided filesystem creation and mount. 436 CStorVolumeAttachmentStatusRaw CStorVolumeAttachmentStatus = "Raw" 437 // CStorVolumeAttachmentStatusResizeInProgress indicates that the volume is being 438 // resized 439 CStorVolumeAttachmentStatusResizeInProgress CStorVolumeAttachmentStatus = "ResizeInProgress" 440 // CStorVolumeAttachmentStatusMountFailed indicates that login and mount process from 441 // the volume has bben started but failed kubernetes needs to retry sending 442 // nodepublish 443 CStorVolumeAttachmentStatusMountFailed CStorVolumeAttachmentStatus = "MountFailed" 444 // CStorVolumeAttachmentStatusUnmountInProgress indicates that the volume is busy and 445 // unavailable for use by other goroutines, an unmount operation on volume 446 // is under progress 447 CStorVolumeAttachmentStatusUnmountUnderProgress CStorVolumeAttachmentStatus = "UnmountUnderProgress" 448 // CStorVolumeAttachmentStatusWaitingForCVCBound indicates that the volume components 449 // are still being created 450 CStorVolumeAttachmentStatusWaitingForCVCBound CStorVolumeAttachmentStatus = "WaitingForCVCBound" 451 // CStorVolumeAttachmentStatusWaitingForVolumeToBeReady indicates that the replicas are 452 // yet to connect to target 453 CStorVolumeAttachmentStatusWaitingForVolumeToBeReady CStorVolumeAttachmentStatus = "WaitingForVolumeToBeReady" 454 ) 455 456 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 457 // +resource:path=csivolumes 458 459 // CStorVolumeAttachmentList is a list of CStorVolumeAttachment resources 460 type CStorVolumeAttachmentList struct { 461 metav1.TypeMeta `json:",inline"` 462 metav1.ListMeta `json:"metadata"` 463 464 Items []CStorVolumeAttachment `json:"items"` 465 } 466 467 468 ```