Skip to content

Commit 9c05c5d

Browse files
committed
✨ Add MachineDrainRule "WaitCompleted"
Signed-off-by: Vince Prignano <vince@prigna.com>
1 parent da9bc79 commit 9c05c5d

File tree

12 files changed

+634
-146
lines changed

12 files changed

+634
-146
lines changed

api/v1beta1/machinedrainrules_types.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import (
2222

2323
const (
2424
// PodDrainLabel is the label that can be set on Pods in workload clusters to ensure a Pod is not drained.
25-
// The only valid value is "skip".
25+
// The only valid values are "skip" and "wait-completed".
2626
// This label takes precedence over MachineDrainRules defined in the management cluster.
2727
PodDrainLabel = "cluster.x-k8s.io/drain"
2828
)
2929

30-
// MachineDrainRuleDrainBehavior defines the drain behavior. Can be either "Drain" or "Skip".
31-
// +kubebuilder:validation:Enum=Drain;Skip
30+
// MachineDrainRuleDrainBehavior defines the drain behavior. Can be either "Drain", "Skip", or "WaitCompleted".
31+
// +kubebuilder:validation:Enum=Drain;Skip;WaitCompleted
3232
type MachineDrainRuleDrainBehavior string
3333

3434
const (
@@ -37,6 +37,10 @@ const (
3737

3838
// MachineDrainRuleDrainBehaviorSkip means the drain for a Pod should be skipped.
3939
MachineDrainRuleDrainBehaviorSkip MachineDrainRuleDrainBehavior = "Skip"
40+
41+
// MachineDrainRuleDrainBehaviorWaitCompleted means the Pod should not be evicted,
42+
// but overall drain should wait until the Pod completes.
43+
MachineDrainRuleDrainBehaviorWaitCompleted MachineDrainRuleDrainBehavior = "WaitCompleted"
4044
)
4145

4246
// MachineDrainRuleSpec defines the spec of a MachineDrainRule.
@@ -112,14 +116,16 @@ type MachineDrainRuleSpec struct {
112116
// MachineDrainRuleDrainConfig configures if and how Pods are drained.
113117
type MachineDrainRuleDrainConfig struct {
114118
// behavior defines the drain behavior.
115-
// Can be either "Drain" or "Skip".
119+
// Can be either "Drain", "Skip", or "WaitCompleted".
116120
// "Drain" means that the Pods to which this MachineDrainRule applies will be drained.
117121
// If behavior is set to "Drain" the order in which Pods are drained can be configured
118122
// with the order field. When draining Pods of a Node the Pods will be grouped by order
119123
// and one group after another will be drained (by increasing order). Cluster API will
120124
// wait until all Pods of a group are terminated / removed from the Node before starting
121125
// with the next group.
122126
// "Skip" means that the Pods to which this MachineDrainRule applies will be skipped during drain.
127+
// "WaitCompleted" means that the pods to which this MachineDrainRule applies will never be evicted
128+
// and we wait for them to be completed, it is enforced that pods marked with this behavior always have Order=0.
123129
// +required
124130
Behavior MachineDrainRuleDrainBehavior `json:"behavior"`
125131

api/v1beta1/zz_generated.openapi.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machinedrainrules.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)