forked from karmada-io/karmada
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request karmada-io#3475 from chaunceyjiang/graceful
fix: graceful-eviction still works after an unexpected restart of karmada-controller-manager
Showing
9 changed files
with
88 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package patcher | ||
|
||
import ( | ||
appsv1 "k8s.io/api/apps/v1" | ||
"k8s.io/apimachinery/pkg/labels" | ||
) | ||
|
||
// Patcher defines various of var that need be pathed. | ||
type Patcher struct { | ||
labels map[string]string | ||
annotations map[string]string | ||
} | ||
|
||
// NewPatcher returns a Patcher | ||
func NewPatcher() *Patcher { | ||
return &Patcher{} | ||
} | ||
|
||
// WithSettings set the labels to Patcher | ||
func (p *Patcher) WithLabels(labels labels.Set) *Patcher { | ||
p.labels = labels | ||
return p | ||
} | ||
|
||
// WithAnnotations set annotations to Patcher | ||
func (p *Patcher) WithAnnotations(annotations labels.Set) *Patcher { | ||
p.annotations = annotations | ||
return p | ||
} | ||
|
||
// ForDeployment patchs various of var with the manifest | ||
func (p *Patcher) ForDeployment(deployment *appsv1.Deployment) { | ||
deployment.Labels = labels.Merge(deployment.Labels, p.labels) | ||
deployment.Spec.Template.Labels = labels.Merge(deployment.Spec.Template.Labels, p.labels) | ||
|
||
deployment.Annotations = labels.Merge(deployment.Annotations, p.annotations) | ||
deployment.Spec.Template.Annotations = labels.Merge(deployment.Spec.Template.Annotations, p.annotations) | ||
} | ||
|
||
// ForStatefulSet patchs various of var with the manifest | ||
func (p *Patcher) ForStatefulSet(sts *appsv1.StatefulSet) { | ||
sts.Labels = labels.Merge(sts.Labels, p.labels) | ||
sts.Spec.Template.Labels = labels.Merge(sts.Spec.Template.Labels, p.labels) | ||
|
||
sts.Annotations = labels.Merge(sts.Annotations, p.annotations) | ||
sts.Spec.Template.Annotations = labels.Merge(sts.Spec.Template.Annotations, p.annotations) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters