8
8
cabptv1 "github.com/talos-systems/cluster-api-bootstrap-provider-talos/api/v1alpha3"
9
9
corev1 "k8s.io/api/core/v1"
10
10
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11
+ "k8s.io/apimachinery/pkg/util/intstr"
11
12
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
12
13
)
13
14
@@ -21,6 +22,15 @@ type ControlPlaneConfig struct {
21
22
ControlPlaneConfig cabptv1.TalosConfigSpec `json:"controlplane"`
22
23
}
23
24
25
+ // RolloutStrategyType defines the rollout strategies for a KubeadmControlPlane.
26
+ type RolloutStrategyType string
27
+
28
+ const (
29
+ // RollingUpdateStrategyType replaces the old control planes by new one using rolling update
30
+ // i.e. gradually scale up or down the old control planes and scale up or down the new one.
31
+ RollingUpdateStrategyType RolloutStrategyType = "RollingUpdate"
32
+ )
33
+
24
34
// TalosControlPlaneSpec defines the desired state of TalosControlPlane
25
35
type TalosControlPlaneSpec struct {
26
36
// Number of desired machines. Defaults to 1. When stacked etcd is used only
@@ -41,6 +51,39 @@ type TalosControlPlaneSpec struct {
41
51
// ControlPlaneConfig is a two TalosConfigSpecs
42
52
// to use for initializing and joining machines to the control plane.
43
53
ControlPlaneConfig ControlPlaneConfig `json:"controlPlaneConfig"`
54
+
55
+ // The RolloutStrategy to use to replace control plane machines with
56
+ // new ones.
57
+ // +optional
58
+ // +kubebuilder:default={type: "RollingUpdate", rollingUpdate: {maxSurge: 1}}
59
+ RolloutStrategy * RolloutStrategy `json:"rolloutStrategy,omitempty"`
60
+ }
61
+
62
+ // RolloutStrategy describes how to replace existing machines
63
+ // with new ones.
64
+ type RolloutStrategy struct {
65
+ // Rolling update config params. Present only if
66
+ // RolloutStrategyType = RollingUpdate.
67
+ // +optional
68
+ RollingUpdate * RollingUpdate `json:"rollingUpdate,omitempty"`
69
+
70
+ // Type of rollout. Currently the only supported strategy is
71
+ // "RollingUpdate".
72
+ // Default is RollingUpdate.
73
+ // +optional
74
+ Type RolloutStrategyType `json:"type,omitempty"`
75
+ }
76
+
77
+ // RollingUpdate is used to control the desired behavior of rolling update.
78
+ type RollingUpdate struct {
79
+ // The maximum number of control planes that can be scheduled above or under the
80
+ // desired number of control planes.
81
+ // Value can be an absolute number 1 or 0.
82
+ // Defaults to 1.
83
+ // Example: when this is set to 1, the control plane can be scaled
84
+ // up immediately when the rolling update starts.
85
+ // +optional
86
+ MaxSurge * intstr.IntOrString `json:"maxSurge,omitempty"`
44
87
}
45
88
46
89
// TalosControlPlaneStatus defines the observed state of TalosControlPlane
@@ -126,13 +169,13 @@ type TalosControlPlane struct {
126
169
}
127
170
128
171
// GetConditions returns the set of conditions for this object.
129
- func (in * TalosControlPlane ) GetConditions () clusterv1.Conditions {
130
- return in .Status .Conditions
172
+ func (r * TalosControlPlane ) GetConditions () clusterv1.Conditions {
173
+ return r .Status .Conditions
131
174
}
132
175
133
176
// SetConditions sets the conditions on this object.
134
- func (in * TalosControlPlane ) SetConditions (conditions clusterv1.Conditions ) {
135
- in .Status .Conditions = conditions
177
+ func (r * TalosControlPlane ) SetConditions (conditions clusterv1.Conditions ) {
178
+ r .Status .Conditions = conditions
136
179
}
137
180
138
181
// +kubebuilder:object:root=true
0 commit comments