Descheduler for Kubernetes
↗️️ Click at the [bullet list icon] at the top right corner of the Readme visualization for the github generated table of contents.
Scheduling in Kubernetes is the process of binding pending pods to nodes, and is performed by a component of Kubernetes called kube-scheduler. The scheduler's decisions, whether or where a pod can or can not be scheduled, are guided by its configurable policy which comprises of set of rules, called predicates and priorities. The scheduler's decisions are influenced by its view of a Kubernetes cluster at that point of time when a new pod appears for scheduling. As Kubernetes clusters are very dynamic and their state changes over time, there may be desire to move already running pods to some other nodes for various reasons:
Consequently, there might be several pods scheduled on less desired nodes in a cluster. Descheduler, based on its policy, finds pods that can be moved and evicts them. Please note, in current implementation, descheduler does not schedule replacement of evicted pods but relies on the default scheduler for that.
If you are using a published release of Descheduler (such as
registry.k8s.io/descheduler/descheduler:v0.36.0), follow the documentation in
that version's release branch, as listed below:
| Descheduler Version | Docs link |
|---|---|
| v0.36.x | release-1.36 |
| v0.35.x | release-1.35 |
| v0.34.x | release-1.34 |
| v0.33.x | release-1.33 |
| v0.32.x | release-1.32 |
| v0.31.x | release-1.31 |
| v0.30.x | release-1.30 |
The
master
branch is considered in-development and the information presented in it may not
work for previous versions.
The descheduler can be run as a Job, CronJob, or Deployment inside of a k8s cluster. It has the
advantage of being able to be run multiple times without needing user intervention.
The descheduler pod is run as a critical pod in the kube-system namespace to avoid
being evicted by itself or by the kubelet.
kubectl create -f kubernetes/base/rbac.yaml
kubectl create -f kubernetes/base/configmap.yaml
kubectl create -f kubernetes/job/job.yamlkubectl create -f kubernetes/base/rbac.yaml
kubectl create -f kubernetes/base/configmap.yaml
kubectl create -f kubernetes/cronjob/cronjob.yamlkubectl create -f kubernetes/base/rbac.yaml
kubectl create -f kubernetes/base/configmap.yaml
kubectl create -f kubernetes/deployment/deployment.yamlStarting with release v0.18.0 there is an official helm chart that can be used to install the descheduler. See the helm chart README for detailed instructions.
The descheduler helm chart is also listed on the artifact hub.
You can use kustomize to install descheduler. See the resources | Kustomize for detailed instructions.
Run As A Job
kustomize build 'github.com/kubernetes-sigs/descheduler/kubernetes/job?ref=release-1.34' | kubectl apply -f -Run As A CronJob
kustomize build 'github.com/kubernetes-sigs/descheduler/kubernetes/cronjob?ref=release-1.34' | kubectl apply -f -Run As A Deployment
kustomize build 'github.com/kubernetes-sigs/descheduler/kubernetes/deployment?ref=release-1.34' | kubectl apply -f -See the user guide in the /docs directory.
The Descheduler Policy is configurable and includes default strategy plugins that can be enabled or disabled. It includes a common eviction configuration at the top level, as well as configuration from the Evictor plugin (Default Evictor, if not specified otherwise). Top-level configuration and Evictor plugin configuration are applied to all evictions.
These are top level keys in the Descheduler Policy that you can use to configure all evictions.
| Name | type | Default Value | Description |
|---|---|---|---|
nodeSelector |
string |
nil |
Limiting the nodes which are processed. Only used when nodeFit=true and only by the PreEvictionFilter Extension Point. |
maxNoOfPodsToEvictPerNode |
int |
nil |
Maximum number of pods evicted from each node (summed through all strategies). |
maxNoOfPodsToEvictPerNamespace |
int |
nil |
Maximum number of pods evicted from each namespace (summed through all strategies). |
maxNoOfPodsToEvictTotal |
int |
nil |
Maximum number of pods evicted per rescheduling cycle (summed through all strategies). |
metricsCollector (deprecated) |
object |
nil |
Configures collection of metrics for actual resource utilization. |
metricsCollector.enabled |
bool |
false |
Enables Kubernetes Metrics Server collection. |
metricsProviders |
[]object |
nil |
Enables various metrics providers like Kubernetes Metrics Server |
evictionFailureEventNotification |
bool |
false |
Enables eviction failure event notification. |
gracePeriodSeconds |
int |
nil |
The duration in seconds before the object should be deleted. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. |
prometheus |
object |
nil |
Configures collection of Prometheus metrics for actual resource utilization |
prometheus.url |
string |
nil |
Points to a Prometheus server url |
prometheus.authToken |
object |
nil |
Sets Prometheus server authentication token. If not specified in cluster authentication token from the container's file system is read. |
prometheus.authToken.secretReference |
object |
nil |
Read the authentication token from a kubernetes secret (the secret is expected to contain the token under prometheusAuthToken data key) |
prometheus.authToken.secretReference.namespace |
string |
nil |
Authentication token kubernetes secret namespace (currently, the RBAC configuration permits retrieving secrets from the kube-system namespace. If the secret needs to be accessed from a different namespace, the existing RBAC rules must be explicitly extended. |
prometheus.authToken.secretReference.name |
string |
nil |
Authentication token kubernetes secret name |
The descheduler currently allows to configure a metric collection of Kubernetes Metrics through metricsProviders field.
The previous way of setting metricsCollector field is deprecated. There are currently two sources to configure:
KubernetesMetrics: enables metrics collection from Kubernetes Metrics serverPrometheus: enables metrics collection from Prometheus serverIn general, each plugin can consume metrics from a different provider so multiple distinct providers can be configured in parallel.
The Default Evictor Plugin is used by default for filtering pods before processing them in an strategy plugin, or for applying a PreEvictionFilter of pods before eviction. You can also create your own Evictor Plugin or use the Default one provided by Descheduler. Other uses for the Evictor plugin can be to sort, filter, validate or group pods by different criteria, and that's why this is handled by a plugin and not configured in the top level config.
| Name | Type | Default Value | Description |
|---|---|---|---|
nodeSelector |
string |
nil |
Limits the nodes that are processed. |
evictLocalStoragePods |
bool |
false |
[Deprecated: Use podProtections with "PodsWithLocalStorage" instead]Allows eviction of pods using local storage. |
evictDaemonSetPods |
bool |
false |
[Deprecated: Use podProtections with "DaemonSetPods" instead]Allows eviction of DaemonSet managed Pods. |
evictSystemCriticalPods |
bool |
false |
[Deprecated: Use podProtections with "SystemCriticalPods" instead][Warning: Will evict Kubernetes system pods] Allows eviction of pods with any priority, including system-critical pods like kube-dns. |
ignorePvcPods |
bool |
false |
[Deprecated: Use podProtections with "PodsWithPVC" instead]Sets whether PVC pods should be evicted or ignored. |
evictFailedBarePods |
bool |
false |
[Deprecated: Use podProtections with "FailedBarePods" instead]Allows eviction of pods without owner references and in a failed phase. |
ignorePodsWithoutPDB |
bool |
false |
[Deprecated: Use podProtections with "PodsWithoutPDB" instead]Sets whether pods without PodDisruptionBudget should be evicted or ignored. |
namespaceLabelSelector |
metav1.LabelSelector |
No open issues yet, or sync has not completed.