diff --git a/apis/reaper/v1alpha1/reaper_types.go b/apis/reaper/v1alpha1/reaper_types.go index 41105dc3e..b2aadf9ad 100644 --- a/apis/reaper/v1alpha1/reaper_types.go +++ b/apis/reaper/v1alpha1/reaper_types.go @@ -243,8 +243,8 @@ type ReaperSpec struct { // DatacenterRef is the reference of a CassandraDatacenter resource that this Reaper instance should manage. It will // also be used as the backend for persisting Reaper's state. Reaper must be able to access the JMX port (7199 by // default) and the CQL port (9042 by default) on this DC. - // +kubebuilder:validation:Required - DatacenterRef CassandraDatacenterRef `json:"datacenterRef"` + // +optional + DatacenterRef CassandraDatacenterRef `json:"datacenterRef,omitempty"` // DatacenterAvailability indicates to Reaper its deployment in relation to the target datacenter's network. // For single-DC clusters, the default (ALL) is fine. For multi-DC clusters, it is recommended to use EACH, @@ -267,6 +267,11 @@ type ReaperSpec struct { // +optional // +kubebuilder:default=false SkipSchemaMigration bool `json:"skipSchemaMigration,omitempty"` + + // Whether this Reaper instance should register Cassandra clusters for repair. If this is set to false or omitted, + // this Reaper instance will only repair the CassandraDatacener referenced by DatacenterRef. + // +optional + ControlPlaneMode bool `json:"controlPlaneMode,omitempty"` } // ReaperProgress is a word summarizing the state of a Reaper resource. diff --git a/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml b/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml index 599955f17..260f6cb8f 100644 --- a/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml +++ b/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml @@ -31875,6 +31875,11 @@ spec: description: The image tag to use. Defaults to "latest". type: string type: object + controlPlaneMode: + description: |- + Whether this Reaper instance should register Cassandra clusters for repair. If this is set to false or omitted, + this Reaper instance will only repair the CassandraDatacener referenced by DatacenterRef. + type: boolean datacenterAvailability: default: ALL description: |- @@ -33292,8 +33297,6 @@ spec: type: string type: object x-kubernetes-map-type: atomic - required: - - datacenterRef type: object status: description: ReaperStatus defines the observed state of Reaper diff --git a/config/crd/bases/reaper.k8ssandra.io_reapers.yaml b/config/crd/bases/reaper.k8ssandra.io_reapers.yaml index 9523a9dad..9d6d7e048 100644 --- a/config/crd/bases/reaper.k8ssandra.io_reapers.yaml +++ b/config/crd/bases/reaper.k8ssandra.io_reapers.yaml @@ -1030,6 +1030,11 @@ spec: description: The image tag to use. Defaults to "latest". type: string type: object + controlPlaneMode: + description: |- + Whether this Reaper instance should register Cassandra clusters for repair. If this is set to false or omitted, + this Reaper instance will only repair the CassandraDatacener referenced by DatacenterRef. + type: boolean datacenterAvailability: default: ALL description: |- @@ -2447,8 +2452,6 @@ spec: type: string type: object x-kubernetes-map-type: atomic - required: - - datacenterRef type: object status: description: ReaperStatus defines the observed state of Reaper diff --git a/controllers/reaper/reaper_controller.go b/controllers/reaper/reaper_controller.go index cd3df5fa8..53bb714b4 100644 --- a/controllers/reaper/reaper_controller.go +++ b/controllers/reaper/reaper_controller.go @@ -91,24 +91,31 @@ func (r *ReaperReconciler) reconcile(ctx context.Context, actualReaper *reaperap actualReaper.Status.Progress = reaperapi.ReaperProgressPending actualReaper.Status.SetNotReady() - actualDc, result, err := r.reconcileDatacenter(ctx, actualReaper, logger) - if !result.IsZero() || err != nil { - return result, err + var actualDc *cassdcapi.CassandraDatacenter + // skip DC reconcile if Reaper is in Control Plane + if actualReaper.Spec.ControlPlaneMode { + logger.Info("Skipping Reaper DC reconcile, Reaper is in Control Plane mode") + } else { + dc, result, err := r.reconcileDatacenter(ctx, actualReaper, logger) + if !result.IsZero() || err != nil { + return result, err + } + actualDc = dc } actualReaper.Status.Progress = reaperapi.ReaperProgressDeploying - if result, err = r.reconcileDeployment(ctx, actualReaper, actualDc, logger); !result.IsZero() || err != nil { + if result, err := r.reconcileDeployment(ctx, actualReaper, actualDc, logger); !result.IsZero() || err != nil { return result, err } - if result, err = r.reconcileService(ctx, actualReaper, logger); !result.IsZero() || err != nil { + if result, err := r.reconcileService(ctx, actualReaper, logger); !result.IsZero() || err != nil { return result, err } actualReaper.Status.Progress = reaperapi.ReaperProgressConfiguring - if result, err = r.configureReaper(ctx, actualReaper, actualDc, logger); !result.IsZero() || err != nil { + if result, err := r.configureReaper(ctx, actualReaper, actualDc, logger); !result.IsZero() || err != nil { return result, err } diff --git a/pkg/reaper/deployment.go b/pkg/reaper/deployment.go index 54e371649..767d9898b 100644 --- a/pkg/reaper/deployment.go +++ b/pkg/reaper/deployment.go @@ -62,11 +62,15 @@ func NewDeployment(reaper *api.Reaper, dc *cassdcapi.CassandraDatacenter, keysto readinessProbe := computeProbe(reaper.Spec.ReadinessProbe) livenessProbe := computeProbe(reaper.Spec.LivenessProbe) + storageType := "cassandra" + if reaper.Spec.ControlPlaneMode { + storageType = "memory" + } envVars := []corev1.EnvVar{ { Name: "REAPER_STORAGE_TYPE", - Value: "cassandra", + Value: storageType, }, { Name: "REAPER_ENABLE_DYNAMIC_SEED_LIST",