Skip to content

Commit c1907f4

Browse files
authored
Merge pull request #5139 from vincepri/default-kcp-rollingupdate-03
🐛 KubeadmControlPlane rolloutstrategy should be defaulted in openapi
2 parents f80c6c0 + c3f0330 commit c1907f4

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type KubeadmControlPlaneSpec struct {
8585
// The RolloutStrategy to use to replace control plane machines with
8686
// new ones.
8787
// +optional
88+
// +kubebuilder:default={type: "RollingUpdate", rollingUpdate: {maxSurge: 1}}
8889
RolloutStrategy *RolloutStrategy `json:"rolloutStrategy,omitempty"`
8990
}
9091

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,10 @@ spec:
10461046
format: int32
10471047
type: integer
10481048
rolloutStrategy:
1049+
default:
1050+
rollingUpdate:
1051+
maxSurge: 1
1052+
type: RollingUpdate
10491053
description: The RolloutStrategy to use to replace control plane machines
10501054
with new ones.
10511055
properties:

controlplane/kubeadm/controllers/upgrade.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func (r *KubeadmControlPlaneReconciler) upgradeControlPlane(
3838
) (ctrl.Result, error) {
3939
logger := controlPlane.Logger()
4040

41+
if kcp.Spec.RolloutStrategy == nil || kcp.Spec.RolloutStrategy.RollingUpdate == nil {
42+
return ctrl.Result{}, errors.New("rolloutStrategy is not set")
43+
}
44+
4145
// TODO: handle reconciliation of etcd members and kubeadm config in case they get out of sync with cluster
4246

4347
workloadCluster, err := r.managementCluster.GetWorkloadCluster(ctx, util.ObjectKey(cluster))

0 commit comments

Comments
 (0)