9.18.13.3. Configuring descheduler evictions for virtual machines
After the descheduler is installed and configured, all migratable virtual machines (VMs) are eligible for eviction by default. You can configure the descheduler to manage VM evictions across the cluster and optionally exclude specific VMs from eviction.
Prerequisites
-
Install the descheduler in the OpenShift Container Platform web console or OpenShift CLI (
oc).
Procedure
- Stop the VM.
Configure the
KubeDeschedulerobject with theKubeVirtRelieveAndMigrateprofile and enable background evictions for improved VM eviction stability during live migration:apiVersion: operator.openshift.io/v1 kind: KubeDescheduler metadata: name: cluster namespace: openshift-kube-descheduler-operator spec: deschedulingIntervalSeconds: 60 profiles: - KubeVirtRelieveAndMigrate mode: Automatic-
Optional: To evict pods, set the
modefield value toAutomatic. By default, the descheduler does not evict pods. Optional: Configure limits for the number of parallel evictions to improve stability in large clusters.
The descheduler can limit the number of concurrent evictions per node and across the cluster by using the
evictionLimitsfield. Set these limits to match the migration limits configured in theHyperConvergedcustom resource (CR).spec: evictionLimits: node: 2 total: 5Set values that correspond to the migration limits in the
HyperConvergedCR:spec: liveMigrationConfig: parallelMigrationsPerCluster: 5 parallelOutboundMigrationsPerNode: 2Optional: To exclude the VM from eviction, add the
descheduler.alpha.kubernetes.io/prefer-no-evictionannotation to thespec.template.metadata.annotationsfield. The change is applied dynamically and is propagated to theVirtualMachineInstance(VMI) object and thevirt-launcherpod.Only the presence of the annotation is checked. The value is not evaluated, so
"true"and"false"have the same effect.apiVersion: kubevirt.io/v1 kind: VirtualMachine spec: template: metadata: annotations: descheduler.alpha.kubernetes.io/prefer-no-eviction: "true"- Start the VM.
Result
The VM is now configured according to the descheduler settings.