The module lifecycle stage: Generally available version

The module has requirements for installation

The examples on this page are manifests of Descheduler objects. Create an object from a manifest in one of the following ways:

  • Web UI
  • CLI
  1. Go to System → System Management → Cluster → Scheduling → Deschedulers.
  2. Click Create.
  3. Go to the YAML tab, paste the manifest and click Apply.

Save the manifest to the descheduler.yaml file and apply it:

d8 k apply -f descheduler.yaml

Configuring the pod redistribution interval

To set how often the descheduler module runs the pod redistribution cycle, use the deschedulingInterval parameter. The parameter sets how often the cluster is checked, but does not guarantee an eviction in every cycle. The eviction conditions are set in a Descheduler object.

For example, to run descheduler every 5 minutes, set deschedulingInterval: Frequent:

  • Web UI
  • CLI
  1. Go to System → System Management → Cluster → Platform → Modules.
  2. Open the descheduler module and go to the Settings tab.
  3. Set the deschedulingInterval parameter to Frequent and save the changes.

Set the parameter in the descheduler ModuleConfig:

apiVersion: deckhouse.io/v1alpha1
kind: ModuleConfig
metadata:
  name: descheduler
spec:
  version: 2
  settings:
    deschedulingInterval: Frequent
  # ...

Redistributing pods from overloaded nodes

With the descheduler module enabled, apply the following manifest of a Descheduler object. The strategy selects the nodes with a CPU utilization of 20% or lower as possible targets and evicts pods from the nodes with a utilization above 50%. The utilization source is set by metricsSource: Default:

apiVersion: deckhouse.io/v1alpha2
kind: Descheduler
metadata:
  name: low-node-utilization
spec:
  strategies:
    lowNodeUtilization:
      enabled: true
      thresholds:
        cpu: 20
      targetThresholds:
        cpu: 50

Expected result: if suitable target nodes and pods that can be evicted are available, the load is redistributed from the nodes above the 50% threshold. Pods of the protected categories and requests that violate a PodDisruptionBudget are not processed as regular candidates.

Balancing relative to the average utilization

The strategy uses deviations of 5 percentage points from the average CPU utilization of the Ready nodes. For example, with an average of 40%, the nodes with a utilization of 35% or lower are considered underutilized, and the nodes above 45% are considered overutilized. The limit allows at most two evictions from a node per cycle and counts background evictions:

apiVersion: deckhouse.io/v1alpha2
kind: Descheduler
metadata:
  name: low-node-utilization-deviation
spec:
  strategies:
    lowNodeUtilization:
      enabled: true
      useDeviationThresholds: true
      thresholds:
        cpu: 5
      targetThresholds:
        cpu: 5
      evictionLimits:
        node: 2

Expected result: when the eviction conditions are met, the strategy reduces the deviation of the load from the average. A virtual machine pod that is still migrating from the node takes a place in the limit. Reaching the range is not guaranteed: it depends on the available nodes and the restrictions of the pods.

Balancing by the CPU utilization over 15 minutes

Enable the prometheus module and use the Moderate or Rare interval for descheduler. The Prometheus source averages the CPU utilization of the nodes over 15 minutes. Averaging reduces the effect of short load spikes, but does not exclude it completely. Do not set evictionLimits.node: in this mode it raises the number of evictions from a node per cycle:

apiVersion: deckhouse.io/v1alpha2
kind: Descheduler
metadata:
  name: low-node-utilization-prometheus
spec:
  strategies:
    lowNodeUtilization:
      enabled: true
      metricsSource: Prometheus
      useDeviationThresholds: true
      thresholds:
        cpu: 5
      targetThresholds:
        cpu: 5

Expected result: the strategy selects candidates by a deviation of 5 percentage points from the average utilization and evicts at most one pod from each overutilized node per cycle. If Prometheus is unavailable or has no data for at least one Ready node, the balancing of this strategy is skipped.

Packing pods onto fewer nodes

Set spec.schedulerName: high-node-utilization in the pod template of the target workload, as described in scheduler profiles. For a Deployment, this is the spec.template.spec.schedulerName field. Then apply the manifest of a Descheduler object.

apiVersion: deckhouse.io/v1alpha2
kind: Descheduler
metadata:
  name: high-node-utilization
spec:
  strategies:
    highNodeUtilization:
      enabled: true
      thresholds:
        cpu: 50
        memory: 50

Expected result: the strategy evicts suitable pods from the nodes where the CPU and memory requests do not exceed 50% of the available resources. Replacement pods with spec.schedulerName: high-node-utilization use the MostAllocated scoring strategy and prefer nodes with a higher share of requested resources. Removing the freed nodes requires autoscaling.

Protecting pods by StorageClass

The protectedStorageClasses parameter excludes pods with a PersistentVolumeClaim of the listed StorageClasses from processing. Replace local-path with the name of the StorageClass to protect:

apiVersion: deckhouse.io/v1alpha2
kind: Descheduler
metadata:
  name: protect-local-storage
spec:
  protectedStorageClasses:
    - local-path
  strategies:
    lowNodeUtilization:
      enabled: true
      thresholds:
        cpu: 20
      targetThresholds:
        cpu: 50

Expected result: pods with a PersistentVolumeClaim of the local-path StorageClass are excluded from the candidates. The protection also applies if the PersistentVolumeClaim is not found or its storageClassName is empty. The descheduler.alpha.kubernetes.io/evict annotation bypasses this filter.

To turn off the protection by StorageClass, remove protectedStorageClasses. An empty list is not allowed.

Checking the result

After applying a manifest from the examples above, check the eviction events and the module logs:

d8 k get events -A --field-selector reportingComponent=sigs.k8s.io.descheduler
d8 k logs deployment/descheduler \
  -n d8-descheduler \
  -c descheduler \
  --since=30m

The events of the module show the processed evictions except the background ones: a live migration of a virtual machine creates no event. The absence of evictions is not an error by itself: check that suitable nodes are available, the thresholds and the restrictions of the pods.

Troubleshooting

A utilization data read error stops the balancing of the affected strategy in the current cycle. The action depends on the log message:

Message Cause Action
unable to find metric entry for The Prometheus response has no data for the node Check that node-exporter metrics are collected for the node and wait for at least two successful scrapes
unable to find node The Metrics API did not return the required node metrics Check the availability of the registered Metrics API and the node data
pod does not fit on any other node Other nodes do not satisfy the placement conditions of the pod Check the available resources, selectors, taints and the state of the nodes

If a message does not appear in the log, set logLevel to Debug for the time of troubleshooting: this level logs why a pod was not evicted. After the cause is resolved, restore the previous level to reduce the log volume.