multigrescluster

package
v0.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

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:

  1. 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).

  2. 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.

  3. 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.

  4. 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").

  5. Lifecycle Management: It relies on Kubernetes owner references for garbage collection of child resources and cleaned up before the parent MultigresCluster is removed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCell

BuildCell constructs the desired Cell resource.

func BuildGlobalTopoServer

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL