@@ -2,9 +2,30 @@ package cluster
2
2
3
3
import (
4
4
corev1 "k8s.io/api/core/v1"
5
+ "k8s.io/apimachinery/pkg/api/resource"
5
6
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6
7
)
7
8
9
+ // ResourceName is the name identifying various resources in a ResourceList.
10
+ type ResourceName string
11
+
12
+ // Resource names must be not more than 63 characters, consisting of upper- or lower-case alphanumeric characters,
13
+ // with the -, _, and . characters allowed anywhere, except the first or last character.
14
+ // The default convention, matching that for annotations, is to use lower-case names, with dashes, rather than
15
+ // camel case, separating compound words.
16
+ // Fully-qualified resource typenames are constructed from a DNS-style subdomain, followed by a slash `/` and a name.
17
+ const (
18
+ // ResourceCPU in cores. (e,g. 500m = .5 cores)
19
+ ResourceCPU ResourceName = "cpu"
20
+ // ResourceMemory in bytes. (e,g. 500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
21
+ ResourceMemory ResourceName = "memory"
22
+ // ResourceStorage is volume size, in bytes (e,g. 5Gi = 5GiB = 5 * 1024 * 1024 * 1024)
23
+ ResourceStorage ResourceName = "storage"
24
+ // ResourceEphemeralStorage is local ephemeral storage, in bytes. (e,g. 500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
25
+ // The resource name for ResourceEphemeralStorage is alpha and it can change across releases.
26
+ ResourceEphemeralStorage ResourceName = "ephemeral-storage"
27
+ )
28
+
8
29
//revive:disable:exported
9
30
10
31
// +genclient
@@ -26,6 +47,26 @@ type Cluster struct {
26
47
27
48
// ClusterSpec defines the desired state of a member cluster.
28
49
type ClusterSpec struct {
50
+ // ID is the unique identifier for the cluster.
51
+ // It is different from the object uid(.metadata.uid) and typically collected automatically
52
+ // from member cluster during the progress of registration.
53
+ //
54
+ // The value is collected in order:
55
+ // 1. If the registering cluster enabled ClusterProperty API and defined the cluster ID by
56
+ // creating a ClusterProperty object with name 'cluster.clusterset.k8s.io', Karmada would
57
+ // take the defined value in the ClusterProperty object.
58
+ // See https://github.com/kubernetes-sigs/about-api for more details about ClusterProperty API.
59
+ // 2. Take the uid of 'kube-system' namespace on the registering cluster.
60
+ //
61
+ // Please don't update this value unless you know what you are doing, because
62
+ // it will/may be used to :
63
+ // - uniquely identify the clusters within the Karmada system.
64
+ // - compose the DNS name of multi-cluster services.
65
+ //
66
+ // +optional
67
+ // +kubebuilder:validation:Maxlength=128000
68
+ ID string `json:"id,omitempty"`
69
+
29
70
// SyncMode describes how a cluster sync resources from karmada control plane.
30
71
// +required
31
72
SyncMode ClusterSyncMode
@@ -61,6 +102,12 @@ type ClusterSpec struct {
61
102
// +optional
62
103
ProxyURL string
63
104
105
+ // ProxyHeader is the HTTP header required by proxy server.
106
+ // The key in the key-value pair is HTTP header key and value is the associated header payloads.
107
+ // For the header with multiple values, the values should be separated by comma(e.g. 'k1': 'v1,v2,v3').
108
+ // +optional
109
+ ProxyHeader map [string ]string
110
+
64
111
// Provider represents the cloud provider name of the member cluster.
65
112
// +optional
66
113
Provider string
@@ -78,6 +125,104 @@ type ClusterSpec struct {
78
125
// any resource that does not tolerate the Taint.
79
126
// +optional
80
127
Taints []corev1.Taint
128
+
129
+ // ResourceModels is the list of resource modeling in this cluster. Each modeling quota can be customized by the user.
130
+ // Modeling name must be one of the following: cpu, memory, storage, ephemeral-storage.
131
+ // If the user does not define the modeling name and modeling quota, it will be the default model.
132
+ // The default model grade from 0 to 8.
133
+ // When grade = 0 or grade = 1, the default model's cpu quota and memory quota is a fix value.
134
+ // When grade greater than or equal to 2, each default model's cpu quota is [2^(grade-1), 2^grade), 2 <= grade <= 7
135
+ // Each default model's memory quota is [2^(grade + 2), 2^(grade + 3)), 2 <= grade <= 7
136
+ // E.g. grade 0 likes this:
137
+ // - grade: 0
138
+ // ranges:
139
+ // - name: "cpu"
140
+ // min: 0 C
141
+ // max: 1 C
142
+ // - name: "memory"
143
+ // min: 0 GB
144
+ // max: 4 GB
145
+ //
146
+ // - grade: 1
147
+ // ranges:
148
+ // - name: "cpu"
149
+ // min: 1 C
150
+ // max: 2 C
151
+ // - name: "memory"
152
+ // min: 4 GB
153
+ // max: 16 GB
154
+ //
155
+ // - grade: 2
156
+ // ranges:
157
+ // - name: "cpu"
158
+ // min: 2 C
159
+ // max: 4 C
160
+ // - name: "memory"
161
+ // min: 16 GB
162
+ // max: 32 GB
163
+ //
164
+ // - grade: 7
165
+ // range:
166
+ // - name: "cpu"
167
+ // min: 64 C
168
+ // max: 128 C
169
+ // - name: "memory"
170
+ // min: 512 GB
171
+ // max: 1024 GB
172
+ //
173
+ // grade 8, the last one likes below. No matter what Max value you pass,
174
+ // the meaning of Max value in this grade is infinite. You can pass any number greater than Min value.
175
+ // - grade: 8
176
+ // range:
177
+ // - name: "cpu"
178
+ // min: 128 C
179
+ // max: MAXINT
180
+ // - name: "memory"
181
+ // min: 1024 GB
182
+ // max: MAXINT
183
+ //
184
+ // +optional
185
+ ResourceModels []ResourceModel
186
+ }
187
+
188
+ // ResourceModel describes the modeling that you want to statistics.
189
+ type ResourceModel struct {
190
+ // Grade is the index for the resource modeling.
191
+ // +required
192
+ Grade uint
193
+
194
+ // Ranges describes the resource quota ranges.
195
+ // +required
196
+ Ranges []ResourceModelRange
197
+ }
198
+
199
+ // ResourceModelRange describes the detail of each modeling quota that ranges from min to max.
200
+ // Please pay attention, by default, the value of min can be inclusive, and the value of max cannot be inclusive.
201
+ // E.g. in an interval, min = 2, max =10 is set, which means the interval [2,10).
202
+ // This rule ensure that all intervals have the same meaning. If the last interval is +¡Þ,
203
+ // it is definitely unreachable. Therefore, we define the right interval as the open interval.
204
+ // For a valid interval, the value on the right is greater than the value on the left,
205
+ // in other words, max must be greater than min.
206
+ // It is strongly recommended that the [Min, Max) of all ResourceModelRanges can make a continuous interval.
207
+ type ResourceModelRange struct {
208
+ // Name is the name for the resource that you want to categorize.
209
+ // +required
210
+ Name ResourceName
211
+
212
+ // Min is the minimum amount of this resource represented by resource name.
213
+ // Note: The Min value of first grade(usually 0) always acts as zero.
214
+ // E.g. [1,2) equal to [0,2).
215
+ // +required
216
+ Min resource.Quantity
217
+
218
+ // Max is the maximum amount of this resource represented by resource name.
219
+ // Special Instructions, for the last ResourceModelRange, which no matter what Max value you pass,
220
+ // the meaning is infinite. Because for the last item,
221
+ // any ResourceModelRange's quota larger than Min will be classified to the last one.
222
+ // Of course, the value of the Max field is always greater than the value of the Min field.
223
+ // It should be true in any case.
224
+ // +required
225
+ Max resource.Quantity
81
226
}
82
227
83
228
const (
@@ -190,6 +335,22 @@ type ResourceSummary struct {
190
335
// Total amount of required resources of all Pods that have been scheduled to nodes.
191
336
// +optional
192
337
Allocated corev1.ResourceList
338
+
339
+ // AllocatableModelings represents the statistical resource modeling.
340
+ // +optional
341
+ AllocatableModelings []AllocatableModeling
342
+ }
343
+
344
+ // AllocatableModeling represents the number of nodes in which allocatable resources in a specific resource model grade.
345
+ // E.g. AllocatableModeling{Grade: 2, Count: 10} means 10 nodes belong to resource model in grade 2.
346
+ type AllocatableModeling struct {
347
+ // Grade is the index of ResourceModel.
348
+ // +required
349
+ Grade uint
350
+
351
+ // Count is the number of nodes that own the resources delineated by this modeling.
352
+ // +required
353
+ Count int
193
354
}
194
355
195
356
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
0 commit comments