Skip to content

Commit f2d68ed

Browse files
Merge pull request #641 from alexander-demicev/defaultreplicas
Default RKE2 control plane replicas to 1 if not specified
2 parents 80c7591 + ae404ce commit f2d68ed

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
lines changed

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ SETUP_ENVTEST_BIN := setup-envtest
7676
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
7777
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
7878

79-
CONTROLLER_GEN_VER := v0.16.1
79+
CONTROLLER_GEN_VER := v0.17.3
8080
CONTROLLER_GEN_BIN := controller-gen
8181
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))
8282
CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
8383

84-
CONVERSION_GEN_VER := v0.30.0
84+
CONVERSION_GEN_VER := v0.33.0
8585
CONVERSION_GEN_BIN := conversion-gen
8686
# We are intentionally using the binary without version suffix, to avoid the version
8787
# in generated files.
@@ -226,7 +226,6 @@ generate-go-conversions-rke2-bootstrap: $(CONVERSION_GEN) ## Generate conversion
226226
generate-go-conversions-rke2-control-plane: $(CONVERSION_GEN) ## Generate conversions go code for the rke2 control plane
227227
$(MAKE) clean-generated-conversions SRC_DIRS="./controlplane/api/v1alpha1"
228228
$(CONVERSION_GEN) \
229-
--extra-dirs=github.com/rancher/cluster-api-provider-rke2/bootstrap/api/v1alpha1 \
230229
--output-file=zz_generated.conversion.go $(ROOT_DIR)/$(CAPRKE2_DIR) \
231230
--go-header-file=./hack/boilerplate.go.txt \
232231
./controlplane/api/v1alpha1

bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.17.3
77
name: rke2configs.bootstrap.cluster.x-k8s.io
88
spec:
99
group: bootstrap.cluster.x-k8s.io

bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configtemplates.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.17.3
77
name: rke2configtemplates.bootstrap.cluster.x-k8s.io
88
spec:
99
group: bootstrap.cluster.x-k8s.io

controlplane/api/v1beta1/rke2controlplane_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type RKE2ControlPlaneSpec struct {
4848
bootstrapv1.RKE2ConfigSpec `json:",inline"`
4949

5050
// Replicas is the number of replicas for the Control Plane.
51+
// +optional
5152
Replicas *int32 `json:"replicas,omitempty"`
5253

5354
// Version defines the desired Kubernetes version.

controlplane/api/v1beta1/rke2controlplane_webhook.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ func (rd *RKE2ControlPlaneCustomDefaulter) Default(_ context.Context, obj runtim
104104
rcp.Spec.MachineTemplate.NodeDeletionTimeout = &metav1.Duration{Duration: defaultNodeDeletionTimeout}
105105
}
106106

107+
// Set replicas to 1 if not set
108+
if rcp.Spec.Replicas == nil {
109+
replicas := int32(1)
110+
rcp.Spec.Replicas = &replicas
111+
}
112+
107113
return nil
108114
}
109115

controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanes.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.17.3
77
name: rke2controlplanes.controlplane.cluster.x-k8s.io
88
spec:
99
group: controlplane.cluster.x-k8s.io

controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanetemplates.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.17.3
77
name: rke2controlplanetemplates.controlplane.cluster.x-k8s.io
88
spec:
99
group: controlplane.cluster.x-k8s.io

0 commit comments

Comments
 (0)