Skip to content

Commit

Permalink
✨ support add-on agent resource requirements settings
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Le <[email protected]>
  • Loading branch information
elgnay committed Jan 6, 2025
1 parent 05ff7c1 commit 3e993dc
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,89 @@ spec:
- mirror
type: object
type: array
resourceRequirements:
description: |-
ResourceRequirements specify the resources required by add-on agents.
If a container matches multiple ContainerResourceRequirements, the last matched configuration in the
array will take precedence.
items:
description: ContainerResourceRequirements defines resources required
by one or a group of containers.
properties:
containerID:
description: |-
ContainerID is a unique identifier for an agent container. It consists of three parts: resource types,
resource name, and container name, separated by ':'. The format follows
'{resource_types}:{resource_name}:{container_name}' where
1). Supported resource types include deployments, daemonsets, statefulsets, replicasets, jobs,
cronjobs and pods;
2). Wildcards (*) can be used in any part to match multiple containers. For example, '*:*:*'
matches all containers of the agent.
pattern: ^(deployments|daemonsets|statefulsets|replicasets|jobs|cronjobs|pods|\*):.+:.+$
type: string
resources:
description: Compute resources required by matched containers.
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
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.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
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/
type: object
type: object
required:
- containerID
- resources
type: object
type: array
x-kubernetes-list-map-keys:
- containerID
x-kubernetes-list-type: map
type: object
type: object
served: true
Expand Down
28 changes: 28 additions & 0 deletions addon/v1alpha1/types_addondeploymentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ type AddOnDeploymentConfigSpec struct {
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
AgentInstallNamespace string `json:"agentInstallNamespace,omitempty"`

// ResourceRequirements specify the resources required by add-on agents.
// If a container matches multiple ContainerResourceRequirements, the last matched configuration in the
// array will take precedence.
// +optional
// +listType=map
// +listMapKey=containerID
ResourceRequirements []ContainerResourceRequirements `json:"resourceRequirements,omitempty"`
}

// ContainerResourceRequirements defines resources required by one or a group of containers.
type ContainerResourceRequirements struct {
// ContainerID is a unique identifier for an agent container. It consists of three parts: resource types,
// resource name, and container name, separated by ':'. The format follows
// '{resource_types}:{resource_name}:{container_name}' where
// 1). Supported resource types include deployments, daemonsets, statefulsets, replicasets, jobs,
// cronjobs and pods;
// 2). Wildcards (*) can be used in any part to match multiple containers. For example, '*:*:*'
// matches all containers of the agent.
// +required
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=`^(deployments|daemonsets|statefulsets|replicasets|jobs|cronjobs|pods|\*):.+:.+$`
ContainerID string `json:"containerID"`

// Compute resources required by matched containers.
// +required
// +kubebuilder:validation:Required
Resources corev1.ResourceRequirements `json:"resources"`
}

// CustomizedVariable represents a customized variable for add-on deployment.
Expand Down
24 changes: 24 additions & 0 deletions addon/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions addon/v1alpha1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3e993dc

Please sign in to comment.