Skip to content

Commit 82f7a74

Browse files
authored
Merge pull request #52 from yan234280533/dev-qos-class
add qos and priority class defination for ensurance
2 parents 54464ca + f27b10a commit 82f7a74

File tree

20 files changed

+858
-31
lines changed

20 files changed

+858
-31
lines changed

analysis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

artifacts/deploy/ensurance.crane.io_avoidanceactions.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ spec:
1313
kind: AvoidanceAction
1414
listKind: AvoidanceActionList
1515
plural: avoidanceactions
16+
shortNames:
17+
- avoid
1618
singular: avoidanceaction
1719
scope: Cluster
1820
versions:

artifacts/deploy/ensurance.crane.io_nodeqosensurancepolicies.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ spec:
1313
kind: NodeQOSEnsurancePolicy
1414
listKind: NodeQOSEnsurancePolicyList
1515
plural: nodeqosensurancepolicies
16+
shortNames:
17+
- nep
1618
singular: nodeqosensurancepolicy
1719
scope: Cluster
1820
versions:
@@ -95,7 +97,8 @@ spec:
9597
type: integer
9698
type: object
9799
timeoutSeconds:
98-
description: TimeoutSeconds is the timeout for request
100+
description: TimeoutSeconds is the timeout for request. Defaults
101+
to 0, no timeout forever.
99102
format: int32
100103
type: integer
101104
type: object

artifacts/deploy/ensurance.crane.io_podqosensurancepolicies.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ spec:
1313
kind: PodQOSEnsurancePolicy
1414
listKind: PodQOSEnsurancePolicyList
1515
plural: podqosensurancepolicies
16+
shortNames:
17+
- qep
1618
singular: podqosensurancepolicy
1719
scope: Namespaced
1820
versions:
@@ -182,12 +184,9 @@ spec:
182184
required:
183185
- port
184186
type: object
185-
initialDelaySeconds:
186-
description: Init delay time for handler Defaults to 5
187-
format: int32
188-
type: integer
189187
timeoutSeconds:
190-
description: Timeout for request. Defaults to 0, instead not timeout
188+
description: TimeoutSeconds is the timeout for request. Defaults
189+
to 0, no timeout forever
191190
format: int32
192191
type: integer
193192
type: object
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.7.0
8+
creationTimestamp: null
9+
name: servicepolicies.ensurance.crane.io
10+
spec:
11+
group: ensurance.crane.io
12+
names:
13+
kind: ServicePolicy
14+
listKind: ServicePolicyList
15+
plural: servicepolicies
16+
shortNames:
17+
- sp
18+
singular: servicepolicy
19+
scope: Cluster
20+
versions:
21+
- name: v1alpha1
22+
schema:
23+
openAPIV3Schema:
24+
description: ServicePolicy defines the behaviours for the pods which have
25+
the same priority class
26+
properties:
27+
apiVersion:
28+
description: 'APIVersion defines the versioned schema of this representation
29+
of an object. Servers should convert recognized schemas to the latest
30+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
31+
type: string
32+
kind:
33+
description: 'Kind is a string value representing the REST resource this
34+
object represents. Servers may infer this from the endpoint the client
35+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
properties:
41+
avoidanceStrategy:
42+
description: AvoidanceStrategy defines the avoidance strategy for
43+
pods
44+
properties:
45+
allowEvict:
46+
type: boolean
47+
allowThrottle:
48+
type: boolean
49+
type: object
50+
priorityClassName:
51+
description: PriorityClassName is the priority class name used in
52+
the pods.
53+
type: string
54+
resourceMutation:
55+
description: ResourcetMutation defines if the service need to mutate
56+
resource to expand resource
57+
properties:
58+
limitMutations:
59+
items:
60+
properties:
61+
mutatingResourceName:
62+
description: MutatingResourceName is the resource name mutate
63+
type: string
64+
resourceName:
65+
description: ResourceName is the origin resource name which
66+
to be mutated
67+
enum:
68+
- cpu
69+
- memory
70+
type: string
71+
type: object
72+
type: array
73+
requestMutations:
74+
items:
75+
properties:
76+
mutatingResourceName:
77+
description: MutatingResourceName is the resource name mutate
78+
type: string
79+
resourceName:
80+
description: ResourceName is the origin resource name which
81+
to be mutated
82+
enum:
83+
- cpu
84+
- memory
85+
type: string
86+
type: object
87+
type: array
88+
type: object
89+
resourcePriority:
90+
description: ResourcePriority defines the priority for various resources
91+
properties:
92+
cpuPriority:
93+
description: CPUPriority define the cpu priority for the pods.
94+
CPUPriority range [0,7], 0 is the highest level. When the cpu
95+
resource is shortage, the low level pods would be throttled
96+
format: int32
97+
maximum: 7
98+
minimum: 0
99+
type: integer
100+
memoryPriority:
101+
description: MemoryPriority define the memory priority for the
102+
pods. MemoryPriority range [0,7], 0 is the highest level When
103+
the memory is shortage, the low level pods would priority be
104+
killed
105+
format: int32
106+
maximum: 7
107+
minimum: 0
108+
type: integer
109+
networkIOPriority:
110+
description: NetworkIOPriority define the network IO priority
111+
for the pods. NetworkIOPriority range [0,7], 0 is the highest
112+
level. When the network device is busy, the low level pods would
113+
be throttled
114+
format: int32
115+
maximum: 7
116+
minimum: 0
117+
type: integer
118+
type: object
119+
required:
120+
- priorityClassName
121+
type: object
122+
status:
123+
description: ServicePolicyStatus defines the desired status of ServicePolicy
124+
type: object
125+
required:
126+
- spec
127+
type: object
128+
served: true
129+
storage: true
130+
subresources:
131+
status: {}
132+
status:
133+
acceptedNames:
134+
kind: ""
135+
plural: ""
136+
conditions: []
137+
storedVersions: []

autoscaling/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ensurance/v1alpha1/types.go

Lines changed: 107 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,104 @@ const (
1515
AvoidanceActionStrategyPreview AvoidanceActionStrategy = "Preview"
1616
)
1717

18+
// +genclient
19+
// +genclient:nonNamespaced
20+
// +kubebuilder:resource:scope=Cluster,shortName=sp
21+
// +kubebuilder:subresource:status
22+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
23+
24+
// ServicePolicy defines the behaviours for the pods which have the same priority class
25+
type ServicePolicy struct {
26+
metav1.TypeMeta `json:",inline"`
27+
28+
metav1.ObjectMeta `json:"metadata,omitempty"`
29+
30+
Spec ServicePolicySpec `json:"spec"`
31+
32+
Status ServicePolicyStatus `json:"status,omitempty"`
33+
}
34+
35+
type ServicePolicySpec struct {
36+
// PriorityClassName is the priority class name used in the pods.
37+
// +required
38+
PriorityClassName string `json:"priorityClassName"`
39+
40+
// ResourcePriority defines the priority for various resources
41+
// +optional
42+
ResourcePriority ResourcePriority `json:"resourcePriority,omitempty"`
43+
44+
// AvoidanceStrategy defines the avoidance strategy for pods
45+
// +optional
46+
AvoidanceStrategy AvoidanceStrategy `json:"avoidanceStrategy,omitempty"`
47+
48+
// ResourcetMutation defines if the service need to mutate resource to expand resource
49+
// +optional
50+
ResourceMutation ResourceMutation `json:"resourceMutation,omitempty"`
51+
}
52+
53+
// ServicePolicyStatus defines the desired status of ServicePolicy
54+
type ServicePolicyStatus struct {
55+
}
56+
57+
type ResourceMutation struct {
58+
// +optional
59+
RequestMutations []ResourcetMutation `json:"requestMutations,omitempty"`
60+
// +optional
61+
LimitMutations []ResourcetMutation `json:"limitMutations,omitempty"`
62+
}
63+
64+
type ResourcePriority struct {
65+
// CPUPriority define the cpu priority for the pods.
66+
// CPUPriority range [0,7], 0 is the highest level.
67+
// When the cpu resource is shortage, the low level pods would be throttled
68+
// +kubebuilder:validation:Minimum=0
69+
// +kubebuilder:validation:Maximum=7
70+
// +optional
71+
CPUPriority int32 `json:"cpuPriority,omitempty"`
72+
// MemoryPriority define the memory priority for the pods.
73+
// MemoryPriority range [0,7], 0 is the highest level
74+
// When the memory is shortage, the low level pods would priority be killed
75+
// +kubebuilder:validation:Minimum=0
76+
// +kubebuilder:validation:Maximum=7
77+
// +optional
78+
MemoryPriority int32 `json:"memoryPriority,omitempty"`
79+
// NetworkIOPriority define the network IO priority for the pods.
80+
// NetworkIOPriority range [0,7], 0 is the highest level.
81+
// When the network device is busy, the low level pods would be throttled
82+
// +kubebuilder:validation:Minimum=0
83+
// +kubebuilder:validation:Maximum=7
84+
// +optional
85+
NetworkIOPriority int32 `json:"networkIOPriority,omitempty"`
86+
}
87+
88+
type AvoidanceStrategy struct {
89+
// +optional
90+
AllowThrottle bool `json:"allowThrottle,omitempty"`
91+
// +optional
92+
AllowEvict bool `json:"allowEvict,omitempty"`
93+
}
94+
95+
type ResourcetMutation struct {
96+
// ResourceName is the origin resource name which to be mutated
97+
// +kubebuilder:validation:Type=string
98+
// +kubebuilder:validation:Enum=cpu;memory
99+
// +required
100+
ResourceName corev1.ResourceName `json:"resourceName,omitempty"`
101+
102+
// MutatingResourceName is the resource name mutate
103+
// +required
104+
MutatingResourceName corev1.ResourceName `json:"mutatingResourceName,omitempty"`
105+
}
106+
107+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
108+
109+
// ServicePolicyList contains a list of ServicePolicy
110+
type ServicePolicyList struct {
111+
metav1.TypeMeta `json:",inline"`
112+
metav1.ListMeta `json:"metadata,omitempty"`
113+
Items []ServicePolicy `json:"items"`
114+
}
115+
18116
// PodQOSEnsurancePolicySpec defines the desired status of PodQOSEnsurancePolicy
19117
type PodQOSEnsurancePolicySpec struct {
20118
// Selector is a label query over pods that should match the policy
@@ -31,14 +129,11 @@ type QualityProbe struct {
31129
// HTTPGet specifies the http request to perform.
32130
// +optional
33131
HTTPGet *corev1.HTTPGetAction `json:"httpGet,omitempty"`
34-
// Init delay time for handler
35-
// Defaults to 5
36-
// +optional
37-
InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"`
38-
// Timeout for request.
39-
// Defaults to 0, instead not timeout
132+
133+
// TimeoutSeconds is the timeout for request.
134+
// Defaults to 0, no timeout forever
40135
// +optional
41-
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
136+
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`
42137
}
43138

44139
// PodQOSEnsurancePolicyStatus defines the observed status of PodQOSEnsurancePolicy
@@ -47,6 +142,7 @@ type PodQOSEnsurancePolicyStatus struct {
47142

48143
// +genclient
49144
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
145+
// +kubebuilder:resource:shortName=qep
50146

51147
// PodQOSEnsurancePolicy is the Schema for the podqosensurancepolicies API
52148
type PodQOSEnsurancePolicy struct {
@@ -68,7 +164,7 @@ type PodQOSEnsurancePolicyList struct {
68164

69165
// +genclient
70166
// +genclient:nonNamespaced
71-
// +kubebuilder:resource:scope=Cluster
167+
// +kubebuilder:resource:scope=Cluster,shortName=nep
72168
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
73169

74170
// NodeQOSEnsurancePolicy is the Schema for the nodeqosensurancepolicies API
@@ -102,7 +198,8 @@ type NodeQualityProbe struct {
102198
// +optional
103199
NodeLocalGet *NodeLocalGet `json:"nodeLocalGet,omitempty"`
104200

105-
// TimeoutSeconds is the timeout for request
201+
// TimeoutSeconds is the timeout for request.
202+
// Defaults to 0, no timeout forever.
106203
// +optional
107204
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`
108205
}
@@ -239,7 +336,7 @@ type AvoidanceActionStatus struct {
239336
// +genclient
240337
// +genclient:nonNamespaced
241338
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
242-
// +kubebuilder:resource:scope="Cluster"
339+
// +kubebuilder:resource:scope="Cluster",shortName=avoid
243340

244341
// AvoidanceAction defines Avoidance action
245342
type AvoidanceAction struct {

0 commit comments

Comments
 (0)