diff --git a/api/v1/seaweed_types.go b/api/v1/seaweed_types.go index 74f1516..2e08556 100644 --- a/api/v1/seaweed_types.go +++ b/api/v1/seaweed_types.go @@ -32,13 +32,10 @@ type SeaweedSpec struct { MetricsAddress string `json:"metricsAddress,omitempty"` // VolumeServerCount is the number of volume servers, default to 1 - VolumeServerCount int `json:"volumeServerCount,omitempty"` + VolumeServerCount int32 `json:"volumeServerCount,omitempty"` // FilerCount is the number of filers, default to 1 - FilerCount int `json:"filerCount,omitempty"` - - // S3Count is the number of s3, default to 1 - S3Count int `json:"s3Count,omitempty"` + FilerCount int32 `json:"filerCount,omitempty"` } // SeaweedStatus defines the observed state of Seaweed diff --git a/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml b/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml index e9daa64..566a871 100644 --- a/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml +++ b/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml @@ -38,16 +38,15 @@ spec: properties: filerCount: description: FilerCount is the number of filers, default to 1 + format: int32 type: integer metricsAddress: description: MetricsAddress is Prometheus gateway address type: string - s3Count: - description: S3Count is the number of s3, default to 1 - type: integer volumeServerCount: description: VolumeServerCount is the number of volume servers, default to 1 + format: int32 type: integer type: object status: diff --git a/config/samples/seaweed_v1_seaweed.yaml b/config/samples/seaweed_v1_seaweed.yaml index 8f4f5c0..99ee9ac 100644 --- a/config/samples/seaweed_v1_seaweed.yaml +++ b/config/samples/seaweed_v1_seaweed.yaml @@ -4,4 +4,5 @@ metadata: name: seaweed1 spec: # Add fields here - foo: bar + volumeServerCount: 4 + filerCount: 2 diff --git a/controllers/controller_filer.go b/controllers/controller_filer.go index 409dfc7..5c8d999 100644 --- a/controllers/controller_filer.go +++ b/controllers/controller_filer.go @@ -48,6 +48,17 @@ func (r *SeaweedReconciler) ensureFilerStatefulSet(seaweedCR *seaweedv1.Seaweed) log.Error(err, "Failed to get filer statefulset") return ReconcileResult(err) } + + if *filerStatefulSet.Spec.Replicas != seaweedCR.Spec.FilerCount { + filerStatefulSet.Spec.Replicas = &seaweedCR.Spec.FilerCount + if err = r.Update(ctx, filerStatefulSet); err != nil { + log.Error(err, "Failed to update filer statefulset", "Namespace", filerStatefulSet.Namespace, "Name", filerStatefulSet.Name) + return ReconcileResult(err) + } + // Deployment created successfully - return and requeue + return ReconcileResult(err) + } + log.Info("Get filer stateful set " + filerStatefulSet.Name) return ReconcileResult(err) } diff --git a/controllers/controller_volume.go b/controllers/controller_volume.go index f92bd99..d86328d 100644 --- a/controllers/controller_volume.go +++ b/controllers/controller_volume.go @@ -48,6 +48,17 @@ func (r *SeaweedReconciler) ensureVolumeServerStatefulSet(seaweedCR *seaweedv1.S log.Error(err, "Failed to get volume server statefulset") return ReconcileResult(err) } + + if *volumeServerStatefulSet.Spec.Replicas != seaweedCR.Spec.VolumeServerCount { + volumeServerStatefulSet.Spec.Replicas = &seaweedCR.Spec.VolumeServerCount + if err = r.Update(ctx, volumeServerStatefulSet); err != nil { + log.Error(err, "Failed to update volume statefulset", "Namespace", volumeServerStatefulSet.Namespace, "Name", volumeServerStatefulSet.Name) + return ReconcileResult(err) + } + // Deployment created successfully - return and requeue + return ReconcileResult(err) + } + log.Info("Get volume stateful set " + volumeServerStatefulSet.Name) return ReconcileResult(err) } diff --git a/controllers/seaweed_controller.go b/controllers/seaweed_controller.go index 05587a2..7583149 100644 --- a/controllers/seaweed_controller.go +++ b/controllers/seaweed_controller.go @@ -57,9 +57,6 @@ func (r *SeaweedReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { if seaweedCR.Spec.FilerCount == 0 { seaweedCR.Spec.FilerCount = 1 } - if seaweedCR.Spec.S3Count == 0 { - seaweedCR.Spec.S3Count = 1 - } if done, result, err = r.ensureMaster(seaweedCR); done { return result, err