@@ -22,13 +22,13 @@ import (
22
22
23
23
const (
24
24
// 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 ".
26
26
// This label takes precedence over MachineDrainRules defined in the management cluster.
27
27
PodDrainLabel = "cluster.x-k8s.io/drain"
28
28
)
29
29
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
32
32
type MachineDrainRuleDrainBehavior string
33
33
34
34
const (
@@ -37,6 +37,10 @@ const (
37
37
38
38
// MachineDrainRuleDrainBehaviorSkip means the drain for a Pod should be skipped.
39
39
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"
40
44
)
41
45
42
46
// MachineDrainRuleSpec defines the spec of a MachineDrainRule.
@@ -112,14 +116,16 @@ type MachineDrainRuleSpec struct {
112
116
// MachineDrainRuleDrainConfig configures if and how Pods are drained.
113
117
type MachineDrainRuleDrainConfig struct {
114
118
// behavior defines the drain behavior.
115
- // Can be either "Drain" or "Skip ".
119
+ // Can be either "Drain", "Skip", or "WaitCompleted ".
116
120
// "Drain" means that the Pods to which this MachineDrainRule applies will be drained.
117
121
// If behavior is set to "Drain" the order in which Pods are drained can be configured
118
122
// with the order field. When draining Pods of a Node the Pods will be grouped by order
119
123
// and one group after another will be drained (by increasing order). Cluster API will
120
124
// wait until all Pods of a group are terminated / removed from the Node before starting
121
125
// with the next group.
122
126
// "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.
123
129
// +required
124
130
Behavior MachineDrainRuleDrainBehavior `json:"behavior"`
125
131
0 commit comments