Documentation
¶
Overview ¶
Package multigrescluster implements the controller for the root MultigresCluster resource.
The MultigresCluster controller acts as the central orchestrator for the database system. It is responsible for translating the high-level user intent into specific child resources. Its primary responsibilities include:
Global Component Management: It directly manages singleton resources defined at the cluster level, such as the MultiAdmin deployment. It also manages the Global TopoServer (via a child TopoServer CR) when the cluster is configured for managed topology (Etcd).
Resource Fan-Out (Child CR Management): It projects the configuration defined in the MultigresCluster spec (Cells and Databases) into discrete child Custom Resources (Cell and TableGroup). These child resources are then reconciled by their own respective controllers.
Defaulting and Template Resolution: It applies in-memory defaults (robustness against webhook unavailability) and leverages the 'pkg/resolver' module to fetch CoreTemplates, CellTemplates, and ShardTemplates, merging them with user-defined overrides to produce the final specifications for child resources.
Status Aggregation: It continually observes the status of its child resources to produce a high-level summary of the cluster's health (e.g., "All cells ready", "Database X has Y/Z shards ready").
Lifecycle Management: It relies on Kubernetes owner references for garbage collection of child resources and cleaned up before the parent MultigresCluster is removed.
Index ¶
- func BuildCell(cluster *multigresv1alpha1.MultigresCluster, ...) (*multigresv1alpha1.Cell, error)
- func BuildGlobalTopoServer(cluster *multigresv1alpha1.MultigresCluster, ...) (*multigresv1alpha1.TopoServer, error)
- func BuildMultiAdminDeployment(cluster *multigresv1alpha1.MultigresCluster, ...) (*appsv1.Deployment, error)
- func BuildMultiAdminService(cluster *multigresv1alpha1.MultigresCluster, scheme *runtime.Scheme) (*corev1.Service, error)
- func BuildMultiAdminWebDeployment(cluster *multigresv1alpha1.MultigresCluster, ...) (*appsv1.Deployment, error)
- func BuildMultiAdminWebService(cluster *multigresv1alpha1.MultigresCluster, ...) (*corev1.Service, error)
- func BuildMultiGatewayGlobalService(cluster *multigresv1alpha1.MultigresCluster, ...) (*corev1.Service, error)
- func BuildTableGroup(cluster *multigresv1alpha1.MultigresCluster, ...) (*multigresv1alpha1.TableGroup, error)
- type MultigresClusterReconciler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCell ¶
func BuildCell( cluster *multigresv1alpha1.MultigresCluster, cellCfg *multigresv1alpha1.CellConfig, gatewaySpec *multigresv1alpha1.StatelessSpec, gatewayPlacement *multigresv1alpha1.PodPlacementSpec, localTopoSpec *multigresv1alpha1.LocalTopoServerSpec, globalTopoRef multigresv1alpha1.GlobalTopoServerRef, allCellNames []multigresv1alpha1.CellName, scheme *runtime.Scheme, ) (*multigresv1alpha1.Cell, error)
BuildCell constructs the desired Cell resource.
func BuildGlobalTopoServer ¶
func BuildGlobalTopoServer( cluster *multigresv1alpha1.MultigresCluster, spec *multigresv1alpha1.GlobalTopoServerSpec, scheme *runtime.Scheme, ) (*multigresv1alpha1.TopoServer, error)
BuildGlobalTopoServer constructs the desired TopoServer for the global topology. Note: We do NOT use safe hashing here because GlobalTopo is a singleton resource per cluster with a predictable name pattern that is unlikely to exceed length limits. It returns nil, nil if the spec does not require an Etcd server (e.g. external).
func BuildMultiAdminDeployment ¶
func BuildMultiAdminDeployment( cluster *multigresv1alpha1.MultigresCluster, spec *multigresv1alpha1.StatelessSpec, scheme *runtime.Scheme, ) (*appsv1.Deployment, error)
BuildMultiAdminDeployment constructs the desired MultiAdmin Deployment. Note: We do NOT use safe hashing here because MultiAdmin is a singleton resource per cluster with a predictable name pattern that is unlikely to exceed length limits.
func BuildMultiAdminService ¶
func BuildMultiAdminService( cluster *multigresv1alpha1.MultigresCluster, scheme *runtime.Scheme, ) (*corev1.Service, error)
BuildMultiAdminService constructs the desired Service for MultiAdmin.
func BuildMultiAdminWebDeployment ¶
func BuildMultiAdminWebDeployment( cluster *multigresv1alpha1.MultigresCluster, spec *multigresv1alpha1.StatelessSpec, scheme *runtime.Scheme, ) (*appsv1.Deployment, error)
BuildMultiAdminWebDeployment constructs the desired MultiAdminWeb Deployment.
func BuildMultiAdminWebService ¶
func BuildMultiAdminWebService( cluster *multigresv1alpha1.MultigresCluster, extAW *multigresv1alpha1.ExternalAdminWebConfig, scheme *runtime.Scheme, ) (*corev1.Service, error)
BuildMultiAdminWebService constructs the desired Service for MultiAdminWeb.
func BuildMultiGatewayGlobalService ¶
func BuildMultiGatewayGlobalService( cluster *multigresv1alpha1.MultigresCluster, extGw *multigresv1alpha1.ExternalGatewayConfig, scheme *runtime.Scheme, ) (*corev1.Service, error)
BuildMultiGatewayGlobalService constructs a cluster-level Service that selects all multigateway pods across all cells. This provides a stable DNS name for multiadmin-web to connect to PostgreSQL via any available multigateway, regardless of which cells exist.
func BuildTableGroup ¶
func BuildTableGroup( cluster *multigresv1alpha1.MultigresCluster, dbCfg multigresv1alpha1.DatabaseConfig, tgCfg *multigresv1alpha1.TableGroupConfig, resolvedShards []multigresv1alpha1.ShardResolvedSpec, globalTopoRef multigresv1alpha1.GlobalTopoServerRef, scheme *runtime.Scheme, ) (*multigresv1alpha1.TableGroup, error)
BuildTableGroup constructs the desired TableGroup resource.
Types ¶
type MultigresClusterReconciler ¶
type MultigresClusterReconciler struct {
client.Client
Scheme *runtime.Scheme
Recorder record.EventRecorder
// CreateTopoStore overrides the default topology store factory for testing.
CreateTopoStore func(multigresv1alpha1.GlobalTopoServerRef) (topoclient.Store, error)
}
MultigresClusterReconciler reconciles a MultigresCluster object.
func (*MultigresClusterReconciler) Reconcile ¶
func (r *MultigresClusterReconciler) Reconcile( ctx context.Context, req ctrl.Request, ) (ctrl.Result, error)
Reconcile resolves templates, reconciles child resources (Cells, TableGroups, TopoServer), and updates the MultigresCluster status and tracking labels.
+kubebuilder:rbac:groups=multigres.com,resources=multigresclusters,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=multigres.com,resources=multigresclusters/status,verbs=get;update;patch +kubebuilder:rbac:groups=multigres.com,resources=multigresclusters/finalizers,verbs=update +kubebuilder:rbac:groups=multigres.com,resources=coretemplates;celltemplates;shardtemplates,verbs=get;list;watch +kubebuilder:rbac:groups=multigres.com,resources=cells;tablegroups;toposervers,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=multigres.com,resources=shards,verbs=get;list;watch +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
func (*MultigresClusterReconciler) SetupWithManager ¶
func (r *MultigresClusterReconciler) SetupWithManager( mgr ctrl.Manager, opts ...controller.Options, ) error
SetupWithManager sets up the controller with the Manager.