Repository: kubernetes-sigs/descheduler

Issue #1131: Where should Policies go?
Created: 2023-04-26T16:40:25Z
Hello guys,
I'm new to the Descheduler.
Based on the docs, I wrote this policy:
apiVersion: descheduler/v1alpha2
kind: DeschedulerPolicy
profiles:
  - name: ProfileName
    pluginConfig:
    - name: "DefaultEvictor"
      args:
        evictFailedBarePods: true
        nodeFit: true
    - name: "RemoveFailedPods"
      args:
        reasons:
        - "NodeAffinity"
        includingInitContainers: true
        excludeOwnerKinds:
        - "Job"
    - name: "PodLifeTime"
      args:
        maxPodLifeTimeSeconds: 3600
        states:
        - "Pending"
        - "PodInitializing"
        # namespaces:
        #   exclude:
        #   - "vault"
    - name: "RemovePodsHavingTooManyRestarts"
      args:
        podRestartThreshold: 20
        includingInitContainers: true
    - name: "RemovePodsViolatingTopologySpreadConstraint"
      args:
        includeSoftConstraints: false
    - name: "LowNodeUtilization"
      args:
        thresholds:
          "memory": 20
        targetThresholds:
          "memory": 80
    - name: "HighNodeUtilization"
      args:
        thresholds:
          "memory": 20
        evictableNamespaces:
          namespaces:
            exclude:
            - "kube-system"
            - "vault"
    plugins:
      evict:
        enabled:
          - "DefaultEvictor"
      balance:
        enabled:
          - "RemovePodsViolatingTopologySpreadConstraint"
          - "LowNodeUtilization"
          - "HighNodeUtilization"
      deschedule:
        enabled:
          - "RemoveFailedPods"
          - "PodLifeTime"
          - "RemovePodsHavingTooManyRestarts"

I installed the descheduler with Helm.

How can I apply this Policy to the descheduler?
It didn't create any CRD, and also I didn't see anything about this on the docs.

Should I add it here at the  values?

Maybe I should define it at the values.yaml like this?
kind: Deployment

image:
  repository: mydomain-regisry/descheduler
  tag: "v0.26.1"

imagePullSecrets:
  - name: k8s-nexus

deschedulingInterval: 5m

replicas: 2
leaderElection: 
  enabled: true
  leaseDuration: 15s
  renewDeadline: 10s
  retryPeriod: 2s
  resourceLock: "leases"
  resourceName: "descheduler"
  resourceNamescape: "kube-system"

deschedulerPolicyAPIVersion: "descheduler/v1alpha2"

deschedulerPolicy:
  profiles:
  - name: ProfileName
    pluginConfig:
    - name: "DefaultEvictor"
      args:
        evictFailedBarePods: true
        nodeFit: true
    - name: "RemoveFailedPods"
      args:
        reasons:
        - "NodeAffinity"
        includingInitContainers: true
        excludeOwnerKinds:
        - "Job"
    - name: "PodLifeTime"
      args:
        maxPodLifeTimeSeconds: 3600
        states:
        - "Pending"
        - "PodInitializing"
        # namespaces:
        #   exclude:
        #   - "vault"
    - name: "RemovePodsHavingTooManyRestarts"
      args:
        podRestartThreshold: 20
        includingInitContainers: true
    - name: "RemovePodsViolatingTopologySpreadConstraint"
      args:
        includeSoftConstraints: false
    - name: "LowNodeUtilization"
      args:
        thresholds:
          "memory": 20
        targetThresholds:
          "memory": 80
    - name: "HighNodeUtilization"
      args:
        thresholds:
          "memory": 20
        evictableNamespaces:
          namespaces:
            exclude:
            - "kube-system"
            - "vault"
    plugins:
      evict:
        enabled:
          - "DefaultEvictor"
      balance:
        enabled:
          - "RemovePodsViolatingTopologySpreadConstraint"
          - "LowNodeUtilization"
          - "HighNodeUtilization"
      deschedule:
        enabled:
          - "RemoveFailedPods"
          - "PodLifeTime"
          - "RemovePodsHavingTooManyRestarts"

Duplicate issue #1351: Not installing CRDs
Created: 2024-02-16T17:07:11Z
descheduler version: 0.29.0
When installing with Helm chart CRDs not getting installed.
Using apiVersion: "descheduler/v1alpha2" , kind: "DeschedulerPolicy"
When I try to create the policy manually it doen't find the CRD amd in you chart repo and your repo I can not seem to find the CRDs

Closing comment (2024-02-16T17:14:23Z): The Policy config isn't a k8s resource (so you don't create it as a CRD). It is just a literal text file that you pass to the descheduler binary when it runs. In kubernetes, this can be done by creating a configmap with the config file as its data and using volume mounts to mount that configmap as a file in your Pod's container filesystem.
There are examples of doing this manually in the k8s manifests mentioned in the quickstart guide. The Helm chart makes this a little easier by parsing the options from a single values.yaml file.
Hope that helps!
/remove-kind bug
/kind support
Duplicate: #1131