Skip to content

Support v1alpha1.ScyllaDBDatacenter registration with global ScyllaDB Manager instance #2590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions helm/scylla-operator/templates/edit_clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rules:
- scylladbmonitorings
- scylladbdatacenters
- scylladbclusters
- scylladbmanagerclusterregistrations
verbs:
- create
- patch
Expand Down
18 changes: 4 additions & 14 deletions helm/scylla-operator/templates/operator.clusterrole_def.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ rules:
- scylladbdatacenters
- remotekubernetesclusters
- scylladbclusters
- scylladbmanagerclusterregistrations
verbs:
- create
- delete
Expand All @@ -125,6 +126,7 @@ rules:
- scylladbdatacenters/status
- remotekubernetesclusters/status
- scylladbclusters/status
- scylladbmanagerclusterregistrations/status
verbs:
- get
- list
Expand Down Expand Up @@ -301,6 +303,7 @@ rules:
- scyllaclusters/finalizers
- scylladbdatacenters/finalizers
- scylladbmonitorings/finalizers
- scylladbmanagerclusterregistrations/finalizers
verbs:
- update
- apiGroups:
Expand Down Expand Up @@ -329,23 +332,10 @@ rules:
- daemonsets/finalizers
verbs:
- update
- apiGroups:
- scylla.scylladb.com
resources:
- scyllaclusters/finalizers
- scylladbdatacenters/finalizers
- scylladbmonitorings/finalizers
verbs:
- update
- apiGroups:
- policy
resources:
- poddisruptionbudgets/finalizers
verbs:
- update
- apiGroups:
- scylla.scylladb.com
resources:
- nodeconfigs/finalizers
verbs:
- update

1 change: 1 addition & 0 deletions helm/scylla-operator/templates/view_clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rules:
- scylladbmonitorings
- scylladbdatacenters
- scylladbclusters
- scylladbmanagerclusterregistrations
verbs:
- get
- list
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/scylla/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&RemoteKubernetesClusterList{},
&RemoteOwner{},
&RemoteOwnerList{},
&ScyllaDBManagerClusterRegistration{},
&ScyllaDBManagerClusterRegistrationList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (C) 2025 ScyllaDB

package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

type LocalScyllaDBReference struct {
// kind specifies the type of the resource.
Kind string `json:"kind"`
// name specifies the name of the resource.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be worth mentioning that the name references object in the same namespace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the Local in the struct name is a conventional way of saying this (by similarity to LocalObjectReference) - I could add a comment to the entire struct though, if it's not clear enough?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct name isn't visible in kubectl explain, while comments are.

Name string `json:"name"`
}

type ScyllaDBManagerClusterRegistrationSpec struct {
// scyllaDBClusterRef specifies the typed reference to the local ScyllaDB cluster.
// Supported kind is ScyllaDBDatacenter in scylla.scylladb.com group.
ScyllaDBClusterRef LocalScyllaDBReference `json:"scyllaDBClusterRef"`
}

type ScyllaDBManagerClusterRegistrationStatus struct {
// observedGeneration is the most recent generation observed for this ScyllaDBManagerClusterRegistration. It corresponds to the
// ScyllaDBManagerClusterRegistration's generation, which is updated on mutation by the API Server.
// +optional
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`

// conditions hold conditions describing ScyllaDBManagerClusterRegistration state.
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// clusterID reflects the internal identification number of the cluster in ScyllaDB Manager state.
// +optional
ClusterID *string `json:"clusterID,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:printcolumn:name="PROGRESSING",type=string,JSONPath=".status.conditions[?(@.type=='Progressing')].status"
// +kubebuilder:printcolumn:name="DEGRADED",type=string,JSONPath=".status.conditions[?(@.type=='Degraded')].status"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"

type ScyllaDBManagerClusterRegistration struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// spec defines the desired state of ScyllaDBManagerClusterRegistration.
Spec ScyllaDBManagerClusterRegistrationSpec `json:"spec,omitempty"`

// status reflects the observed state of ScyllaDBManagerClusterRegistration.
Status ScyllaDBManagerClusterRegistrationStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ScyllaDBManagerClusterRegistrationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ScyllaDBManagerClusterRegistration `json:"items"`
}
37 changes: 37 additions & 0 deletions pkg/cmd/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import (
scyllaversionedclient "github.com/scylladb/scylla-operator/pkg/client/scylla/clientset/versioned"
scyllainformers "github.com/scylladb/scylla-operator/pkg/client/scylla/informers/externalversions"
"github.com/scylladb/scylla-operator/pkg/clusterdomain"
"github.com/scylladb/scylla-operator/pkg/controller/globalscylladbmanager"
"github.com/scylladb/scylla-operator/pkg/controller/nodeconfig"
"github.com/scylladb/scylla-operator/pkg/controller/nodeconfigpod"
"github.com/scylladb/scylla-operator/pkg/controller/orphanedpv"
"github.com/scylladb/scylla-operator/pkg/controller/remotekubernetescluster"
"github.com/scylladb/scylla-operator/pkg/controller/scyllacluster"
"github.com/scylladb/scylla-operator/pkg/controller/scylladbcluster"
"github.com/scylladb/scylla-operator/pkg/controller/scylladbdatacenter"
"github.com/scylladb/scylla-operator/pkg/controller/scylladbmanagerclusterregistration"
"github.com/scylladb/scylla-operator/pkg/controller/scylladbmonitoring"
"github.com/scylladb/scylla-operator/pkg/controller/scyllaoperatorconfig"
"github.com/scylladb/scylla-operator/pkg/crypto"
Expand Down Expand Up @@ -675,6 +677,29 @@ func (o *OperatorOptions) run(ctx context.Context, streams genericclioptions.IOS
return fmt.Errorf("can't create ScyllaDBCluster controller: %w", err)
}

gsmc, err := globalscylladbmanager.NewController(
o.kubeClient,
o.scyllaClient.ScyllaV1alpha1(),
scyllaInformers.Scylla().V1alpha1().ScyllaDBManagerClusterRegistrations(),
scyllaInformers.Scylla().V1alpha1().ScyllaDBDatacenters(),
kubeInformers.Core().V1().Namespaces(),
)
if err != nil {
return fmt.Errorf("can't create global ScyllaDB Manager controller: %w", err)
}

smcrc, err := scylladbmanagerclusterregistration.NewController(
o.kubeClient,
o.scyllaClient.ScyllaV1alpha1(),
scyllaInformers.Scylla().V1alpha1().ScyllaDBManagerClusterRegistrations(),
scyllaInformers.Scylla().V1alpha1().ScyllaDBDatacenters(),
kubeInformers.Core().V1().Secrets(),
kubeInformers.Core().V1().Namespaces(),
)
if err != nil {
return fmt.Errorf("can't create ScyllaDBManagerClusterRegistration controller: %w", err)
}

var wg sync.WaitGroup
defer wg.Wait()

Expand Down Expand Up @@ -786,6 +811,18 @@ func (o *OperatorOptions) run(ctx context.Context, streams genericclioptions.IOS
sdbcc.Run(ctx, o.ConcurrentSyncs)
}()

wg.Add(1)
go func() {
defer wg.Done()
gsmc.Run(ctx)
}()

wg.Add(1)
go func() {
defer wg.Done()
smcrc.Run(ctx, o.ConcurrentSyncs)
}()

<-ctx.Done()

return nil
Expand Down
Loading