Skip to content

Commit e7bd1bd

Browse files
✨ Configurable qos resources for deployments managed by clustermanager and klusterlet (#316)
* configurable qos resources for clustermanager and klusterlet deployments Signed-off-by: Dong Beiqing <[email protected]> * move ResourceRequirement to a separate file Signed-off-by: Dong Beiqing <[email protected]> --------- Signed-off-by: Dong Beiqing <[email protected]>
1 parent cb76224 commit e7bd1bd

10 files changed

+216
-31
lines changed

crdsv1beta1/0001_00_operator.open-cluster-management.io_klusterlets.crd.yaml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,53 @@ spec:
156156
description: RegistrationImagePullSpec represents the desired image configuration of registration agent. quay.io/open-cluster-management.io/registration:latest will be used if unspecified.
157157
type: string
158158
resourceRequirement:
159-
description: ResourceRequirement specify QoS classes of klusterlet deployment
159+
description: ResourceRequirement specify QoS classes of deployments managed by klusterlet. It applies to all the containers in the deployments.
160160
type: object
161161
properties:
162+
resourceRequirements:
163+
description: ResourceRequirements defines resource requests and limits when Type is ResourceQosClassResourceRequirement
164+
type: object
165+
properties:
166+
claims:
167+
description: "Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. \n This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. \n This field is immutable. It can only be set for containers."
168+
type: array
169+
items:
170+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
171+
type: object
172+
required:
173+
- name
174+
properties:
175+
name:
176+
description: Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container.
177+
type: string
178+
x-kubernetes-list-map-keys:
179+
- name
180+
x-kubernetes-list-type: map
181+
limits:
182+
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
183+
type: object
184+
additionalProperties:
185+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
186+
anyOf:
187+
- type: integer
188+
- type: string
189+
x-kubernetes-int-or-string: true
190+
requests:
191+
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
192+
type: object
193+
additionalProperties:
194+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
195+
anyOf:
196+
- type: integer
197+
- type: string
198+
x-kubernetes-int-or-string: true
162199
type:
163200
type: string
164201
default: Default
165202
enum:
166203
- Default
167204
- BestEffort
205+
- ResourceRequirement
168206
workConfiguration:
169207
description: WorkConfiguration contains the configuration of work
170208
type: object

operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,65 @@ spec:
244244
will be used if unspecified.
245245
type: string
246246
resourceRequirement:
247-
description: ResourceRequirement specify QoS classes of klusterlet
248-
deployment
247+
description: ResourceRequirement specify QoS classes of deployments
248+
managed by klusterlet. It applies to all the containers in the deployments.
249249
properties:
250+
resourceRequirements:
251+
description: ResourceRequirements defines resource requests and
252+
limits when Type is ResourceQosClassResourceRequirement
253+
properties:
254+
claims:
255+
description: "Claims lists the names of resources, defined
256+
in spec.resourceClaims, that are used by this container.
257+
\n This is an alpha field and requires enabling the DynamicResourceAllocation
258+
feature gate. \n This field is immutable. It can only be
259+
set for containers."
260+
items:
261+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
262+
properties:
263+
name:
264+
description: Name must match the name of one entry in
265+
pod.spec.resourceClaims of the Pod where this field
266+
is used. It makes that resource available inside a
267+
container.
268+
type: string
269+
required:
270+
- name
271+
type: object
272+
type: array
273+
x-kubernetes-list-map-keys:
274+
- name
275+
x-kubernetes-list-type: map
276+
limits:
277+
additionalProperties:
278+
anyOf:
279+
- type: integer
280+
- type: string
281+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
282+
x-kubernetes-int-or-string: true
283+
description: 'Limits describes the maximum amount of compute
284+
resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
285+
type: object
286+
requests:
287+
additionalProperties:
288+
anyOf:
289+
- type: integer
290+
- type: string
291+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
292+
x-kubernetes-int-or-string: true
293+
description: 'Requests describes the minimum amount of compute
294+
resources required. If Requests is omitted for a container,
295+
it defaults to Limits if that is explicitly specified, otherwise
296+
to an implementation-defined value. Requests cannot exceed
297+
Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
298+
type: object
299+
type: object
250300
type:
251301
default: Default
252302
enum:
253303
- Default
254304
- BestEffort
305+
- ResourceRequirement
255306
type: string
256307
type: object
257308
workConfiguration:

operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,69 @@ spec:
259259
description: RegistrationImagePullSpec represents the desired image
260260
of registration controller/webhook installed on hub.
261261
type: string
262+
resourceRequirement:
263+
description: ResourceRequirement specify QoS classes of deployments
264+
managed by clustermanager. It applies to all the containers in the
265+
deployments.
266+
properties:
267+
resourceRequirements:
268+
description: ResourceRequirements defines resource requests and
269+
limits when Type is ResourceQosClassResourceRequirement
270+
properties:
271+
claims:
272+
description: "Claims lists the names of resources, defined
273+
in spec.resourceClaims, that are used by this container.
274+
\n This is an alpha field and requires enabling the DynamicResourceAllocation
275+
feature gate. \n This field is immutable. It can only be
276+
set for containers."
277+
items:
278+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
279+
properties:
280+
name:
281+
description: Name must match the name of one entry in
282+
pod.spec.resourceClaims of the Pod where this field
283+
is used. It makes that resource available inside a
284+
container.
285+
type: string
286+
required:
287+
- name
288+
type: object
289+
type: array
290+
x-kubernetes-list-map-keys:
291+
- name
292+
x-kubernetes-list-type: map
293+
limits:
294+
additionalProperties:
295+
anyOf:
296+
- type: integer
297+
- type: string
298+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
299+
x-kubernetes-int-or-string: true
300+
description: 'Limits describes the maximum amount of compute
301+
resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
302+
type: object
303+
requests:
304+
additionalProperties:
305+
anyOf:
306+
- type: integer
307+
- type: string
308+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
309+
x-kubernetes-int-or-string: true
310+
description: 'Requests describes the minimum amount of compute
311+
resources required. If Requests is omitted for a container,
312+
it defaults to Limits if that is explicitly specified, otherwise
313+
to an implementation-defined value. Requests cannot exceed
314+
Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
315+
type: object
316+
type: object
317+
type:
318+
default: Default
319+
enum:
320+
- Default
321+
- BestEffort
322+
- ResourceRequirement
323+
type: string
324+
type: object
262325
workConfiguration:
263326
description: WorkConfiguration contains the configuration of work
264327
properties:

operator/v1/funcs_clustermanager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package v1
2+
3+
func (cm *ClusterManager) GetResourceRequirement() *ResourceRequirement {
4+
return cm.Spec.ResourceRequirement
5+
}

operator/v1/funcs_klusterlet.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package v1
2+
3+
func (k *Klusterlet) GetResourceRequirement() *ResourceRequirement {
4+
return k.Spec.ResourceRequirement
5+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package v1
2+
3+
import corev1 "k8s.io/api/core/v1"
4+
5+
type ResourceRequirementAcquirer interface {
6+
GetResourceRequirement() *ResourceRequirement
7+
}
8+
9+
// ResourceRequirement allow user override the default pod QoS classes
10+
type ResourceRequirement struct {
11+
// +kubebuilder:validation:Enum=Default;BestEffort;ResourceRequirement
12+
// +kubebuilder:default:=Default
13+
Type ResourceQosClass `json:"type"`
14+
// ResourceRequirements defines resource requests and limits when Type is ResourceQosClassResourceRequirement
15+
// +optional
16+
ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
17+
}
18+
19+
type ResourceQosClass string
20+
21+
const (
22+
// Default use resource setting in the template file (with requests but no limits in the resources)
23+
ResourceQosClassDefault ResourceQosClass = "Default"
24+
// If all containers in the pod don't set resource request and limits, the pod is treated as BestEffort.
25+
ResourceQosClassBestEffort ResourceQosClass = "BestEffort"
26+
// Configurable resource requirements with requests and limits
27+
ResourceQosClassResourceRequirement ResourceQosClass = "ResourceRequirement"
28+
)

operator/v1/types_clustermanager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ type ClusterManagerSpec struct {
7070
// AddOnManagerConfiguration contains the configuration of addon manager
7171
// +optional
7272
AddOnManagerConfiguration *AddOnManagerConfiguration `json:"addOnManagerConfiguration,omitempty"`
73+
74+
// ResourceRequirement specify QoS classes of deployments managed by clustermanager.
75+
// It applies to all the containers in the deployments.
76+
// +optional
77+
ResourceRequirement *ResourceRequirement `json:"resourceRequirement,omitempty"`
7378
}
7479

7580
// NodePlacement describes node scheduling configuration for the pods.

operator/v1/types_klusterlet.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package v1
22

3-
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
46

57
// +genclient
68
// +genclient:nonNamespaced
@@ -87,27 +89,12 @@ type KlusterletSpec struct {
8789
// +optional
8890
HubApiServerHostAlias *HubApiServerHostAlias `json:"hubApiServerHostAlias,omitempty"`
8991

90-
// ResourceRequirement specify QoS classes of klusterlet deployment
92+
// ResourceRequirement specify QoS classes of deployments managed by klusterlet.
93+
// It applies to all the containers in the deployments.
9194
// +optional
9295
ResourceRequirement *ResourceRequirement `json:"resourceRequirement,omitempty"`
9396
}
9497

95-
type ResourceQosClass string
96-
97-
const (
98-
// Default use resource setting in the template file
99-
ResourceQosClassDefault ResourceQosClass = "Default"
100-
// If all containers in the pod don't set resource request and limits, the pod is treated as BestEffort.
101-
ResourceQosClassBestEffort ResourceQosClass = "BestEffort"
102-
)
103-
104-
// ResourceRequirement allow user override the default pod QoS classes
105-
type ResourceRequirement struct {
106-
// +kubebuilder:validation:Enum=Default;BestEffort
107-
// +kubebuilder:default:=Default
108-
Type ResourceQosClass `json:"type"`
109-
}
110-
11198
// ServerURL represents the apiserver url and ca bundle that is accessible externally
11299
type ServerURL struct {
113100
// URL is the url of apiserver endpoint of the managed cluster.

operator/v1/zz_generated.deepcopy.go

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

operator/v1/zz_generated.swagger_doc_generated.go

Lines changed: 2 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)