How to make Cluster Autoscaler skip a node for scale down in OpenShift 4

Solution Verified - Updated

Environment

  • Red Hat OpenShift Container Platform (RHOCP)
    • 4

Issue

  • Can I configure Cluster Autoscaler to skip a node for scale down process where a specific pod is running in OCP 4?
  • How to stop the Cluster Autoscaler from evicting a specific pod in the scale-down process?

Resolution

To make the cluster autoscaler skip a node for scale-down process, add the annotation "cluster-autoscaler.kubernetes.io/safe-to-evict": "false" in the deployment or the pod definition. Example:

[...]
template:
     metadata:
       labels:
         app: jenkins
       annotations:
         "cluster-autoscaler.kubernetes.io/safe-to-evict": "false"             ## <-----

     spec:
       nodeSelector:
         failure-domain.beta.kubernetes.io/zone: us-west-2b
[...]

Root Cause

Cluster Autoscaler is designed to reduce the number of nodes when the load is reduced. In this process, Cluster Autoscaler can delete any node which satisfies the criteria. Refer to How does scale down works in Cluster Autoscaler in OCP 4? for additional information.

SBR
Components

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.