-
Notifications
You must be signed in to change notification settings - Fork 315
/
nodemetric_types.go
150 lines (123 loc) · 5.66 KB
/
nodemetric_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
/*
Copyright 2022 The Koordinator 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 (
apiext "github.com/koordinator-sh/koordinator/apis/extension"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// default NodeMemoryCollectPolicy is usageWithoutPageCache
// +kubebuilder:validation:Enum=usageWithHotPageCache;usageWithoutPageCache;usageWithPageCache
type NodeMemoryCollectPolicy string
const (
UsageWithoutPageCache NodeMemoryCollectPolicy = "usageWithoutPageCache"
UsageWithHotPageCache NodeMemoryCollectPolicy = "usageWithHotPageCache"
// TODO(BUPT-wxq): implement the UsageWithPageCache policy
UsageWithPageCache NodeMemoryCollectPolicy = "usageWithPageCache"
)
type NodeMetricInfo struct {
// NodeUsage is the total resource usage of node
NodeUsage ResourceMap `json:"nodeUsage,omitempty"`
// AggregatedNodeUsages will report only if there are enough samples
AggregatedNodeUsages []AggregatedUsage `json:"aggregatedNodeUsages,omitempty"`
// SystemUsage is the resource usage of daemon processes and OS kernel, calculated by `NodeUsage - sum(podUsage)`
SystemUsage ResourceMap `json:"systemUsage,omitempty"`
// AggregatedSystemUsages will report only if there are enough samples
// Deleted pods will be excluded during aggregation
AggregatedSystemUsages []AggregatedUsage `json:"aggregatedSystemUsages,omitempty"`
}
type AggregatedUsage struct {
Usage map[apiext.AggregationType]ResourceMap `json:"usage,omitempty"`
Duration metav1.Duration `json:"duration,omitempty"`
}
type PodMetricInfo struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
PodUsage ResourceMap `json:"podUsage,omitempty"`
// Priority class of the application
Priority apiext.PriorityClass `json:"priority,omitempty"`
// QoS class of the application
QoS apiext.QoSClass `json:"qos,omitempty"`
// Third party extensions for PodMetric
Extensions *ExtensionsMap `json:"extensions,omitempty"`
}
type HostApplicationMetricInfo struct {
// Name of the host application
Name string `json:"name,omitempty"`
// Resource usage of the host application
Usage ResourceMap `json:"usage,omitempty"`
// Priority class of the application
Priority apiext.PriorityClass `json:"priority,omitempty"`
// QoS class of the application
QoS apiext.QoSClass `json:"qos,omitempty"`
}
// NodeMetricSpec defines the desired state of NodeMetric
type NodeMetricSpec struct {
// CollectPolicy defines the Metric collection policy
CollectPolicy *NodeMetricCollectPolicy `json:"metricCollectPolicy,omitempty"`
}
// NodeMetricCollectPolicy defines the Metric collection policy
type NodeMetricCollectPolicy struct {
// AggregateDurationSeconds represents the aggregation period in seconds
AggregateDurationSeconds *int64 `json:"aggregateDurationSeconds,omitempty"`
// ReportIntervalSeconds represents the report period in seconds
ReportIntervalSeconds *int64 `json:"reportIntervalSeconds,omitempty"`
// NodeAggregatePolicy represents the target grain of node aggregated usage
NodeAggregatePolicy *AggregatePolicy `json:"nodeAggregatePolicy,omitempty"`
// NodeMemoryPolicy represents apply which method collect memory info
NodeMemoryCollectPolicy *NodeMemoryCollectPolicy `json:"nodeMemoryCollectPolicy,omitempty"`
}
type AggregatePolicy struct {
Durations []metav1.Duration `json:"durations,omitempty"`
}
// ReclaimableMetric defines the reclaimable metric of resource priority
type ReclaimableMetric struct {
// Resource is the resource usage of the prediction
Resource ResourceMap `json:"resource,omitempty"`
}
// NodeMetricStatus defines the observed state of NodeMetric
type NodeMetricStatus struct {
// UpdateTime is the last time this NodeMetric was updated.
UpdateTime *metav1.Time `json:"updateTime,omitempty"`
// NodeMetric contains the metrics for this node.
NodeMetric *NodeMetricInfo `json:"nodeMetric,omitempty"`
// PodsMetric contains the metrics for pods belong to this node.
PodsMetric []*PodMetricInfo `json:"podsMetric,omitempty"`
// HostApplicationMetric contains the metrics of out-out-band applications on node.
HostApplicationMetric []*HostApplicationMetricInfo `json:"hostApplicationMetric,omitempty"`
// ProdReclaimableMetric is the indicator statistics of Prod type resources reclaimable
ProdReclaimableMetric *ReclaimableMetric `json:"prodReclaimableMetric,omitempty"`
}
// +genclient
// +genclient:nonNamespaced
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// NodeMetric is the Schema for the nodemetrics API
type NodeMetric struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec NodeMetricSpec `json:"spec,omitempty"`
Status NodeMetricStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// NodeMetricList contains a list of NodeMetric
type NodeMetricList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NodeMetric `json:"items"`
}
func init() {
SchemeBuilder.Register(&NodeMetric{}, &NodeMetricList{})
}