Skip to content

Commit cd83660

Browse files
authored
Merge pull request #16 from numtide/multipooler-api-and-crd
2 parents fd03c3d + 9c890ef commit cd83660

File tree

3 files changed

+1935
-24
lines changed

3 files changed

+1935
-24
lines changed

api/v1alpha1/multipooler_types.go

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

1919
import (
20+
corev1 "k8s.io/api/core/v1"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
)
2223

23-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2424
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2525

26-
// MultiPoolerSpec defines the desired state of MultiPooler
26+
// MultiPoolerSpec defines the desired state of MultiPooler.
2727
type MultiPoolerSpec struct {
28-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29-
// Important: Run "make" to regenerate code after modifying this file
30-
// The following markers will use OpenAPI v3 schema to validate the value
31-
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
28+
// CellName is the name of the cell this MultiPooler belongs to.
29+
// +kubebuilder:validation:MinLength=1
30+
// +optional
31+
CellName string `json:"cellName,omitempty"`
32+
33+
// Replicas is the desired number of MultiPooler pods.
34+
// +kubebuilder:validation:Minimum=1
35+
// +kubebuilder:default=1
36+
// +optional
37+
Replicas *int32 `json:"replicas,omitempty"`
38+
39+
// MultiPooler defines the configuration for the multipooler container.
40+
// +optional
41+
MultiPooler MultiPoolerContainerSpec `json:"multiPooler,omitempty"`
42+
43+
// Pgctld defines the configuration for the pgctld container.
44+
// +optional
45+
Pgctld MultiPoolerContainerSpec `json:"pgctld,omitempty"`
46+
47+
// Postgres defines the configuration for the postgres container.
48+
// +optional
49+
Postgres MultiPoolerContainerSpec `json:"postgres,omitempty"`
50+
51+
// ImagePullSecrets is an optional list of references to secrets in the same namespace
52+
// to use for pulling images.
53+
// +optional
54+
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
55+
56+
// ServiceAccountName is the name of the ServiceAccount to use for the MultiPooler pods.
57+
// +optional
58+
ServiceAccountName string `json:"serviceAccountName,omitempty"`
59+
60+
// HTTPPort is the port for HTTP traffic.
61+
// +kubebuilder:validation:Minimum=1
62+
// +kubebuilder:validation:Maximum=65535
63+
// +kubebuilder:default=15200
64+
// +optional
65+
HTTPPort int32 `json:"httpPort,omitempty"`
66+
67+
// GRPCPort is the port for gRPC traffic.
68+
// +kubebuilder:validation:Minimum=1
69+
// +kubebuilder:validation:Maximum=65535
70+
// +kubebuilder:default=15270
71+
// +optional
72+
GRPCPort int32 `json:"grpcPort,omitempty"`
73+
74+
// PostgresPort is the port for PostgreSQL protocol traffic.
75+
// +kubebuilder:validation:Minimum=1
76+
// +kubebuilder:validation:Maximum=65535
77+
// +kubebuilder:default=5432
78+
// +optional
79+
PostgresPort int32 `json:"postgresPort,omitempty"`
80+
81+
// StorageClassName is the name of the StorageClass to use for PostgreSQL data volumes.
82+
// If not specified, the default StorageClass will be used.
83+
// +optional
84+
StorageClassName *string `json:"storageClassName,omitempty"`
85+
86+
// StorageSize is the size of the persistent volume for each MultiPooler pod.
87+
// +kubebuilder:default="10Gi"
88+
// +optional
89+
StorageSize string `json:"storageSize,omitempty"`
90+
91+
// VolumeClaimTemplate allows customization of the PersistentVolumeClaim for PostgreSQL data.
92+
// If specified, this takes precedence over StorageClassName and StorageSize.
93+
// +optional
94+
VolumeClaimTemplate *corev1.PersistentVolumeClaimSpec `json:"volumeClaimTemplate,omitempty"`
95+
96+
// Affinity defines pod affinity and anti-affinity rules.
97+
// +optional
98+
Affinity *corev1.Affinity `json:"affinity,omitempty"`
99+
100+
// Tolerations allows pods to schedule onto nodes with matching taints.
101+
// +optional
102+
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
103+
104+
// NodeSelector is a selector which must be true for the pod to fit on a node.
105+
// +optional
106+
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
107+
108+
// TopologySpreadConstraints controls how pods are spread across topology domains.
109+
// +optional
110+
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
32111

33-
// foo is an example field of MultiPooler. Edit multipooler_types.go to remove/update
112+
// PodAnnotations are annotations to add to the MultiPooler pods.
34113
// +optional
35-
Foo *string `json:"foo,omitempty"`
114+
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
115+
116+
// PodLabels are additional labels to add to the MultiPooler pods.
117+
// +optional
118+
PodLabels map[string]string `json:"podLabels,omitempty"`
36119
}
37120

38121
// MultiPoolerStatus defines the observed state of MultiPooler.
39122
type MultiPoolerStatus struct {
40-
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
41-
// Important: Run "make" to regenerate code after modifying this file
42-
43-
// For Kubernetes API conventions, see:
44-
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
45-
46-
// conditions represent the current state of the MultiPooler resource.
47-
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
48-
//
49-
// Standard condition types include:
50-
// - "Available": the resource is fully functional
51-
// - "Progressing": the resource is being created or updated
52-
// - "Degraded": the resource failed to reach or maintain its desired state
53-
//
54-
// The status of each condition is one of True, False, or Unknown.
123+
// Ready indicates whether the MultiPooler is healthy and available.
124+
Ready bool `json:"ready"`
125+
126+
// Replicas is the desired number of MultiPooler pods.
127+
Replicas int32 `json:"replicas"`
128+
129+
// ReadyReplicas is the number of ready MultiPooler pods.
130+
ReadyReplicas int32 `json:"readyReplicas"`
131+
132+
// ObservedGeneration reflects the generation of the most recently observed MultiPooler spec.
133+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
134+
135+
// Conditions represent the latest available observations of the MultiPooler's state.
55136
// +listType=map
56137
// +listMapKey=type
57138
// +optional
@@ -60,6 +141,10 @@ type MultiPoolerStatus struct {
60141

61142
// +kubebuilder:object:root=true
62143
// +kubebuilder:subresource:status
144+
// +kubebuilder:printcolumn:name="Cell",type=string,JSONPath=`.spec.cellName`
145+
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
146+
// +kubebuilder:printcolumn:name="Replicas",type=string,JSONPath=`.status.readyReplicas`
147+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
63148

64149
// MultiPooler is the Schema for the multipoolers API
65150
type MultiPooler struct {
@@ -87,6 +172,18 @@ type MultiPoolerList struct {
87172
Items []MultiPooler `json:"items"`
88173
}
89174

175+
// MultiPoolerContainerSpec defines the configuration for a container in a MultiPooler pod.
176+
type MultiPoolerContainerSpec struct {
177+
// Image is the container image.
178+
// +kubebuilder:validation:MinLength=1
179+
// +optional
180+
Image string `json:"image,omitempty"`
181+
182+
// Resources defines the resource requirements for this container.
183+
// +optional
184+
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
185+
}
186+
90187
func init() {
91188
SchemeBuilder.Register(&MultiPooler{}, &MultiPoolerList{})
92189
}

0 commit comments

Comments
 (0)