Resource Bin Packing [page]deterministic
> Note: This article applies to resource bin packing in context of scheduling of a single pod. For bin packing when scheduling pod groups, please read the [article about Topology-aware Scheduling](/docs/concepts/scheduling-eviction/topology-aware-scheduling/).
In the [scheduling-plugin](/docs/reference/scheduling/config/#scheduling-plugins) `NodeResourcesFit` of kube-scheduler, there are two scoring strategies that support the bin packing of resources: `MostAllocated` and `RequestedToCapacityRatio`.
## Enabling bin packing using MostAllocated strategy The `MostAllocated` strategy scores the nodes based on the utilization of resources, favoring the ones with higher allocation. For each resource type, you can set a weight to modify its influence in the node score.
To set the `MostAllocated` strategy for the `NodeResourcesFit` plugin, use a [scheduler configuration](/docs/reference/scheduling/config) similar to the following:
```yaml apiVersion: kubescheduler.config.k8s.io/v1 kind: KubeSchedulerConfiguration profiles: - pluginConfig: - args: scoringStrategy: resources: - name: cpu weight: 1 - name: memory weight: 1 - name: intel.com/foo weight: 3 - name: intel.com/bar weight: 3 type: MostAllocated name: NodeResourcesFit ```
With this configuration, nodes are scored using a weighted average of utilization across all four resources. Because `intel.com/foo` and `intel.com/bar` each carry a weight of `3` versus `1` for CPU and memory, the utilization of those extended resources has three times more influence on the final node score. The scheduler selects the highest-scoring node, aiming to schedule pods on highly utilized nodes. This helps prepare for scale-down of the least utilized nodes.
To learn more about other parameters and their default configuration, see the API documentation for [`NodeResourcesFitArgs`](/docs/reference/config-api/kube-scheduler-config.v1/#kubescheduler-config-k8s-io-v1-NodeResourcesFitArgs).
## Enabling bin packing using RequestedToCapacityRatio
The `RequestedToCapacityRatio` strategy allows the users to specify the resources along with weights for each resource to score nodes based on the request to capacity ratio. This allows users to bin pack extended resources by using appropriate parameters to improve the utilization of scarce resources in large clusters. It favors nodes according to a configured function of the allocated resources. The behavior of the `RequestedToCapacityRatio` in the `NodeResourcesFit` score function can be controlled by the [scoringStrategy](/docs/reference/config-api/kube-scheduler-config.v1/#kubescheduler-config-k8s-io-v1-ScoringStrategy) field. Within the `scoringStrategy` field, you can configure two parameters: `requestedToCapacityRatio` and `resources`. The `shape` in the `requestedToCapacityRatio` parameter allows the user to tune the function as least requested or most requested based on `utilization` and `score` values. The `resources` parameter comprises both the `name` of the resource to be considered during scoring and its corresponding `weight`, which specifies the weight of each resource.
Below is an example configuration that sets the bin packing behavior for extended resources `intel.com/foo` and `intel.com/bar` using the `requestedToCapacityRatio` field.
```yaml apiVersion: kubescheduler.config.k8s.io/v1 kind: KubeSchedulerConfiguration profiles: - pluginConfig: - args: scoringStrategy: resources: - name: intel.com/foo weight: 3 - name: intel.com/bar weight: 3 requestedToCapacityRatio: shape: - utilization: 0 score: 0 - utilization: 100 score: 10 type: RequestedToCapacityRatio name: NodeResourcesFit ```
In this example, only the extended resources `intel.com/foo` and `intel.com/bar` are listed in `resources`. The `NodeResou …(trimmed)