github.com/openebs/api@v1.12.0/pkg/apis/cstor/v1/cstorpoolcluster.go (about)

     1  /*
     2  Copyright 2020 The OpenEBS 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  	corev1 "k8s.io/api/core/v1"
    21  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    22  )
    23  
    24  // PoolType is a label for the pool type of a cStor pool.
    25  type PoolType string
    26  
    27  // These are the valid pool types of cStor Pool.
    28  const (
    29  	// PoolStriped is the striped raid group.
    30  	PoolStriped PoolType = "stripe"
    31  	// PoolMirrored is the mirror raid group.
    32  	PoolMirrored PoolType = "mirror"
    33  	// PoolRaidz is the raidz raid group.
    34  	PoolRaidz PoolType = "raidz"
    35  	// PoolRaidz2 is the raidz2 raid group.
    36  	PoolRaidz2 PoolType = "raidz2"
    37  )
    38  
    39  // +genclient
    40  // +genclient:noStatus
    41  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    42  // +k8s:openapi-gen=true
    43  // +resource:path=cstorpoolcluster
    44  
    45  // CStorPoolCluster describes a CStorPoolCluster custom resource.
    46  type CStorPoolCluster struct {
    47  	metav1.TypeMeta   `json:",inline"`
    48  	metav1.ObjectMeta `json:"metadata,omitempty"`
    49  	Spec              CStorPoolClusterSpec   `json:"spec"`
    50  	Status            CStorPoolClusterStatus `json:"status"`
    51  	VersionDetails    VersionDetails         `json:"versionDetails"`
    52  }
    53  
    54  // CStorPoolClusterSpec is the spec for a CStorPoolClusterSpec resource
    55  type CStorPoolClusterSpec struct {
    56  	// Pools is the spec for pools for various nodes
    57  	// where it should be created.
    58  	Pools []PoolSpec `json:"pools"`
    59  	// DefaultResources are the compute resources required by the cstor-pool
    60  	// container.
    61  	// If the resources at PoolConfig is not specified, this is written
    62  	// to CSPI PoolConfig.
    63  	DefaultResources *corev1.ResourceRequirements `json:"resources"`
    64  	// AuxResources are the compute resources required by the cstor-pool pod
    65  	// side car containers.
    66  	DefaultAuxResources *corev1.ResourceRequirements `json:"auxResources"`
    67  	// Tolerations, if specified, are the pool pod's tolerations
    68  	// If tolerations at PoolConfig is empty, this is written to
    69  	// CSPI PoolConfig.
    70  	Tolerations []corev1.Toleration `json:"tolerations"`
    71  
    72  	// DefaultPriorityClassName if specified applies to all the pool pods
    73  	// in the pool spec if the priorityClass at the pool level is
    74  	// not specified.
    75  	DefaultPriorityClassName string `json:"priorityClassName"`
    76  }
    77  
    78  //PoolSpec is the spec for pool on node where it should be created.
    79  type PoolSpec struct {
    80  	// NodeSelector is the labels that will be used to select
    81  	// a node for pool provisioning.
    82  	// Required field
    83  	NodeSelector map[string]string `json:"nodeSelector"`
    84  	// DataRaidGroups is the raid group configuration for the given pool.
    85  	DataRaidGroups []RaidGroup `json:"dataRaidGroups"`
    86  	// WriteCacheRaidGroups is the write cache raid group.
    87  	WriteCacheRaidGroups []RaidGroup `json:"writeCacheRaidGroups"`
    88  	// PoolConfig is the default pool config that applies to the
    89  	// pool on node.
    90  	PoolConfig PoolConfig `json:"poolConfig"`
    91  }
    92  
    93  // PoolConfig is the default pool config that applies to the
    94  // pool on node.
    95  type PoolConfig struct {
    96  	// DataRaidGroupType is the  raid type.
    97  	DataRaidGroupType string `json:"dataRaidGroupType"`
    98  
    99  	// WriteCacheGroupType is the write cache raid type.
   100  	WriteCacheGroupType string `json:"writeCacheGroupType"`
   101  
   102  	// ThickProvision to enable thick provisioning
   103  	// Optional -- defaults to false
   104  	ThickProvision bool `json:"thickProvision"`
   105  	// Compression to enable compression
   106  	// Optional -- defaults to off
   107  	// Possible values : lz, off
   108  	Compression string `json:"compression"`
   109  	// Resources are the compute resources required by the cstor-pool
   110  	// container.
   111  	Resources *corev1.ResourceRequirements `json:"resources"`
   112  	// AuxResources are the compute resources required by the cstor-pool pod
   113  	// side car containers.
   114  	AuxResources *corev1.ResourceRequirements `json:"auxResources"`
   115  	// Tolerations, if specified, the pool pod's tolerations.
   116  	Tolerations []corev1.Toleration `json:"tolerations"`
   117  
   118  	// PriorityClassName if specified applies to this pool pod
   119  	// If left empty, DefaultPriorityClassName is applied.
   120  	// (See CStorPoolClusterSpec.DefaultPriorityClassName)
   121  	// If both are empty, not priority class is applied.
   122  	PriorityClassName *string `json:"priorityClassName"`
   123  
   124  	// ROThresholdLimit is threshold(percentage base) limit
   125  	// for pool read only mode. If ROThresholdLimit(%) amount
   126  	// of pool storage is reached then pool will set to readonly.
   127  	// NOTE:
   128  	// 1. If ROThresholdLimit is set to 100 then entire
   129  	//    pool storage will be used by default it will be set to 85%.
   130  	// 2. ROThresholdLimit value will be 0 <= ROThresholdLimit <= 100.
   131  	ROThresholdLimit *int `json:"roThresholdLimit"` //optional
   132  }
   133  
   134  // RaidGroup contains the details of a raid group for the pool
   135  type RaidGroup struct {
   136  	CStorPoolInstanceBlockDevices []CStorPoolInstanceBlockDevice `json:"blockDevices"`
   137  }
   138  
   139  // CStorPoolInstanceBlockDevice contains the details of block devices that
   140  // constitutes a raid group.
   141  type CStorPoolInstanceBlockDevice struct {
   142  	// BlockDeviceName is the name of the block device.
   143  	BlockDeviceName string `json:"blockDeviceName"`
   144  	// Capacity is the capacity of the block device.
   145  	// It is system generated
   146  	Capacity uint64 `json:"capacity"`
   147  	// DevLink is the dev link for block devices
   148  	DevLink string `json:"devLink"`
   149  }
   150  
   151  // CStorPoolClusterStatus represents the latest available observations of a CSPC's current state.
   152  type CStorPoolClusterStatus struct {
   153  	// ProvisionedInstances is the the number of CSPI present at the current state.
   154  	ProvisionedInstances int32 `json:"provisionedInstances"`
   155  
   156  	// DesiredInstances is the number of CSPI(s) that should be provisioned.
   157  	DesiredInstances int32 `json:"desiredInstances"`
   158  
   159  	// HealthyInstances is the number of CSPI(s) that are healthy.
   160  	HealthyInstances int32 `json:"healthyInstances"`
   161  
   162  	// Current state of CSPC.
   163  	Conditions []CStorPoolClusterCondition `json:"conditions"`
   164  }
   165  
   166  type CSPCConditionType string
   167  
   168  // These are valid conditions of a cspc.
   169  const (
   170  	// PoolManagerAvailable means the PoolManagerAvailable deployment is available, ie. at least the minimum available
   171  	// replicas required are up and running and in ready state.
   172  	PoolManagerAvailable CSPCConditionType = "PoolManagerAvailable"
   173  )
   174  
   175  // CStorPoolClusterCondition describes the state of a CSPC at a certain point.
   176  type CStorPoolClusterCondition struct {
   177  	// Type of CSPC condition.
   178  	Type CSPCConditionType `json:"type"`
   179  	// Status of the condition, one of True, False, Unknown.
   180  	Status corev1.ConditionStatus `json:"status"`
   181  	// The last time this condition was updated.
   182  	LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
   183  	// Last time the condition transitioned from one status to another.
   184  	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
   185  	// The reason for the condition's last transition.
   186  	Reason string `json:"reason,omitempty"`
   187  	// A human readable message indicating details about the transition.
   188  	Message string `json:"message,omitempty"`
   189  }
   190  
   191  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   192  // +resource:path=cstorpoolclusters
   193  
   194  // CStorPoolClusterList is a list of CStorPoolCluster resources
   195  type CStorPoolClusterList struct {
   196  	metav1.TypeMeta `json:",inline"`
   197  	metav1.ListMeta `json:"metadata"`
   198  
   199  	Items []CStorPoolCluster `json:"items"`
   200  }