github.com/openebs/api@v1.12.0/design/cstor/v1/cstorpool.md (about)

     1  # Proposed v1 schema for CSPC and CSPI
     2  
     3  ## Table of Contents
     4  
     5  * [Introduction](#introduction)
     6  * [Goals](#goals)
     7  * [CSPC and CSPI Schema Proposal](#cspc-and-cspi-schema-proposal)
     8  
     9  ## Introduction
    10  
    11  This proposal highlights the limitations of current CSPC and CSPI schema and
    12  proposes improvements for the same.
    13  Please refer to the following link for cstor operator design document. 
    14  https://github.com/openebs/openebs/blob/master/contribute/design/1.x/cstor-operator/doc.md
    15  
    16  # Goals
    17  
    18  OpenEBS cStor Data Engine has been in production for over a year now, with multiple cStor custom resource schema 
    19  revisions. The goal of this design is to incorporate all the feedback received on the alpha and beta versions of cStor 
    20  custom resources and define a version 1 schema.
    21  The schema proposed in this document encompasses the following requirements:
    22  
    23  - Include the best practicies followed by users with SPC into the schema itself.
    24  - Rename the SPC and CSP to CSPC and CSPI based on the feedback received.
    25  - Enhance the elements of CSPC and CSPI to enable performing Day 2 operations declaratively:
    26      - Scaling up/down of cStor Pools
    27      - Expanding the capacity of cStor Pools
    28      - Replacing the failed block devices in cStor Pools.
    29      - Add supportability features via Status Conditions and Events
    30      - Capture the history / log of upgrades
    31  
    32  
    33  ## CSPC and CSPI Schema Proposal
    34  
    35  ### CSPC Schema
    36  
    37  ```go
    38  // CStorPoolCluster describes a CStorPoolCluster custom resource.
    39  type CStorPoolCluster struct {
    40  	metav1.TypeMeta   `json:",inline"`
    41  	metav1.ObjectMeta `json:"metadata,omitempty"`
    42  	Spec              CStorPoolClusterSpec   `json:"spec"`
    43  	Status            CStorPoolClusterStatus `json:"status"`
    44  	VersionDetails    VersionDetails         `json:"versionDetails"`
    45  }
    46  
    47  // CStorPoolClusterSpec is the spec for a CStorPoolClusterSpec resource
    48  type CStorPoolClusterSpec struct {
    49  	// Pools is the spec for pools for various nodes
    50  	// where it should be created.
    51  	Pools []PoolSpec `json:"pools"`
    52  
    53  	// DefaultResources are the compute resources required by the cstor-pool
    54  	// container.
    55  	// If the resources at PoolConfig is not specified, this is written
    56  	// to CSPI PoolConfig.
    57  	DefaultResources *corev1.ResourceRequirements `json:"resources"`
    58  
    59  	// AuxResources are the compute resources required by the cstor-pool pod
    60  	// side car containers.
    61  	DefaultAuxResources *corev1.ResourceRequirements `json:"auxResources"`
    62  
    63  	// DefaultTolerations, if specified, are the pool pod's tolerations
    64  	// If tolerations at PoolConfig is empty, this is written to
    65  	// CSPI PoolConfig.
    66  	DefaultTolerations []corev1.Toleration `json:"tolerations"`
    67  
    68  	// DefaultPriorityClassName if specified applies to all the pool pods
    69  	// in the pool spec if the priorityClass at the pool level is
    70  	// not specified.
    71  	DefaultPriorityClassName string `json:"priorityClassName"`
    72  }
    73  
    74  //PoolSpec is the spec for pool on node where it should be created.
    75  type PoolSpec struct {
    76  	// NodeSelector is the labels that will be used to select
    77  	// a node for pool provisioning.
    78  	// Required field
    79  	NodeSelector map[string]string `json:"nodeSelector"`
    80  
    81  	// DataRaidConfig is the raid group configuration for the given pool.
    82  	DataRaidGroups []RaidGroup `json:"dataRaidGroups"`
    83  
    84  	// WriteCacheGroups is the write cache for the given pool.
    85  	WriteCacheGroups []RaidGroup `json:"writeCacheGroups"`
    86  
    87  	// PoolConfig is the pool config that applies to the
    88  	// pool on node.
    89  	PoolConfig PoolConfig `json:"poolConfig"`
    90  }
    91  
    92  // PoolConfig is the default pool config that applies to the
    93  // pool on node.
    94  type PoolConfig struct {
    95  	// DataRaidGroupType is the data raid group raid type 
    96  	// Supported values are : stripe, mirror, raidz and raidz2
    97  	DataRaidGroupType string `json:"dataRaidGroupType"`
    98  
    99  	// WriteCacheRaidGroupType is the write cache raid type 
   100  	// Supported values are : stripe, mirror, raidz and raidz2
   101  	WriteCacheRaidGroupType string `json:"writeCacheRaidGroupType"`
   102  
   103  	// ThickProvisioning will provision the volumes, only if capacity is available on the pool.
   104  	// Setting this to true will disable over-provisioning of the pool.
   105  	// Optional -- defaults to false
   106  	ThickProvisioning bool `json:"thickProvisioning"`
   107  
   108  	// Compression to enable compression
   109  	// Optional -- defaults to off
   110  	// Possible values : lz, off
   111  	Compression string `json:"compression"`
   112  
   113  	// Resources are the compute resources required by the cstor-pool
   114  	// container.
   115  	Resources *corev1.ResourceRequirements `json:"resources"`
   116  
   117  	// AuxResources are the compute resources required by the cstor-pool pod
   118  	// side car containers.
   119  	AuxResources *corev1.ResourceRequirements `json:"auxResources"`
   120  
   121  	// Tolerations, if specified, the pool pod's tolerations.
   122  	Tolerations []corev1.Toleration `json:"tolerations"`
   123  
   124  	// PriorityClassName if specified applies to this pool pod
   125  	// If left empty, DefaultPriorityClassName is applied.
   126  	// (See CStorPoolClusterSpec.DefaultPriorityClassName)
   127  	// If both are empty, not priority class is applied.
   128  	PriorityClassName string `json:"priorityClassName"`
   129  	
   130  	// ROThresholdLimit is threshold(percentage base) limit
   131  	// for pool read only mode. If ROThresholdLimit(%) amount
   132  	// of pool storage is reached then pool will set to readonly.
   133  	// NOTE:
   134  	// 1. If ROThresholdLimit is set to 100 then entire
   135  	//    pool storage will be used by default it will be set to 85%.
   136  	// 2. ROThresholdLimit value will be 0 < ROThresholdLimit <= 100.
   137  	// optional
   138  	ROThresholdLimit int `json:"roThresholdLimit"`
   139  }
   140  
   141  // RaidGroup contains the details of a raid group for the pool
   142  type RaidGroup struct {
   143  	CStorPoolInstanceBlockDevices []CStorPoolInstanceBlockDevice `json:"cspiBlockDevices"`
   144  }
   145  
   146  // CStorPoolInstanceBlockDevice contains the details of block devices that
   147  // constitutes a raid group.
   148  type CStorPoolInstanceBlockDevice struct {
   149  	// BlockDeviceName is the name of the block device.
   150  	BlockDeviceName string `json:"blockDeviceName"`
   151  
   152  	// Capacity is the capacity of the block device.
   153  	// It is system generated filled by CSPI controller
   154  	Capacity uint64 `json:"capacity"`
   155  
   156  	// DevLink is the dev link for block devices
   157  	DevLink string `json:"devLink"`
   158  }
   159  
   160  // CStorPoolClusterStatus represents the latest available observations of a CSPC's current state.
   161  type CStorPoolClusterStatus struct {
   162  	// ProvisionedInstances is the the number of CSPI present at the current state. 
   163  	ProvisionedInstances int32 `json:"provisionedInstances"`
   164  	
   165  	// DesiredInstances is the number of CSPI(s) that should be provisioned.
   166  	DesiredInstances int32 `json:"runningInstances"`
   167  
   168  	// HealthyInstances is the number of CSPI(s) that are healthy.
   169  	HealthyInstances int32 `json:"healthyInstances"`
   170  
   171  	// Current state of CSPC.
   172  	Conditions []CStorPoolClusterCondition  `json:conditions`
   173  }
   174  
   175  type CSPCConditionType string
   176  
   177  // CStorPoolClusterCondition describes the state of a CSPC at a certain point.
   178  type CStorPoolClusterCondition struct {
   179  	// Type of CSPC condition.
   180  	Type CSPCConditionType `json:"type"`
   181  	// Status of the condition, one of True, False, Unknown.
   182  	Status corev1.ConditionStatus `json:"status"`
   183  	// The last time this condition was updated.
   184  	LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
   185  	// Last time the condition transitioned from one status to another.
   186  	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
   187  	// The reason for the condition's last transition.
   188  	Reason string `json:"reason,omitempty"`
   189  	// A human readable message indicating details about the transition.
   190  	Message string `json:"message,omitempty"`
   191  }
   192  
   193  // CStorPoolClusterList is a list of CStorPoolCluster resources
   194  type CStorPoolClusterList struct {
   195  	metav1.TypeMeta `json:",inline"`
   196  	metav1.ListMeta `json:"metadata"`
   197  
   198  	Items []CStorPoolCluster `json:"items"`
   199  }
   200  
   201  ```
   202  
   203  ### CSPI Schema
   204  
   205  ```go
   206  // CStorPoolInstance describes a cstor pool instance resource.
   207  type CStorPoolInstance struct {
   208  	metav1.TypeMeta   `json:",inline"`
   209  	metav1.ObjectMeta `json:"metadata,omitempty"`
   210  	// Spec is the specification of the cstorpoolinstance resource.
   211  	Spec CStorPoolInstanceSpec `json:"spec"`
   212  	// Status is the possible statuses of the cstorpoolinstance resource.
   213  	Status CStorPoolInstanceStatus `json:"status"`
   214  	// VersionDetails is the openebs version.
   215  	VersionDetails VersionDetails `json:"versionDetails"`
   216  }
   217  
   218  // CStorPoolInstanceSpec is the spec listing fields for a CStorPoolInstance resource.
   219  type CStorPoolInstanceSpec struct {
   220  	// HostName is the name of kubernetes node where the pool
   221  	// should be created.
   222  	HostName string `json:"hostName"`
   223  	// NodeSelector is the labels that will be used to select
   224  	// a node for pool provisioning.
   225  	// Required field
   226  	NodeSelector map[string]string `json:"nodeSelector"`
   227  	// PoolConfig is the default pool config that applies to the
   228  	// pool on node.
   229  	PoolConfig PoolConfig `json:"poolConfig"`
   230  	// DataRaidGroups is the raid group configuration for the given pool.
   231  	DataRaidGroups []RaidGroup `json:"dataRaidGroups"`
   232  	// WriteCacheRaidGroups is the write cache raid group.
   233  	WriteCacheRaidGroups []RaidGroup `json:"writeCacheRaidGroups"`
   234  }
   235  
   236  // CStorPoolInstanceStatus is for handling status of pool.
   237  type CStorPoolInstanceStatus struct {
   238  	// Current state of CSPI with details.
   239  	Conditions []CStorPoolInstanceCondition 
   240  	// The phase of a CStorPool is a simple, high-level summary of the pool state on the node.  
   241  	Phase    CStorPoolPhase        `json:"phase"`
   242  	// Capacity describes the capacity details of a cstor pool 
   243  	Capacity CStorPoolInstanceCapacity `json:"capacity"`
   244  	//ReadOnly if pool is readOnly or not
   245  	ReadOnly bool `json:"readOnly"`
   246  	// ProvisionedReplicas describes the total count of Volume Replicas
   247  	// present in the cstor pool
   248  	ProvisionedReplicas int32 `json:"provisionedReplicas"`
   249  	// HealthyReplicas describes the total count of healthy Volume Replicas
   250  	// in the cstor pool
   251  	HealthyReplicas int32 `json:"healthyReplicas"`
   252  }
   253  
   254  // CStorPoolInstanceCapacity stores the pool capacity related attributes.
   255  type CStorPoolInstanceCapacity struct {
   256  	// Amount of physical data (and its metadata) written to pool
   257  	// after applying compression, etc..,
   258  	Used resource.Quantity `json:"used"`
   259  	// Amount of usable space in the pool after excluding
   260  	// metadata and raid parity
   261  	Free resource.Quantity `json:"free"`
   262  	// Sum of usable capacity in all the data raidgroups
   263  	Total resource.Quantity `json:"total"`
   264  	// ZFSCapacityAttributes contains advanced information about pool capacity details
   265  	ZFS ZFSCapacityAttributes `json:"zfs"`
   266  }
   267  
   268  // ZFSCapacityAttributes stores the advanced information about pool capacity related
   269  // attributes
   270  type ZFSCapacityAttributes struct {
   271  	// LogicalUsed is the amount of space that is "logically" consumed
   272  	// by this pool and all its descendents. The logical space ignores
   273  	// the effect of the compression and copies properties, giving a
   274  	// quantity closer to the amount of data that applications see.
   275  	// However, it does include space consumed by metadata.
   276  	// NOTE: Used and LogicalUsed can vary depends on the pool properties
   277  	LogicalUsed resource.Quantity `json:"logicalUsed"`
   278  }
   279  
   280  type CSPIConditionType string
   281  
   282  // CSPIConditionType describes the state of a CSPI at a certain point.
   283  type CStorPoolInstanceCondition struct {
   284  	// Type of CSPI condition.
   285  	Type CSPIConditionType `json:"type"`
   286  	// Status of the condition, one of True, False, Unknown.
   287  	Status corev1.ConditionStatus `json:"status"`
   288  	// The last time this condition was updated.
   289  	LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
   290  	// Last time the condition transitioned from one status to another.
   291  	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
   292  	// The reason for the condition's last transition.
   293  	Reason string `json:"reason,omitempty"`
   294  	// A human readable message indicating details about the transition.
   295  	Message string `json:"message,omitempty"`
   296  }
   297  
   298  ```
   299