@@ -17,148 +17,78 @@ limitations under the License.
1717package v1alpha1
1818
1919import (
20- corev1 "k8s.io/api/core/v1"
2120 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2221)
2322
2423// ============================================================================
2524// Cell Spec (Read-only API)
2625// ============================================================================
26+ //
27+ // Cell is a child CR managed by MultigresCluster.
2728
28- // CellSpec defines the desired state of Cell
29- // This spec is populated by the MultigresCluster controller.
29+ // CellName is a string restricted to 63 characters for strict validation budgeting.
30+ // +kubebuilder:validation:MinLength=1
31+ // +kubebuilder:validation:MaxLength=63
32+ type CellName string
33+
34+ // CellSpec defines the desired state of Cell.
35+ // +kubebuilder:validation:XValidation:rule="has(self.zone) != has(self.region)",message="must specify either 'zone' or 'region', but not both"
3036type CellSpec struct {
3137 // Name is the logical name of the cell.
32- // +kubebuilder:validation:MinLength:=1
33- // +kubebuilder:validation:MaxLength:=63
34- // +kubebuilder:validation:Pattern:="^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
38+ // +kubebuilder:validation:MaxLength=63
3539 Name string `json:"name"`
36-
37- // Images required for this cell's components.
38- // +optional
39- Images CellImagesSpec `json:"images,omitempty"`
40-
41- // MultiGateway defines the desired state of the MultiGateway deployment.
42- MultiGateway StatelessSpec `json:"multigateway"`
43-
44- // MultiOrch defines the desired state of the MultiOrch deployment.
45- MultiOrch StatelessSpec `json:"multiorch"`
46-
47- // GlobalTopoServer is a reference to the cluster-wide global topo server.
48- // This is always populated by the parent controller.
49- GlobalTopoServer GlobalTopoServerRefSpec `json:"globalTopoServer"`
50-
51- // TopoServer defines the topology server configuration for this cell.
52- // If this is empty, the cell defaults to using the GlobalTopoServer.
53- TopoServer CellTopoServerSpec `json:"topoServer"`
54-
55- // AllCells is a list of all cell names in the cluster for discovery.
56- // +optional
57- AllCells []string `json:"allCells,omitempty"`
58-
59- // TopologyReconciliation defines flags for the cell controller's reconciliation logic.
60- // +optional
61- TopologyReconciliation TopologyReconciliationSpec `json:"topologyReconciliation,omitempty"`
62- }
63-
64- // CellImagesSpec defines the images required for a Cell.
65- type CellImagesSpec struct {
66- // +optional
67- // +kubebuilder:validation:MinLength=1
68- MultiGateway string `json:"multigateway,omitempty"`
40+ // Zone indicates the physical availability zone.
41+ // +kubebuilder:validation:MaxLength=63
42+ Zone string `json:"zone,omitempty"`
43+ // Region indicates the physical region.
6944 // +optional
70- // +kubebuilder:validation:MinLength=1
71- MultiOrch string `json:"multiorch,omitempty"`
72- }
45+ // +kubebuilder:validation:MaxLength=63
46+ Region string `json:"region,omitempty"`
7347
74- // StatelessSpec defines the desired state for a scalable, stateless component
75- // like MultiAdmin, MultiOrch, or MultiGateway.
76- type StatelessSpec struct {
77- // Replicas is the desired number of pods.
78- // +kubebuilder:validation:Minimum=0
79- // +optional
80- Replicas * int32 `json:"replicas,omitempty"`
48+ // MultiGatewayImage is the image used for the gateway in this cell.
49+ // +kubebuilder:validation:MaxLength=512
50+ MultiGatewayImage string `json:"multigatewayImage"`
8151
82- // Affinity defines the pod's scheduling constraints.
83- // +optional
84- Affinity * corev1.Affinity `json:"affinity,omitempty"`
85-
86- // Resources defines the compute resource requirements.
87- // +optional
88- corev1.ResourceRequirements `json:"resources,omitempty"`
89- }
52+ // MultiGateway fully resolved config.
53+ MultiGateway StatelessSpec `json:"multigateway"`
9054
91- // GlobalTopoServerRefSpec defines a reference to the global topo server.
92- type GlobalTopoServerRefSpec struct {
93- // RootPath is the root path being used in the global topo server.
94- // +optional
95- RootPath string `json:"rootPath,omitempty"`
55+ // GlobalTopoServer reference (always populated).
56+ GlobalTopoServer GlobalTopoServerRef `json:"globalTopoServer"`
9657
97- // ClientServiceName is the name of the etcd client service.
98- // +kubebuilder:validation:MinLength=1
58+ // TopoServer defines the local topology config.
9959 // +optional
100- ClientServiceName string `json:"clientServiceName,omitempty"`
101- }
60+ TopoServer LocalTopoServerSpec `json:"topoServer,omitempty"`
10261
103- // CellTopoServerSpec defines the topology server configuration for this cell.
104- // Only one of External or ManagedSpec should be set.
105- // If neither is set, the cell uses the top-level GlobalTopoServer.
106- // TODO: Add validation when External field is uncommented
107- type CellTopoServerSpec struct {
108- // External defines connection details for an unmanaged, external topo server.
62+ // AllCells list for discovery.
10963 // +optional
110- // External *ExternalTopoServerSpec `json:"external,omitempty"`
64+ // +kubebuilder:validation:MaxItems=100
65+ AllCells []CellName `json:"allCells,omitempty"`
11166
112- // ManagedSpec defines the spec for a managed, cell-local topo server.
113- // If set, the Cell controller will create a child TopoServer CR.
67+ // TopologyReconciliation flags.
11468 // +optional
115- ManagedSpec * TopoServerSpec `json:"managedSpec ,omitempty"`
69+ TopologyReconciliation TopologyReconciliation `json:"topologyReconciliation ,omitempty"`
11670}
11771
118- // TopologyReconciliationSpec defines flags for the cell controller.
119- type TopologyReconciliationSpec struct {
120- // RegisterCell instructs the controller to register this cell in the topology.
121- // +optional
122- RegisterCell bool `json:"registerCell,omitempty"`
123-
124- // PruneTablets instructs the controller to prune old tablets from the topology.
125- // +optional
126- PruneTablets bool `json:"pruneTablets,omitempty"`
72+ // TopologyReconciliation defines flags for the cell controller.
73+ type TopologyReconciliation struct {
74+ RegisterCell bool `json:"registerCell"`
75+ PrunePoolers bool `json:"prunePoolers"`
12776}
12877
12978// ============================================================================
13079// CR Controller Status Specs
13180// ============================================================================
13281
133- // CellStatus defines the observed state of Cell
82+ // CellStatus defines the observed state of Cell.
13483type CellStatus struct {
135- // ObservedGeneration is the most recent generation observed by the controller.
136- // +optional
137- ObservedGeneration int64 `json:"observedGeneration,omitempty"`
138-
139- // Conditions represent the latest available observations of the Cell's state.
84+ // Conditions represent the latest available observations.
14085 // +optional
14186 Conditions []metav1.Condition `json:"conditions,omitempty"`
14287
143- // GatewayReplicas is the current number of MultiGateway pods.
144- // +optional
145- GatewayReplicas int32 `json:"gatewayReplicas,omitempty"`
146-
147- // GatewayReadyReplicas is the number of MultiGateway pods ready to serve requests.
148- // +optional
149- GatewayReadyReplicas int32 `json:"gatewayReadyReplicas,omitempty"`
150-
151- // GatewayServiceName is the name of the MultiGateway service.
152- // +optional
88+ GatewayReplicas int32 `json:"gatewayReplicas"`
89+ GatewayReadyReplicas int32 `json:"gatewayReadyReplicas"`
90+ // +kubebuilder:validation:MaxLength=253
15391 GatewayServiceName string `json:"gatewayServiceName,omitempty"`
154-
155- // MultiOrchAvailable indicates whether the MultiOrch deployment is available.
156- // +optional
157- MultiOrchAvailable metav1.ConditionStatus `json:"multiorchAvailable,omitempty"`
158-
159- // TopoServerAvailable indicates whether the cell's topo server (local or global) is available.
160- // +optional
161- TopoServerAvailable metav1.ConditionStatus `json:"topoServerAvailable,omitempty"`
16292}
16393
16494// ============================================================================
@@ -167,19 +97,10 @@ type CellStatus struct {
16797
16898// +kubebuilder:object:root=true
16999// +kubebuilder:subresource:status
170- // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type=='Available')].status",description="Current availability status"
171- // +kubebuilder:printcolumn:name="Gateway Ready",type="string",JSONPath=".status.gatewayReadyReplicas",description="Gateway ready replicas"
172- // +kubebuilder:printcolumn:name="Gateway Total",type="string",JSONPath=".status.gatewayReplicas",description="Gateway total replicas"
173- // +kubebuilder:printcolumn:name="Orch Ready",type="string",JSONPath=".status.multiorchAvailable",description="Orchestrator status"
174- // +kubebuilder:printcolumn:name="Topo Ready",type="string",JSONPath=".status.topoServerAvailable",description="Topo server status"
175- // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
176- // +kubebuilder:rbac:groups=multigres.com,resources=cells,verbs=get;list;watch;create;update;patch;delete
177- // +kubebuilder:rbac:groups=multigres.com,resources=cells/status,verbs=get;update;patch
178- // +kubebuilder:rbac:groups=multigres.com,resources=cells/finalizers,verbs=update
179- // +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
180- // +kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;update;patch;delete
181-
182- // Cell is the Schema for the Cells API
100+ // +kubebuilder:printcolumn:name="Gateway",type="integer",JSONPath=".status.gatewayReadyReplicas"
101+ // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Available')].status"
102+
103+ // Cell is the Schema for the cells API
183104type Cell struct {
184105 metav1.TypeMeta `json:",inline"`
185106 metav1.ObjectMeta `json:"metadata,omitempty"`
0 commit comments