Skip to content

Commit

Permalink
refactor: add frontend ports
Browse files Browse the repository at this point in the history
  • Loading branch information
zyy17 committed Sep 29, 2024
1 parent 7f63235 commit 5f48e35
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 35 deletions.
6 changes: 5 additions & 1 deletion apis/v1alpha1/defaulting.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (in *GreptimeDBCluster) defaultFrontend() *FrontendSpec {
Template: &PodTemplateSpec{},
Replicas: pointer.Int32(DefaultReplicas),
},
RPCPort: DefaultRPCPort,
HTTPPort: DefaultHTTPPort,
MySQLPort: DefaultMySQLPort,
PostgreSQLPort: DefaultPostgreSQLPort,
Service: &ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
},
Expand Down Expand Up @@ -159,7 +163,7 @@ func (in *GreptimeDBCluster) mergeFrontendTemplate() error {
}

// Reconfigure the probe settings based on the HTTP port.
in.Spec.Frontend.Template.MainContainer.LivenessProbe.HTTPGet.Port = intstr.FromInt32(in.Spec.HTTPPort)
in.Spec.Frontend.Template.MainContainer.LivenessProbe.HTTPGet.Port = intstr.FromInt32(in.Spec.Frontend.HTTPPort)
}

return nil
Expand Down
42 changes: 42 additions & 0 deletions apis/v1alpha1/greptimedbcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ type MetaSpec struct {
ComponentSpec `json:",inline"`

// RPCPort is the gRPC port of the meta.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
RPCPort int32 `json:"rpcPort,omitempty"`

// HTTPPort is the HTTP port of the meta.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
HTTPPort int32 `json:"httpPort,omitempty"`

Expand Down Expand Up @@ -107,6 +111,30 @@ func (in *MetaSpec) IsEnableCheckEtcdService() bool {
type FrontendSpec struct {
ComponentSpec `json:",inline"`

// RPCPort is the gRPC port of the frontend.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
RPCPort int32 `json:"rpcPort,omitempty"`

// HTTPPort is the HTTP port of the frontend.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
HTTPPort int32 `json:"httpPort,omitempty"`

// MySQLPort is the MySQL port of the frontend.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
MySQLPort int32 `json:"mysqlPort,omitempty"`

// PostgreSQLPort is the PostgreSQL port of the frontend.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
PostgreSQLPort int32 `json:"postgreSQLPort,omitempty"`

// Service is the service configuration of the frontend.
// +optional
Service *ServiceSpec `json:"service,omitempty"`
Expand Down Expand Up @@ -149,10 +177,14 @@ type DatanodeSpec struct {
ComponentSpec `json:",inline"`

// RPCPort is the gRPC port of the datanode.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
RPCPort int32 `json:"rpcPort,omitempty"`

// HTTPPort is the HTTP port of the datanode.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
HTTPPort int32 `json:"httpPort,omitempty"`

Expand Down Expand Up @@ -194,6 +226,8 @@ type FlownodeSpec struct {
ComponentSpec `json:",inline"`

// The gRPC port of the flownode.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
RPCPort int32 `json:"rpcPort,omitempty"`
}
Expand Down Expand Up @@ -242,18 +276,26 @@ type GreptimeDBClusterSpec struct {
Flownode *FlownodeSpec `json:"flownode,omitempty"`

// HTTPPort is the HTTP port of the greptimedb cluster.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
HTTPPort int32 `json:"httpPort,omitempty"`

// RPCPort is the RPC port of the greptimedb cluster.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
RPCPort int32 `json:"rpcPort,omitempty"`

// MySQLPort is the MySQL port of the greptimedb cluster.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
MySQLPort int32 `json:"mysqlPort,omitempty"`

// PostgreSQLPort is the PostgreSQL port of the greptimedb cluster.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
PostgreSQLPort int32 `json:"postgreSQLPort,omitempty"`

Expand Down
8 changes: 8 additions & 0 deletions apis/v1alpha1/greptimedbstandalone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,26 @@ type GreptimeDBStandaloneSpec struct {
TLS *TLSSpec `json:"tls,omitempty"`

// HTTPPort is the port of the greptimedb http service.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
HTTPPort int32 `json:"httpPort,omitempty"`

// RPCPort is the port of the greptimedb rpc service.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
RPCPort int32 `json:"rpcPort,omitempty"`

// MySQLPort is the port of the greptimedb mysql service.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
MySQLPort int32 `json:"mysqlPort,omitempty"`

// PostgreSQLPort is the port of the greptimedb postgresql service.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +optional
PostgreSQLPort int32 `json:"postgreSQLPort,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ spec:
port: 4000
frontend:
replicas: 1
httpPort: 4000
mysqlPort: 4002
postgreSQLPort: 4003
rpcPort: 4001
service:
type: ClusterIP
template:
Expand All @@ -34,7 +38,7 @@ spec:
livenessProbe:
httpGet:
path: /health
port: 5000
port: 4000
meta:
etcdEndpoints:
- etcd.etcd-cluster.svc.cluster.local:2379
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ spec:
memory: "1Gi"
frontend:
replicas: 1
httpPort: 4000
mysqlPort: 4002
postgreSQLPort: 4003
rpcPort: 4001
service:
type: ClusterIP
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ spec:
port: 4000
frontend:
replicas: 1
httpPort: 4000
mysqlPort: 4002
postgreSQLPort: 4003
rpcPort: 4001
service:
type: ClusterIP
template:
Expand Down
38 changes: 38 additions & 0 deletions config/crd/resources/greptime.io_greptimedbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2818,6 +2818,8 @@ spec:
type: string
httpPort:
format: int32
maximum: 65535
minimum: 0
type: integer
logging:
properties:
Expand Down Expand Up @@ -2846,6 +2848,8 @@ spec:
type: integer
rpcPort:
format: int32
maximum: 65535
minimum: 0
type: integer
storage:
properties:
Expand Down Expand Up @@ -5663,6 +5667,8 @@ spec:
type: integer
rpcPort:
format: int32
maximum: 65535
minimum: 0
type: integer
template:
properties:
Expand Down Expand Up @@ -8431,6 +8437,11 @@ spec:
properties:
config:
type: string
httpPort:
format: int32
maximum: 65535
minimum: 0
type: integer
logging:
properties:
format:
Expand All @@ -8452,10 +8463,25 @@ spec:
persistentWithData:
type: boolean
type: object
mysqlPort:
format: int32
maximum: 65535
minimum: 0
type: integer
postgreSQLPort:
format: int32
maximum: 65535
minimum: 0
type: integer
replicas:
format: int32
minimum: 0
type: integer
rpcPort:
format: int32
maximum: 65535
minimum: 0
type: integer
service:
properties:
annotations:
Expand Down Expand Up @@ -11243,6 +11269,8 @@ spec:
type: object
httpPort:
format: int32
maximum: 65535
minimum: 0
type: integer
initializer:
properties:
Expand Down Expand Up @@ -11284,6 +11312,8 @@ spec:
type: array
httpPort:
format: int32
maximum: 65535
minimum: 0
type: integer
logging:
properties:
Expand Down Expand Up @@ -11312,6 +11342,8 @@ spec:
type: integer
rpcPort:
format: int32
maximum: 65535
minimum: 0
type: integer
storeKeyPrefix:
type: string
Expand Down Expand Up @@ -14082,6 +14114,8 @@ spec:
type: object
mysqlPort:
format: int32
maximum: 65535
minimum: 0
type: integer
objectStorage:
properties:
Expand Down Expand Up @@ -14160,6 +14194,8 @@ spec:
type: object
postgreSQLPort:
format: int32
maximum: 65535
minimum: 0
type: integer
prometheusMonitor:
properties:
Expand All @@ -14176,6 +14212,8 @@ spec:
type: object
rpcPort:
format: int32
maximum: 65535
minimum: 0
type: integer
version:
type: string
Expand Down
8 changes: 8 additions & 0 deletions config/crd/resources/greptime.io_greptimedbstandalones.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,8 @@ spec:
type: object
httpPort:
format: int32
maximum: 65535
minimum: 0
type: integer
initializer:
properties:
Expand Down Expand Up @@ -2855,6 +2857,8 @@ spec:
type: object
mysqlPort:
format: int32
maximum: 65535
minimum: 0
type: integer
objectStorage:
properties:
Expand Down Expand Up @@ -2933,6 +2937,8 @@ spec:
type: object
postgreSQLPort:
format: int32
maximum: 65535
minimum: 0
type: integer
prometheusMonitor:
properties:
Expand All @@ -2949,6 +2955,8 @@ spec:
type: object
rpcPort:
format: int32
maximum: 65535
minimum: 0
type: integer
service:
properties:
Expand Down
Loading

0 comments on commit 5f48e35

Please sign in to comment.