Deploying and Configuring the Kube Descheduler Operator on OpenShift

Updated

Installing and Configuring the Kube Descheduler Operator on OpenShift

Prerequisites

  • OpenShift Container Platform (OCP) version 4.x
  • cluster-admin privileges
  • OpenShift CLI (oc) installed and configured

Step 1: Install the Kube Descheduler Operator

  1. Log in to the OpenShift cluster:
   oc login --token=<your_token> --server=<api_server>
  1. Create a namespace for the Descheduler:
   oc create ns openshift-kube-descheduler-operator
  1. Install the Operator using Operator Lifecycle Manager (OLM):
   oc apply -f - <<EOF
   apiVersion: operators.coreos.com/v1alpha1
   kind: Subscription
   metadata:
     name: kube-descheduler-operator
     namespace: openshift-kube-descheduler-operator
   spec:
     channel: stable
     name: kube-descheduler-operator
     source: redhat-operators
     sourceNamespace: openshift-marketplace
   EOF
  1. Verify the installation:
   oc get csv -n openshift-kube-descheduler-operator

The status should be Succeeded.

Step 2: Create a KubeDescheduler Custom Resource (CR)

  1. Create a KubeDescheduler instance:
   oc apply -f - <<EOF
   apiVersion: operator.openshift.io/v1
   kind: KubeDescheduler
   metadata:
     name: cluster
   spec:
     deschedulingIntervalSeconds: 3600
     profiles:
       - AffinityAndTaints
       - TopologyAndDuplicates
   EOF
  1. Verify the Descheduler instance:
   oc get KubeDescheduler cluster -o yaml

Step 3: Verify Pod Evictions

  • Check if the descheduler is running properly:
  oc logs -l app=descheduler -n openshift-kube-descheduler-operator
  • Monitor pod evictions:
  oc get pods --all-namespaces | grep Terminating

Step 4: Modify Descheduler Policies

If you need to update descheduling policies, edit the KubeDescheduler CR:

oc edit KubeDescheduler cluster

Modify the spec.profiles field as needed.

Available Descheduler Profiles

The following profiles are available:

  • AffinityAndTaints: Removes pods violating node/pod affinity and node taints
  • TopologyAndDuplicates: Balances pods based on topology constraints and removes duplicates
  • SoftTopologyAndDuplicates: Same as TopologyAndDuplicates but includes soft constraints
  • LifecycleAndUtilization: Evicts old pods and balances node resource consumption
  • LongLifecycle: Similar to LifecycleAndUtilization without the 24-hour lifetime limit
  • CompactAndScale: Consolidates workloads onto fewer nodes
  • EvictPodsWithPVC: Allows eviction of pods with PVCs
  • EvictPodsWithLocalStorage: Allows eviction of pods with local storage

Conclusion

The Kube Descheduler Operator is a valuable tool for optimizing OpenShift cluster resource utilization. By configuring appropriate policies, administrators can ensure better node balance and improve cluster performance.

SBR
Category
Components
Article Type