/
cstorvolume_policy.go
129 lines (104 loc) · 4.6 KB
/
cstorvolume_policy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
Copyright 2019 The OpenEBS Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// CStorVolumePolicy describes a configuration required for cstor volume
// resources
type CStorVolumePolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec defines a configuration info of a cstor volume required
// to provisione cstor volume resources
Spec CStorVolumePolicySpec `json:"spec"`
Status CStorVolumePolicyStatus `json:"status"`
}
// CStorVolumePolicySpec ...
type CStorVolumePolicySpec struct {
// replicaAffinity is set to true then volume replica resources need to be
// distributed across the pool instances
Provision Provision `json:"provision"`
// TargetSpec represents configuration related to cstor target and its resources
Target TargetSpec `json:"target"`
// ReplicaSpec represents configuration related to replicas resources
Replica ReplicaSpec `json:"replica"`
// ReplicaPoolInfo holds the pool information of volume replicas.
// Ex: If volume is provisioned on which CStor pool volume replicas exist
ReplicaPoolInfo []ReplicaPoolInfo `json:"replicaPoolInfo"`
}
// TargetSpec represents configuration related to cstor target and its resources
type TargetSpec struct {
// QueueDepth sets the queue size at iSCSI target which limits the
// ongoing IO count from client
QueueDepth string `json:"queueDepth,omitempty"`
// Luworkers sets the number of threads that are working on above queue
LuWorkers int64 `json:"luWorkers,omitempty"`
// Monitor enables or disables the target exporter sidecar
Monitor bool `json:"monitor,omitempty"`
// ReplicationFactor represents maximum number of replicas
// that are allowed to connect to the target
ReplicationFactor int64 `json:"replicationFactor,omitempty"`
// Resources are the compute resources required by the cstor-target
// container.
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
// AuxResources are the compute resources required by the cstor-target pod
// side car containers.
AuxResources *corev1.ResourceRequirements `json:"auxResources,omitempty"`
// Tolerations, if specified, are the target pod's tolerations
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// Affinity if specified, are the target pod's affinities
Affinity *corev1.PodAffinity `json:"affinity,omitempty"`
// NodeSelector is the labels that will be used to select
// a node for target pod scheduleing
// Required field
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// PriorityClassName if specified applies to this target pod
// If left empty, no priority class is applied.
PriorityClassName string `json:"priorityClassName,omitempty"`
}
// ReplicaSpec represents configuration related to replicas resources
type ReplicaSpec struct {
// ZvolWorkers represents number of threads that executes client IOs
ZvolWorkers string `json:"zvolWorkers"`
// Affinity if specified, are the replica affinities
Affinity *corev1.PodAffinity `json:"affinity"`
}
// Provision represents volume provisioning configuration
type Provision struct {
// replicaAffinity is set to true then volume replica resources need to be
// distributed across the cstor pool instances based on the given topology
ReplicaAffinity bool `json:"replicaAffinity"`
}
// ReplicaPoolInfo represents the pool information of volume replica
type ReplicaPoolInfo struct {
// PoolName represents the pool name where volume replica exists
PoolName string `json:"poolName"`
// UID also can be added
}
// CStorVolumePolicyStatus is for handling status of CstorVolumePolicy
type CStorVolumePolicyStatus struct {
Phase string `json:"phase"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// CStorVolumePolicyList is a list of CStorVolumePolicy resources
type CStorVolumePolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []CStorVolumePolicy `json:"items"`
}