Skip to content

Commit deed49b

Browse files
committed
Add minimum cluster size validation
Signed-off-by: Frederiko Costa <[email protected]>
1 parent 1adf166 commit deed49b

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

api/v1alpha1/etcdcluster_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type EtcdClusterSpec struct {
3131
// Important: Run "make" to regenerate code after modifying this file
3232

3333
// Size is the expected size of the etcd cluster.
34+
// +kubebuilder:validation:Minimum=0
3435
Size int `json:"size"`
3536
// Version is the expected version of the etcd container image.
3637
Version string `json:"version"`

config/crd/bases/operator.etcd.io_etcdclusters.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ spec:
4848
type: array
4949
size:
5050
description: Size is the expected size of the etcd cluster.
51+
minimum: 0
5152
type: integer
5253
storageSpec:
5354
description: StorageSpec is the name of the StorageSpec to use for

config/manager/kustomization.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
resources:
2-
- manager.yaml
2+
- manager.yaml
3+
apiVersion: kustomize.config.k8s.io/v1beta1
4+
kind: Kustomization
5+
images:
6+
- name: controller
7+
newName: controller
8+
newTag: latest

config/samples/operator_v1alpha1_etcdcluster.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ metadata:
66
app.kubernetes.io/managed-by: kustomize
77
name: etcdcluster-sample
88
spec:
9-
# TODO(user): Add fields here
9+
version: v3.5.20
10+
size: 3

internal/controller/etcdcluster_controller.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ func (r *EtcdClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
8383
return ctrl.Result{}, nil
8484
}
8585

86-
// TODO: Implement finalizer logic here
87-
8886
logger.Info("Reconciling EtcdCluster", "spec", etcdCluster.Spec)
8987

9088
// Get the statefulsets which has the same name as the EtcdCluster resource

0 commit comments

Comments
 (0)