Skip to content

Commit fe414ef

Browse files
authored
Merge pull request #61 from numtide/child-crs-with-existing-items-intact
Add child CRs for Multigres resources
2 parents 1c724f1 + 8235089 commit fe414ef

File tree

10 files changed

+8785
-250
lines changed

10 files changed

+8785
-250
lines changed

api/v1alpha1/cell_types.go

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// ============================================================================
25+
// Cell Spec (Read-only API)
26+
// ============================================================================
27+
28+
// CellSpec defines the desired state of Cell
29+
// This spec is populated by the MultigresCluster controller.
30+
type CellSpec struct {
31+
// 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])?$"
35+
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"`
69+
// +optional
70+
// +kubebuilder:validation:MinLength=1
71+
MultiOrch string `json:"multiorch,omitempty"`
72+
}
73+
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"`
81+
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+
}
90+
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"`
96+
97+
// ClientServiceName is the name of the etcd client service.
98+
// +kubebuilder:validation:MinLength=1
99+
// +optional
100+
ClientServiceName string `json:"clientServiceName,omitempty"`
101+
}
102+
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+
// +kubebuilder:validation:XValidation:rule="(has(self.external) ? 1 : 0) + (has(self.managedSpec) ? 1 : 0) <= 1",message="only one of 'external' or 'managedSpec' can be set for topoServer"
107+
type CellTopoServerSpec struct {
108+
// External defines connection details for an unmanaged, external topo server.
109+
// +optional
110+
// External *ExternalTopoServerSpec `json:"external,omitempty"`
111+
112+
// ManagedSpec defines the spec for a managed, cell-local topo server.
113+
// If set, the Cell controller will create a child TopoServer CR.
114+
// +optional
115+
ManagedSpec *TopoServerSpec `json:"managedSpec,omitempty"`
116+
}
117+
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"`
127+
}
128+
129+
// ============================================================================
130+
// CR Controller Status Specs
131+
// ============================================================================
132+
133+
// CellStatus defines the observed state of Cell
134+
type 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.
140+
// +optional
141+
Conditions []metav1.Condition `json:"conditions,omitempty"`
142+
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
153+
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"`
162+
}
163+
164+
// ============================================================================
165+
// Kind Definition and registration
166+
// ============================================================================
167+
168+
// +kubebuilder:object:root=true
169+
// +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+
177+
// Cell is the Schema for the Cells API
178+
type Cell struct {
179+
metav1.TypeMeta `json:",inline"`
180+
metav1.ObjectMeta `json:"metadata,omitempty"`
181+
182+
Spec CellSpec `json:"spec,omitempty"`
183+
Status CellStatus `json:"status,omitempty"`
184+
}
185+
186+
// +kubebuilder:object:root=true
187+
188+
// CellList contains a list of Cell
189+
type CellList struct {
190+
metav1.TypeMeta `json:",inline"`
191+
metav1.ListMeta `json:"metadata,omitempty"`
192+
Items []Cell `json:"items"`
193+
}
194+
195+
func init() {
196+
SchemeBuilder.Register(&Cell{}, &CellList{})
197+
}

api/v1alpha1/multipooler_types.go

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)