Skip to content

Commit

Permalink
PDB component sets unhealthyPodEvictionPolicy based on annotation (#…
Browse files Browse the repository at this point in the history
…855)

* PDB component sets `unhealthyPodEvictionPolicy` based on annotation

* Address review comment from @unmarshall
  • Loading branch information
shreyas-s-rao authored Aug 9, 2024
1 parent c6231d0 commit 4802138
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/component/poddistruptionbudget/poddisruptionbudget.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ const (
ErrDeletePodDisruptionBudget druidv1alpha1.ErrorCode = "ERR_DELETE_POD_DISRUPTION_BUDGET"
)

const (
// annotationAllowUnhealthyPodEviction is an annotation that can be set on the Etcd resource, to allow unhealthy pod eviction.
// WARNING: this annotation may be removed at any point of time, and is NOT meant to be generally used.
annotationAllowUnhealthyPodEviction = "resources.druid.gardener.cloud/allow-unhealthy-pod-eviction"
)

type _resource struct {
client client.Client
}
Expand Down Expand Up @@ -107,6 +113,11 @@ func buildResource(etcd *druidv1alpha1.Etcd, pdb *policyv1.PodDisruptionBudget)
pdb.Spec.Selector = &metav1.LabelSelector{
MatchLabels: druidv1alpha1.GetDefaultLabels(etcd.ObjectMeta),
}
if metav1.HasAnnotation(etcd.ObjectMeta, annotationAllowUnhealthyPodEviction) {
pdb.Spec.UnhealthyPodEvictionPolicy = utils.PointerOf(policyv1.AlwaysAllow)
} else {
pdb.Spec.UnhealthyPodEvictionPolicy = nil
}
}

func getLabels(etcd *druidv1alpha1.Etcd) map[string]string {
Expand Down

0 comments on commit 4802138

Please sign in to comment.