forked from gocrane/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
156 lines (125 loc) · 5.58 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
package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// CPUManagerPolicy represents policy of the crane agent cpu manager.
type CPUManagerPolicy string
const (
// CPUManagerPolicyNone name of none policy.
CPUManagerPolicyNone CPUManagerPolicy = "None"
// CPUManagerPolicyStatic is the name of the static policy.
CPUManagerPolicyStatic CPUManagerPolicy = "Static"
)
// TopologyManagerPolicy represents policy of the crane agent resource management component.
type TopologyManagerPolicy string
// Constants of type TopologyManagerPolicy represent policy of the agent
// node's resource management component. It's TopologyManager in kubele.
const (
// TopologyManagerPolicyNone policy is the default policy and does not perform any topology alignment.
TopologyManagerPolicyNone TopologyManagerPolicy = "None"
// TopologyManagerPolicySingleNUMANodePodLevel enables pod level resource counting, this policy assumes
// TopologyManager policy single-numa-node also was set on the node.
TopologyManagerPolicySingleNUMANodePodLevel TopologyManagerPolicy = "SingleNUMANodePodLevel"
)
// ZoneType string describes a topology type for a zone
type ZoneType string
const (
ZoneTypeNode ZoneType = "Node"
ZoneTypeSocket ZoneType = "Socket"
ZoneTypeCore ZoneType = "Core"
)
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:scope="Cluster",shortName=nrt
// +kubebuilder:printcolumn:name="CRANE CPU MANAGER POLICY",type=string,JSONPath=".craneManagerPolicy.cpuManagerPolicy",description="CPUManagerPolicy represents policy of the crane agent cpu manager."
// +kubebuilder:printcolumn:name="CRANE TOPOLOGY MANAGER POLICY",type=string,JSONPath=".craneManagerPolicy.topologyManagerPolicy",description="TopologyManagerPolicy represents policy of the crane agent resource management component. Defaults to SingleNUMANodePodLevel."
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created."
// NodeResourceTopology describes node resources and their topology.
type NodeResourceTopology struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// CraneManagerPolicy describes the associated manager policy of crane agent.
// +required
CraneManagerPolicy ManagerPolicy `json:"craneManagerPolicy"`
// Reserved describes resources reserved for system and kubernetes components.
// +optional
Reserved corev1.ResourceList `json:"reserved,omitempty"`
// Zones represents all resource topology zones of a node.
// +optional
Zones ZoneList `json:"zones,omitempty"`
// Attributes represents node attributes if any.
// +optional
Attributes map[string]string `json:"attributes,omitempty"`
}
// ManagerPolicy describes the associated manager policy.
type ManagerPolicy struct {
// CPUManagerPolicy represents policy of the crane agent cpu manager.
// +kubebuilder:validation:Enum=None;Static
// +required
CPUManagerPolicy CPUManagerPolicy `json:"cpuManagerPolicy"`
// TopologyManagerPolicy represents policy of the crane agent resource management component.
// Defaults to SingleNUMANodePodLevel.
// +kubebuilder:validation:Enum=None;SingleNUMANodePodLevel
// +kubebuilder:default=SingleNUMANodePodLevel
// +required
TopologyManagerPolicy TopologyManagerPolicy `json:"topologyManagerPolicy"`
}
// Zone represents a resource topology zone, e.g. socket, node, die or core.
type Zone struct {
// Name represents the zone name.
// +required
Name string `json:"name"`
// Type represents the zone type.
// +kubebuilder:validation:Enum=Node;Socket;Core
// +required
Type ZoneType `json:"type"`
// Parent represents the name of parent zone.
// +optional
Parent string `json:"parent,omitempty"`
// Costs represents the cost between different zones.
// +optional
Costs CostList `json:"costs,omitempty"`
// Attributes represents zone attributes if any.
// +optional
Attributes map[string]string `json:"attributes,omitempty"`
// Resources represents the resource info of the zone.
// +optional
Resources *ResourceInfo `json:"resources,omitempty"`
}
// ZoneList contains an array of Zone objects.
type ZoneList []Zone
// ResourceInfo contains information about one resource type.
type ResourceInfo struct {
// Capacity of the resource, corresponding to capacity in node status, i.e.
// total amount of this resource that the node has.
// +optional
Capacity corev1.ResourceList `json:"capacity,omitempty"`
// Allocatable quantity of the resource, corresponding to allocatable in
// node status, i.e. total amount of this resource available to be used by
// pods.
// +optional
Allocatable corev1.ResourceList `json:"allocatable,omitempty"`
// ReservedCPUNums specifies the cpu numbers reserved for the host level system threads and kubernetes related threads.
// +optional
ReservedCPUNums int32 `json:"reservedCPUNums,omitempty"`
}
// CostInfo describes the cost (or distance) between two Zones.
type CostInfo struct {
// Name represents the zone name.
// +required
Name string `json:"name"`
// Value represents the cost value.
// +required
Value int64 `json:"value"`
}
// CostList contains an array of CostInfo objects.
type CostList []CostInfo
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// NodeResourceTopologyList is a list of NodeResourceTopology resources
type NodeResourceTopologyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []NodeResourceTopology `json:"items"`
}