diff --git a/addon/v1alpha1/0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml b/addon/v1alpha1/0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml index f2c023bd4..4dc853ad0 100644 --- a/addon/v1alpha1/0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml +++ b/addon/v1alpha1/0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml @@ -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 diff --git a/addon/v1alpha1/types_addondeploymentconfig.go b/addon/v1alpha1/types_addondeploymentconfig.go index 69cd70595..ea91310b8 100644 --- a/addon/v1alpha1/types_addondeploymentconfig.go +++ b/addon/v1alpha1/types_addondeploymentconfig.go @@ -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. diff --git a/addon/v1alpha1/zz_generated.deepcopy.go b/addon/v1alpha1/zz_generated.deepcopy.go index c0f0917e5..9530a30c9 100644 --- a/addon/v1alpha1/zz_generated.deepcopy.go +++ b/addon/v1alpha1/zz_generated.deepcopy.go @@ -108,6 +108,13 @@ func (in *AddOnDeploymentConfigSpec) DeepCopyInto(out *AddOnDeploymentConfigSpec copy(*out, *in) } in.ProxyConfig.DeepCopyInto(&out.ProxyConfig) + if in.ResourceRequirements != nil { + in, out := &in.ResourceRequirements, &out.ResourceRequirements + *out = make([]ContainerResourceRequirements, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -453,6 +460,23 @@ func (in *ConfigSpecHash) DeepCopy() *ConfigSpecHash { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerResourceRequirements) DeepCopyInto(out *ContainerResourceRequirements) { + *out = *in + in.Resources.DeepCopyInto(&out.Resources) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerResourceRequirements. +func (in *ContainerResourceRequirements) DeepCopy() *ContainerResourceRequirements { + if in == nil { + return nil + } + out := new(ContainerResourceRequirements) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CurrentClusterBindingConfig) DeepCopyInto(out *CurrentClusterBindingConfig) { *out = *in diff --git a/addon/v1alpha1/zz_generated.swagger_doc_generated.go b/addon/v1alpha1/zz_generated.swagger_doc_generated.go index bdf505bfc..9bcdd95c5 100644 --- a/addon/v1alpha1/zz_generated.swagger_doc_generated.go +++ b/addon/v1alpha1/zz_generated.swagger_doc_generated.go @@ -36,12 +36,23 @@ var map_AddOnDeploymentConfigSpec = map[string]string{ "registries": "Registries describes how to override images used by the addon agent on the managed cluster. the following example will override image \"quay.io/open-cluster-management/addon-agent\" to \"quay.io/ocm/addon-agent\" when deploying the addon agent\n\nregistries:\n - source: quay.io/open-cluster-management/addon-agent\n mirror: quay.io/ocm/addon-agent", "proxyConfig": "ProxyConfig holds proxy settings for add-on agent on the managed cluster. Empty means no proxy settings is available.", "agentInstallNamespace": "AgentInstallNamespace is the namespace where the add-on agent should be installed on the managed cluster.", + "resourceRequirements": "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.", } func (AddOnDeploymentConfigSpec) SwaggerDoc() map[string]string { return map_AddOnDeploymentConfigSpec } +var map_ContainerResourceRequirements = map[string]string{ + "": "ContainerResourceRequirements defines resources required by one or a group of containers.", + "containerID": "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\n 1). Supported resource types include deployments, daemonsets, statefulsets, replicasets, jobs,\n cronjobs and pods;\n 2). Wildcards (*) can be used in any part to match multiple containers. For example, '*:*:*'\n matches all containers of the agent.", + "resources": "Compute resources required by matched containers.", +} + +func (ContainerResourceRequirements) SwaggerDoc() map[string]string { + return map_ContainerResourceRequirements +} + var map_CustomizedVariable = map[string]string{ "": "CustomizedVariable represents a customized variable for add-on deployment.", "name": "Name of this variable.",