Skip to content

Commit b8a4447

Browse files
author
chenzitian.czt
committed
feat: integrate obproxy
1 parent eb12248 commit b8a4447

27 files changed

Lines changed: 4401 additions & 659 deletions

api/v1alpha1/obproxy_types.go

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
Copyright 2023.
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+
apitypes "github.com/oceanbase/ob-operator/api/types"
21+
tasktypes "github.com/oceanbase/ob-operator/pkg/task/types"
22+
23+
corev1 "k8s.io/api/core/v1"
24+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25+
)
26+
27+
// OBClusterReference identifies an OBCluster resource that this OBProxy connects to.
28+
type OBClusterReference struct {
29+
// Namespace of the referenced OBCluster. Defaults to the namespace of the OBProxy resource.
30+
// +optional
31+
Namespace string `json:"namespace,omitempty"`
32+
// Name of the OBCluster resource.
33+
Name string `json:"name"`
34+
}
35+
36+
// OBProxySpec defines the desired state of OBProxy
37+
type OBProxySpec struct {
38+
// Reference to the target OBCluster.
39+
OBCluster OBClusterReference `json:"obCluster"`
40+
41+
// ProxyClusterName is the OBProxy cluster (application) name used inside OceanBase proxy.
42+
ProxyClusterName string `json:"proxyClusterName"`
43+
44+
// ProxySysSecret is the name of a Secret in the same namespace as this OBProxy that holds
45+
// the root@proxysys password. The Secret must contain a key named "password".
46+
ProxySysSecret string `json:"proxySysSecret"`
47+
48+
// Image is the OBProxy container image (e.g. oceanbase/obproxy-ce:tag).
49+
Image string `json:"image"`
50+
51+
// ServiceType is the Kubernetes Service type exposed for SQL access.
52+
// +kubebuilder:default=ClusterIP
53+
// +kubebuilder:validation:Enum=ClusterIP;NodePort;LoadBalancer;ExternalName
54+
ServiceType string `json:"serviceType,omitempty"`
55+
56+
// Replicas is the number of OBProxy pods.
57+
// +kubebuilder:default=1
58+
// +kubebuilder:validation:Minimum=1
59+
Replicas int32 `json:"replicas"`
60+
61+
// Resource limits and requests for each OBProxy pod.
62+
Resource *apitypes.ResourceSpec `json:"resource"`
63+
64+
// Parameters are optional OBProxy configuration key-value pairs (mapped to proxy startup config).
65+
// +optional
66+
Parameters []apitypes.Parameter `json:"parameters,omitempty"`
67+
68+
// ServiceAccount is the name of the ServiceAccount to use for OBProxy pods.
69+
// +kubebuilder:default=default
70+
// +optional
71+
ServiceAccount string `json:"serviceAccount,omitempty"`
72+
73+
// NodeSelector constrains OBProxy pods to nodes matching these labels.
74+
// +optional
75+
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
76+
77+
// Affinity defines scheduling affinity rules for OBProxy pods.
78+
// +optional
79+
Affinity *corev1.Affinity `json:"affinity,omitempty"`
80+
81+
// Tolerations allow OBProxy pods to be scheduled on tainted nodes.
82+
// +optional
83+
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
84+
}
85+
86+
// OBProxyStatus defines the observed state of OBProxy
87+
type OBProxyStatus struct {
88+
// High-level phase, e.g. Running, Pending, Failed.
89+
Status string `json:"status,omitempty"`
90+
91+
// Image is the container image currently running in the Deployment (observed).
92+
Image string `json:"image,omitempty"`
93+
94+
// Replicas is the replica count currently set in the Deployment (observed).
95+
Replicas int32 `json:"replicas,omitempty"`
96+
97+
// ReadyReplicas is the number of ready OBProxy pods (observed).
98+
ReadyReplicas int32 `json:"readyReplicas,omitempty"`
99+
100+
// RSList is the RS_LIST env value currently set in the Deployment (observed).
101+
// +optional
102+
RSList string `json:"rsList,omitempty"`
103+
104+
// RSListSource indicates how RSList was last resolved: "k8s" or "sql".
105+
// +optional
106+
RSListSource string `json:"rsListSource,omitempty"`
107+
108+
// ServiceIP is the ClusterIP of the managed Service (observed).
109+
// +optional
110+
ServiceIP string `json:"serviceIP,omitempty"`
111+
112+
// Conditions holds granular state for diagnostic purposes.
113+
// Known types: OBClusterAvailable, OBClusterReady, RSListAvailable.
114+
// +optional
115+
Conditions []metav1.Condition `json:"conditions,omitempty"`
116+
117+
// OperationContext carries long-running task progress when using the operator task flow.
118+
// +optional
119+
OperationContext *tasktypes.OperationContext `json:"operationContext,omitempty"`
120+
}
121+
122+
//+kubebuilder:object:root=true
123+
//+kubebuilder:subresource:status
124+
//+kubebuilder:resource:shortName=obp
125+
//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.status"
126+
//+kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".status.replicas"
127+
//+kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.readyReplicas"
128+
//+kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".spec.obCluster.name"
129+
//+kubebuilder:printcolumn:name="RSListSrc",type="string",JSONPath=".status.rsListSource"
130+
//+kubebuilder:printcolumn:name="ServiceIP",type="string",JSONPath=".status.serviceIP",priority=1
131+
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
132+
133+
// OBProxy is the Schema for the obproxies API
134+
type OBProxy struct {
135+
metav1.TypeMeta `json:",inline"`
136+
metav1.ObjectMeta `json:"metadata,omitempty"`
137+
138+
Spec OBProxySpec `json:"spec,omitempty"`
139+
Status OBProxyStatus `json:"status,omitempty"`
140+
}
141+
142+
//+kubebuilder:object:root=true
143+
144+
// OBProxyList contains a list of OBProxy
145+
type OBProxyList struct {
146+
metav1.TypeMeta `json:",inline"`
147+
metav1.ListMeta `json:"metadata,omitempty"`
148+
Items []OBProxy `json:"items"`
149+
}
150+
151+
func init() {
152+
SchemeBuilder.Register(&OBProxy{}, &OBProxyList{})
153+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 147 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/oceanbase-dashboard/templates/bundle.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
serviceAccountName: {{ .Release.Name }}-sa
2222
initContainers:
2323
- name: prometheus-storage-owner-init
24-
image: busybox:latest
24+
image: quay.io/oceanbase/oceanbase-dashboard:{{ .Chart.AppVersion }}
2525
imagePullPolicy: IfNotPresent
2626
command: ["sh", "-c", "chown -R 65534:65534 /prometheus"]
2727
volumeMounts:

cmd/operator/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ func main() {
239239
setupLog.Error(err, "unable to create controller", "controller", "OBClusterOperation")
240240
os.Exit(1)
241241
}
242+
if err = (&controller.OBProxyReconciler{
243+
Client: mgr.GetClient(),
244+
Scheme: mgr.GetScheme(),
245+
Recorder: telemetry.NewRecorder(ctx, mgr.GetEventRecorderFor(config.OBProxyControllerName)),
246+
}).SetupWithManager(mgr); err != nil {
247+
setupLog.Error(err, "Unable to create controller", "controller", "OBProxy")
248+
os.Exit(1)
249+
}
242250
if err = (&controller.K8sClusterReconciler{
243251
Client: mgr.GetClient(),
244252
Scheme: mgr.GetScheme(),

0 commit comments

Comments
 (0)