Allow using the PodSafeToEvictKey annotation in reverse
Adding the "cluster-autoscaler.kubernetes.io/safe-to-evict": "false" annotation to a pod prevents the cluster autoscaler from touching it.
This commit is contained in:
parent
b0316799b1
commit
a863acba33
|
|
@ -78,6 +78,10 @@ Cluster Autoscaler decreases the size of the cluster when some nodes are consist
|
|||
* Pods with local storage. *
|
||||
* Pods that cannot be moved elsewhere due to various constraints (lack of resources, non-matching node selctors or affinity,
|
||||
matching anti-affinity, etc)
|
||||
* Pods that have the following annotation set:
|
||||
```
|
||||
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false"
|
||||
```
|
||||
|
||||
<sup>*</sup>Unless the pod has the following annotation (supported in CA 1.0.3 or later):
|
||||
```
|
||||
|
|
|
|||
|
|
@ -195,6 +195,9 @@ func GetPodsForDeletionOnNodeDrain(
|
|||
if HasLocalStorage(pod) && skipNodesWithLocalStorage {
|
||||
return []*apiv1.Pod{}, fmt.Errorf("pod with local storage present: %s", pod.Name)
|
||||
}
|
||||
if hasNotSafeToEvictAnnotation(pod) {
|
||||
return []*apiv1.Pod{}, fmt.Errorf("pod annotated as not safe to evict present: %s", pod.Name)
|
||||
}
|
||||
}
|
||||
pods = append(pods, pod)
|
||||
}
|
||||
|
|
@ -246,3 +249,8 @@ func checkKubeSystemPDBs(pod *apiv1.Pod, pdbs []*policyv1.PodDisruptionBudget) (
|
|||
func hasSaveToEvictAnnotation(pod *apiv1.Pod) bool {
|
||||
return pod.GetAnnotations()[PodSafeToEvictKey] == "true"
|
||||
}
|
||||
|
||||
// This checks if pod has PodSafeToEvictKey annotation set to false
|
||||
func hasNotSafeToEvictAnnotation(pod *apiv1.Pod) bool {
|
||||
return pod.GetAnnotations()[PodSafeToEvictKey] == "false"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue