Skip to content

Commit 446a4fc

Browse files
Changing API to match latest version of design document.
Changing API to match latest version of design document.
2 parents 631e64b + f8572cb commit 446a4fc

21 files changed

+16754
-5284
lines changed

api/v1alpha1/cell_types.go

Lines changed: 43 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -17,148 +17,78 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
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"
3036
type 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.
13483
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.
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
183104
type Cell struct {
184105
metav1.TypeMeta `json:",inline"`
185106
metav1.ObjectMeta `json:"metadata,omitempty"`

api/v1alpha1/celltemplate_types.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// ============================================================================
24+
// CellTemplateSpec Spec
25+
// ============================================================================
26+
27+
// CellTemplateSpec defines reusable config for Cell components (Gateway, LocalTopo).
28+
type CellTemplateSpec struct {
29+
// MultiGateway configuration.
30+
// +optional
31+
MultiGateway *StatelessSpec `json:"multigateway,omitempty"`
32+
33+
// LocalTopoServer configuration (optional).
34+
// +optional
35+
LocalTopoServer *LocalTopoServerSpec `json:"localTopoServer,omitempty"`
36+
}
37+
38+
// ============================================================================
39+
// Kind Definition and registration
40+
// ============================================================================
41+
42+
// +kubebuilder:object:root=true
43+
// +kubebuilder:resource:scope=Namespaced
44+
45+
// CellTemplate is the Schema for the celltemplates API
46+
type CellTemplate struct {
47+
metav1.TypeMeta `json:",inline"`
48+
metav1.ObjectMeta `json:"metadata,omitempty"`
49+
50+
Spec CellTemplateSpec `json:"spec,omitempty"`
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
55+
// CellTemplateList contains a list of CellTemplate
56+
type CellTemplateList struct {
57+
metav1.TypeMeta `json:",inline"`
58+
metav1.ListMeta `json:"metadata,omitempty"`
59+
Items []CellTemplate `json:"items"`
60+
}
61+
62+
func init() {
63+
SchemeBuilder.Register(&CellTemplate{}, &CellTemplateList{})
64+
}

api/v1alpha1/common_types.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
)
22+
23+
// ============================================================================
24+
// Shared Configuration Structs
25+
// ============================================================================
26+
//
27+
// These structs are used across multiple resources (Cluster, Templates, Children)
28+
// to ensure consistency in configuration shapes.
29+
30+
// StatelessSpec defines the desired state for a scalable, stateless component
31+
// like MultiAdmin, MultiOrch, or MultiGateway.
32+
type StatelessSpec struct {
33+
// Replicas is the desired number of pods.
34+
// +kubebuilder:validation:Minimum=0
35+
// +optional
36+
Replicas *int32 `json:"replicas,omitempty"`
37+
38+
// Resources defines the compute resource requirements.
39+
// +optional
40+
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
41+
42+
// Affinity defines the pod's scheduling constraints.
43+
// +optional
44+
Affinity *corev1.Affinity `json:"affinity,omitempty"`
45+
46+
// PodAnnotations are annotations to add to the pods.
47+
// +optional
48+
// +kubebuilder:validation:MaxProperties=64
49+
// +kubebuilder:validation:XValidation:rule="self.all(k, size(k) < 64 && size(self[k]) < 256)",message="annotation keys must be <64 chars and values <256 chars"
50+
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
51+
52+
// PodLabels are additional labels to add to the pods.
53+
// +optional
54+
// +kubebuilder:validation:MaxProperties=64
55+
// +kubebuilder:validation:XValidation:rule="self.all(k, size(k) < 64 && size(self[k]) < 64)",message="label keys and values must be <64 chars"
56+
PodLabels map[string]string `json:"podLabels,omitempty"`
57+
}
58+
59+
// StorageSpec defines the storage configuration.
60+
type StorageSpec struct {
61+
// Size of the persistent volume.
62+
// +kubebuilder:validation:Pattern="^([0-9]+)(.+)$"
63+
// +kubebuilder:validation:MaxLength=63
64+
// +optional
65+
Size string `json:"size,omitempty"`
66+
67+
// Class is the StorageClass name.
68+
// +optional
69+
// +kubebuilder:validation:MinLength=1
70+
// +kubebuilder:validation:MaxLength=63
71+
Class string `json:"class,omitempty"`
72+
}
73+
74+
// ContainerConfig defines generic container configuration.
75+
type ContainerConfig struct {
76+
// Resources defines the compute resource requirements.
77+
// +optional
78+
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
79+
}

0 commit comments

Comments
 (0)