-
Notifications
You must be signed in to change notification settings - Fork 328
/
types.go
308 lines (273 loc) · 15.7 KB
/
types.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/*
* Tencent is pleased to support the open source community by making TKEStack
* available.
*
* Copyright (C) 2012-2019 Tencent. All Rights Reserved.
*
* 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
*
* https://opensource.org/licenses/Apache-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 OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package v1
import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ResourceList is a set of (resource name, quantity) pairs.
type ResourceList map[string]resource.Quantity
// ResourceRequirements describes the compute resource requirements.
type ResourceRequirements struct {
Limits ResourceList `json:"limits,omitempty" protobuf:"bytes,1,rep,name=limits,casttype=ResourceList"`
Requests ResourceList `json:"requests,omitempty" protobuf:"bytes,2,rep,name=requests,casttype=ResourceList"`
}
// +genclient
// +genclient:nonNamespaced
// +genclient:skipVerbs=deleteCollection
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Prometheus is a kubernetes package manager.
type Prometheus struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Spec defines the desired identities of clusters in this set.
// +optional
Spec PrometheusSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
// +optional
Status PrometheusStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PrometheusList is the whole list of all prometheus which owned by a tenant.
type PrometheusList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// List of Prometheuss
Items []Prometheus `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// PrometheusSpec describes the attributes on a Prometheus.
type PrometheusSpec struct {
TenantID string `json:"tenantID" protobuf:"bytes,1,opt,name=tenantID"`
ClusterName string `json:"clusterName" protobuf:"bytes,2,opt,name=clusterName"`
Version string `json:"version,omitempty" protobuf:"bytes,3,opt,name=version"`
// SubVersion is the components version such as node-exporter.
SubVersion map[string]string `json:"subVersion,omitempty" protobuf:"bytes,4,opt,name=subVersion"`
// RemoteAddress is the remote address for prometheus when writing/reading outside of cluster.
RemoteAddress PrometheusRemoteAddr `json:"remoteAddress,omitempty" protobuf:"bytes,5,opt,name=remoteAddress"`
// +optional
// NotifyWebhook is the address that alert messages send to, optional. If not set, a default webhook address "https://[notify-api-address]/webhook" will be used.
NotifyWebhook string `json:"notifyWebhook,omitempty" protobuf:"bytes,6,opt,name=notifyWebhook"`
// +optional
// Resources is the resource request and limit for prometheus
Resources ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,7,opt,name=resources"`
// +optional
// RunOnMaster indicates whether to add master Affinity for all monitor components or not
RunOnMaster bool `json:"runOnMaster,omitempty" protobuf:"bytes,8,opt,name=runOnMaster"`
// +optional
// AlertRepeatInterval indicates repeat interval of alerts
AlertRepeatInterval string `json:"alertRepeatInterval,omitempty" protobuf:"bytes,9,opt,name=alertRepeatInterval"`
// +optional
// WithNPD indicates whether to deploy node-problem-detector or not
WithNPD bool `json:"withNPD,omitempty" protobuf:"bytes,10,opt,name=withNPD"`
}
// PrometheusStatus is information about the current status of a Prometheus.
type PrometheusStatus struct {
// +optional
Version string `json:"version,omitempty" protobuf:"bytes,1,opt,name=version"`
// Phase is the current lifecycle phase of the helm of cluster.
// +optional
Phase AddonPhase `json:"phase,omitempty" protobuf:"bytes,2,opt,name=phase"`
// Reason is a brief CamelCase string that describes any failure.
// +optional
Reason string `json:"reason,omitempty" protobuf:"bytes,3,opt,name=reason"`
// RetryCount is a int between 0 and 5 that describes the time of retrying initializing.
// +optional
RetryCount int32 `json:"retryCount" protobuf:"varint,4,name=retryCount"`
// LastReInitializingTimestamp is a timestamp that describes the last time of retrying initializing.
// +optional
LastReInitializingTimestamp metav1.Time `json:"lastReInitializingTimestamp" protobuf:"bytes,5,name=lastReInitializingTimestamp"`
// SubVersion is the components version such as node-exporter.
SubVersion map[string]string `json:"subVersion,omitempty" protobuf:"bytes,6,opt,name=subVersion"`
}
// PrometheusRemoteAddr is the remote write/read address for prometheus
type PrometheusRemoteAddr struct {
WriteAddr []string `json:"writeAddr,omitempty" protobuf:"bytes,1,opt,name=writeAddr"`
ReadAddr []string `json:"readAddr,omitempty" protobuf:"bytes,2,opt,name=readAddr"`
}
// AddonPhase defines the phase of helm constructor.
type AddonPhase string
const (
// AddonPhaseInitializing means is wait initializing.
AddonPhaseInitializing AddonPhase = "Initializing"
// AddonPhaseReinitializing means is reinitializing.
AddonPhaseReinitializing AddonPhase = "Reinitializing"
// AddonPhaseChecking means is wait checking.
AddonPhaseChecking AddonPhase = "Checking"
// AddonPhaseRunning means is running.
AddonPhaseRunning AddonPhase = "Running"
// AddonPhaseUpgrading means is upgrading.
AddonPhaseUpgrading AddonPhase = "Upgrading"
// AddonPhaseFailed means has been failed.
AddonPhaseFailed AddonPhase = "Failed"
// AddonPhasePending means the controller is proceeding deploying
AddonPhasePending AddonPhase = "Pending"
// AddonPhaseUnhealthy means some pods of GPUManager is partial running
AddonPhaseUnhealthy AddonPhase = "Unhealthy"
// AddonPhaseTerminating means addon terminating
AddonPhaseTerminating AddonPhase = "Terminating"
// AddonPhaseUnknown means addon unknown
AddonPhaseUnknown AddonPhase = "Unknown"
)
// +genclient
// +genclient:nonNamespaced
// +genclient:onlyVerbs=create
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Metric defines the structure for querying monitoring data requests and results.
type Metric struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// +optional
Query MetricQuery `json:"query,omitempty" protobuf:"bytes,2,opt,name=query"`
// +optional
JSONResult string `json:"jsonResult,omitempty" protobuf:"bytes,3,opt,name=jsonResult"`
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// MetricList is the whole list of all metrics.
type MetricList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// List of metrics
Items []Metric `json:"items" protobuf:"bytes,2,rep,name=items"`
}
type MetricQuery struct {
Table string `json:"table" protobuf:"bytes,1,opt,name=table"`
// +optional
StartTime *int64 `json:"startTime,omitempty" protobuf:"varint,2,opt,name=startTime"`
// +optional
EndTime *int64 `json:"endTime,omitempty" protobuf:"varint,3,opt,name=endTime"`
Fields []string `json:"fields" protobuf:"bytes,4,rep,name=fields"`
Conditions []MetricQueryCondition `json:"conditions" protobuf:"bytes,5,rep,name=conditions"`
// +optional
OrderBy string `json:"orderBy,omitempty" protobuf:"bytes,6,opt,name=orderBy"`
// +optional
Order string `json:"order,omitempty" protobuf:"bytes,7,opt,name=order"`
GroupBy []string `json:"groupBy" protobuf:"bytes,8,rep,name=groupBy"`
Limit int32 `json:"limit" protobuf:"varint,9,opt,name=limit"`
Offset int32 `json:"offset" protobuf:"varint,10,opt,name=offset"`
}
type MetricQueryCondition struct {
Key string `json:"key" protobuf:"bytes,1,opt,name=key"`
Expr string `json:"expr" protobuf:"bytes,2,opt,name=expr"`
Value string `json:"value" protobuf:"bytes,3,opt,name=value"`
}
// +genclient
// +genclient:nonNamespaced
// +genclient:onlyVerbs=create
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterOverview defines the structure for querying clusters' overview data request and result.
type ClusterOverview struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// +optional
Result *ClusterOverviewResult `json:"result,omitempty" protobuf:"bytes,2,opt,name=result"`
}
type ClusterOverviewResult struct {
ClusterCount int32 `json:"clusterCount" protobuf:"bytes,1,opt,name=clusterCount"`
ClusterAbnormal int32 `json:"clusterAbnormal" protobuf:"bytes,2,opt,name=clusterAbnormal"`
ProjectCount int32 `json:"projectCount" protobuf:"bytes,3,opt,name=projectCount"`
ProjectAbnormal int32 `json:"projectAbnormal" protobuf:"bytes,4,opt,name=projectAbnormal"`
NodeCount int32 `json:"nodeCount" protobuf:"bytes,5,opt,name=nodeCount"`
NodeAbnormal int32 `json:"nodeAbnormal" protobuf:"bytes,6,opt,name=nodeAbnormal"`
WorkloadCount int32 `json:"workloadCount" protobuf:"bytes,7,opt,name=workloadCount"`
WorkloadAbnormal int32 `json:"workloadAbnormal" protobuf:"bytes,8,opt,name=workloadAbnormal"`
CPUCapacity float64 `json:"cpuCapacity" protobuf:"bytes,9,opt,name=cpuCapacity"`
CPUAllocatable float64 `json:"cpuAllocatable" protobuf:"bytes,10,opt,name=cpuAllocatable"`
CPUNotReadyCapacity float64 `json:"cpuNotReadyCapacity" protobuf:"bytes,11,opt,name=cpuNotReadyCapacity"`
CPUNotReadyAllocatable float64 `json:"cpuNotReadyAllocatable" protobuf:"bytes,12,opt,name=cpuNotReadyAllocatable"`
MemCapacity int64 `json:"memCapacity" protobuf:"bytes,13,opt,name=memCapacity"`
MemAllocatable int64 `json:"memAllocatable" protobuf:"bytes,14,opt,name=memAllocatable"`
MemNotReadyCapacity int64 `json:"memNotReadyCapacity" protobuf:"bytes,15,opt,name=memNotReadyCapacity"`
MemNotReadyAllocatable int64 `json:"memNotReadyAllocatable" protobuf:"bytes,16,opt,name=memNotReadyAllocatable"`
PodCount int32 `json:"podCount" protobuf:"bytes,17,opt,name=podCount"`
Clusters []*ClusterStatistic `json:"clusters" protobuf:"bytes,18,opt,name=clusters"`
}
type ClusterStatistic struct {
ClusterID string `json:"clusterID" protobuf:"bytes,1,opt,name=clusterID"`
ClusterDisplayName string `json:"clusterDisplayName" protobuf:"bytes,2,opt,name=clusterDisplayName"`
TenantID string `json:"tenantID" protobuf:"bytes,3,opt,name=tenantID"`
ClusterPhase string `json:"clusterPhase" protobuf:"bytes,4,opt,name=clusterPhase"`
NodeCount int32 `json:"nodeCount" protobuf:"bytes,5,opt,name=nodeCount"`
NodeAbnormal int32 `json:"nodeAbnormal" protobuf:"bytes,6,opt,name=nodeAbnormal"`
WorkloadCount int32 `json:"workloadCount" protobuf:"bytes,7,opt,name=workloadCount"`
WorkloadAbnormal int32 `json:"workloadAbnormal" protobuf:"bytes,8,opt,name=workloadAbnormal"`
HasMetricServer bool `json:"hasMetricServer" protobuf:"bytes,9,opt,name=hasMetricServer"`
CPUUsed float64 `json:"cpuUsed" protobuf:"bytes,10,opt,name=cpuUsed"`
CPURequest float64 `json:"cpuRequest" protobuf:"bytes,11,opt,name=cpuRequest"`
CPULimit float64 `json:"cpuLimit" protobuf:"bytes,12,opt,name=cpuLimit"`
CPUCapacity float64 `json:"cpuCapacity" protobuf:"bytes,13,opt,name=cpuCapacity"`
CPUAllocatable float64 `json:"cpuAllocatable" protobuf:"bytes,14,opt,name=cpuAllocatable"`
CPUNotReadyCapacity float64 `json:"cpuNotReadyCapacity" protobuf:"bytes,15,opt,name=cpuNotReadyCapacity"`
CPUNotReadyAllocatable float64 `json:"cpuNotReadyAllocatable" protobuf:"bytes,16,opt,name=cpuNotReadyAllocatable"`
CPURequestRate string `json:"cpuRequestRate" protobuf:"bytes,17,opt,name=cpuRequestRate"`
CPUAllocatableRate string `json:"cpuAllocatableRate" protobuf:"bytes,18,opt,name=cpuAllocatableRate"`
CPUUsage string `json:"cpuUsage" protobuf:"bytes,19,opt,name=cpuUsage"`
MemUsed int64 `json:"memUsed" protobuf:"bytes,20,opt,name=memUsed"`
MemRequest int64 `json:"memRequest" protobuf:"bytes,21,opt,name=memRequest"`
MemLimit int64 `json:"memLimit" protobuf:"bytes,22,opt,name=memLimit"`
MemCapacity int64 `json:"memCapacity" protobuf:"bytes,23,opt,name=memCapacity"`
MemAllocatable int64 `json:"memAllocatable" protobuf:"bytes,24,opt,name=memAllocatable"`
MemNotReadyCapacity int64 `json:"memNotReadyCapacity" protobuf:"bytes,25,opt,name=memNotReadyCapacity"`
MemNotReadyAllocatable int64 `json:"memNotReadyAllocatable" protobuf:"bytes,26,opt,name=memNotReadyAllocatable"`
MemRequestRate string `json:"memRequestRate" protobuf:"bytes,27,opt,name=memRequestRate"`
MemAllocatableRate string `json:"memAllocatableRate" protobuf:"bytes,28,opt,name=memAllocatableRate"`
MemUsage string `json:"memUsage" protobuf:"bytes,29,opt,name=memUsage"`
PodCount int32 `json:"podCount" protobuf:"bytes,30,opt,name=podCount"`
SchedulerHealthy bool `json:"schedulerHealthy" protobuf:"bytes,31,opt,name=schedulerHealthy"`
ControllerManagerHealthy bool `json:"controllerManagerHealthy" protobuf:"bytes,32,opt,name=controllerManagerHealthy"`
EtcdHealthy bool `json:"etcdHealthy" protobuf:"bytes,33,opt,name=etcdHealthy"`
}
// +genclient
// +genclient:nonNamespaced
// +genclient:skipVerbs=deleteCollection
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ConfigMap holds configuration data for tke to consume.
type ConfigMap struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Data contains the configuration data.
// Each key must consist of alphanumeric characters, '-', '_' or '.'.
// Values with non-UTF-8 byte sequences must use the BinaryData field.
// The keys stored in Data must not overlap with the keys in
// the BinaryData field, this is enforced during validation process.
// +optional
Data map[string]string `json:"data,omitempty" protobuf:"bytes,2,rep,name=data"`
// BinaryData contains the binary data.
// Each key must consist of alphanumeric characters, '-', '_' or '.'.
// BinaryData can contain byte sequences that are not in the UTF-8 range.
// The keys stored in BinaryData must not overlap with the ones in
// the Data field, this is enforced during validation process.
// +optional
BinaryData map[string][]byte `json:"binaryData,omitempty" protobuf:"bytes,3,rep,name=binaryData"`
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ConfigMapList is a resource containing a list of ConfigMap objects.
type ConfigMapList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Items is the list of ConfigMaps.
Items []ConfigMap `json:"items" protobuf:"bytes,2,rep,name=items"`
}