How apsaradb/polardb-stack-operator works
PolarDB Stack is a Kubernetes operator for managing PolarDB database clusters, with shared-storage clusters as its primary documented model and local-storage support as a separate mode. Users create or modify an MPDCluster resource; reconciliation enters the appropriate state machine and workflow, which carries out lifecycle actions through application services and domain models. The product also exposes a REST API and periodically synchronizes shared-cluster status. The graph preserves documented lifecycle operations; unsampled workflow implementations are represented by their existing directories, and their internal call paths are not inferred.
Main entry points: shared_storage_cluster.go Shared cluster service · mpdcluster_controller.go Cluster reconciler · local_storage_cluster.go Local cluster service · shared Shared workflows
Components 21
Kubernetes control
- MPDCluster resource
apis/mpd/v1/mpdcluster_types.go - Cluster reconciler
pkg/controllers/mpd/mpdcluster_controller.go - REST API
pkg/bizapis/rest.go - Status sync monitor
pkg/business/monitor/shared_storage_cluster_status_sync_monitor.go
Lifecycle workflows
- State machines
pkg/wfimpl/statemachine_instance.go - Shared workflows
pkg/business/workflow/shared - Local workflows
pkg/business/workflow/local - Workflow managers
pkg/wfimpl/wf_manager_instance.go - Workflow step base
pkg/wfimpl/wf_step_base.go
Business services
- Shared cluster service
pkg/business/service/shared_storage_cluster.go - Local cluster service
pkg/business/service/local_storage_cluster.go - Shared cluster model
pkg/business/domain/shared_storage_cluster.go - Local cluster model
pkg/business/domain/local_storage_cluster.go
Runtime adapters
- Shared cluster repository
pkg/business/adapter/shared_storage_cluster_repository.go - Local cluster repository
pkg/business/adapter/local_storage_cluster_repository.go - Shared pod manager
pkg/business/adapter/shared_storage_pod_manager.go - Local pod manager
pkg/business/adapter/local_storage_pod_manager.go
Other components
- Cluster user
- Kubernetes API
- Cluster manager
- Shared storage
Connections 20
- Cluster user → MPDCluster resource: creates or modifies
- MPDCluster resource → Kubernetes API: stored in
- Kubernetes API → Cluster reconciler: triggers reconciliation
pkg/controllers/mpd/mpdcluster_controller.go - Cluster reconciler → State machines: enters state machine
pkg/controllers/mpd/mpdcluster_controller.go - Cluster reconciler → Workflow managers: checks recovery
pkg/controllers/mpd/mpdcluster_controller.go - Cluster reconciler → Shared workflows: selects shared mode
pkg/controllers/mpd/mpdcluster_controller.go - Cluster reconciler → Local workflows: selects local mode
pkg/controllers/mpd/mpdcluster_controller.go - Shared workflows → Workflow managers: creates workflow
pkg/business/workflow/shared/extend_storage.go - Shared workflows → Shared cluster service: grows storage
pkg/business/workflow/shared/extend_storage.go - Workflow step base → Shared cluster service: provides service
pkg/wfimpl/wf_step_base.go - Shared cluster service → Shared cluster model: operates on model
pkg/business/service/shared_storage_cluster.go - Local cluster service → Local cluster model: operates on model
pkg/business/service/local_storage_cluster.go - Shared cluster service → Shared cluster repository: updates cluster
pkg/business/service/shared_storage_cluster.go - Shared cluster service → Shared pod manager: creates pods
pkg/business/service/shared_storage_cluster.go - Local cluster service → Local cluster repository: persists cluster
- Local cluster service → Local pod manager: manages pods
- Shared cluster model → Cluster manager: manages instances
pkg/business/domain/shared_storage_cluster.go - Shared pod manager → Shared storage: mounts shared volumes
pkg/business/adapter/shared_storage_pod_manager.go - Status sync monitor → Shared cluster service: syncs cluster state
pkg/business/monitor/shared_storage_cluster_status_sync_monitor.go - Cluster user → REST API: requests operations