Skip to content

Commit 1a5e25a

Browse files
authored
✨ support add-on agent resource requirements settings (#354)
Signed-off-by: Yang Le <[email protected]>
1 parent 0ba6809 commit 1a5e25a

4 files changed

+146
-0
lines changed

addon/v1alpha1/0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,89 @@ spec:
179179
- mirror
180180
type: object
181181
type: array
182+
resourceRequirements:
183+
description: |-
184+
ResourceRequirements specify the resources required by add-on agents.
185+
If a container matches multiple ContainerResourceRequirements, the last matched configuration in the
186+
array will take precedence.
187+
items:
188+
description: ContainerResourceRequirements defines resources required
189+
by one or a group of containers.
190+
properties:
191+
containerID:
192+
description: |-
193+
ContainerID is a unique identifier for an agent container. It consists of three parts: resource types,
194+
resource name, and container name, separated by ':'. The format follows
195+
'{resource_types}:{resource_name}:{container_name}' where
196+
1). Supported resource types include deployments, daemonsets, statefulsets, replicasets, jobs,
197+
cronjobs and pods;
198+
2). Wildcards (*) can be used in any part to match multiple containers. For example, '*:*:*'
199+
matches all containers of the agent.
200+
pattern: ^(deployments|daemonsets|statefulsets|replicasets|jobs|cronjobs|pods|\*):.+:.+$
201+
type: string
202+
resources:
203+
description: Compute resources required by matched containers.
204+
properties:
205+
claims:
206+
description: |-
207+
Claims lists the names of resources, defined in spec.resourceClaims,
208+
that are used by this container.
209+
210+
211+
This is an alpha field and requires enabling the
212+
DynamicResourceAllocation feature gate.
213+
214+
215+
This field is immutable. It can only be set for containers.
216+
items:
217+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
218+
properties:
219+
name:
220+
description: |-
221+
Name must match the name of one entry in pod.spec.resourceClaims of
222+
the Pod where this field is used. It makes that resource available
223+
inside a container.
224+
type: string
225+
required:
226+
- name
227+
type: object
228+
type: array
229+
x-kubernetes-list-map-keys:
230+
- name
231+
x-kubernetes-list-type: map
232+
limits:
233+
additionalProperties:
234+
anyOf:
235+
- type: integer
236+
- type: string
237+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
238+
x-kubernetes-int-or-string: true
239+
description: |-
240+
Limits describes the maximum amount of compute resources allowed.
241+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
242+
type: object
243+
requests:
244+
additionalProperties:
245+
anyOf:
246+
- type: integer
247+
- type: string
248+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
249+
x-kubernetes-int-or-string: true
250+
description: |-
251+
Requests describes the minimum amount of compute resources required.
252+
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
253+
otherwise to an implementation-defined value. Requests cannot exceed Limits.
254+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
255+
type: object
256+
type: object
257+
required:
258+
- containerID
259+
- resources
260+
type: object
261+
type: array
262+
x-kubernetes-list-map-keys:
263+
- containerID
264+
x-kubernetes-list-type: map
182265
type: object
183266
type: object
184267
served: true

addon/v1alpha1/types_addondeploymentconfig.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,34 @@ type AddOnDeploymentConfigSpec struct {
5858
// +kubebuilder:validation:MaxLength=63
5959
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
6060
AgentInstallNamespace string `json:"agentInstallNamespace,omitempty"`
61+
62+
// ResourceRequirements specify the resources required by add-on agents.
63+
// If a container matches multiple ContainerResourceRequirements, the last matched configuration in the
64+
// array will take precedence.
65+
// +optional
66+
// +listType=map
67+
// +listMapKey=containerID
68+
ResourceRequirements []ContainerResourceRequirements `json:"resourceRequirements,omitempty"`
69+
}
70+
71+
// ContainerResourceRequirements defines resources required by one or a group of containers.
72+
type ContainerResourceRequirements struct {
73+
// ContainerID is a unique identifier for an agent container. It consists of three parts: resource types,
74+
// resource name, and container name, separated by ':'. The format follows
75+
// '{resource_types}:{resource_name}:{container_name}' where
76+
// 1). Supported resource types include deployments, daemonsets, statefulsets, replicasets, jobs,
77+
// cronjobs and pods;
78+
// 2). Wildcards (*) can be used in any part to match multiple containers. For example, '*:*:*'
79+
// matches all containers of the agent.
80+
// +required
81+
// +kubebuilder:validation:Required
82+
// +kubebuilder:validation:Pattern=`^(deployments|daemonsets|statefulsets|replicasets|jobs|cronjobs|pods|\*):.+:.+$`
83+
ContainerID string `json:"containerID"`
84+
85+
// Compute resources required by matched containers.
86+
// +required
87+
// +kubebuilder:validation:Required
88+
Resources corev1.ResourceRequirements `json:"resources"`
6189
}
6290

6391
// CustomizedVariable represents a customized variable for add-on deployment.

addon/v1alpha1/zz_generated.deepcopy.go

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

addon/v1alpha1/zz_generated.swagger_doc_generated.go

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

0 commit comments

Comments
 (0)