Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion api/core/v1alpha1/tiproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ type TiProxyTemplateSpec struct {
Config ConfigFile `json:"config,omitempty"`
UpdateStrategy UpdateStrategy `json:"updateStrategy,omitempty"`

// ExternalPDClusters defines additional backend PD clusters that TiProxy
// should connect to besides the local cluster referenced by spec.cluster.
// Operator will manage these clusters through TiProxy's reloadable
// backend-clusters config and HTTP config API.
// +listType=map
// +listMapKey=name
// +kubebuilder:validation:MaxItems=64
ExternalPDClusters []TiProxyExternalPDCluster `json:"externalPDClusters,omitempty"`

Security *TiProxySecurity `json:"security,omitempty"`

// Volumes defines data volume of TiProxy, it is optional.
Expand All @@ -182,6 +191,24 @@ type TiProxyPreStop struct {
SleepSeconds int32 `json:"sleepSeconds,omitempty"`
}

type TiProxyExternalPDCluster struct {
// Name identifies the backend PD cluster inside TiProxy.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
Name string `json:"name"`

// PDAddrs is a comma separated address list of PD servers, for example:
// "pd-0.example.com:2379,pd-1.example.com:2379".
// +kubebuilder:validation:MinLength=1
PDAddrs string `json:"pdAddrs"`

// NSServers defines the DNS servers TiProxy should use when resolving the
// backend cluster endpoints.
// +listType=set
// +kubebuilder:validation:MaxItems=16
NSServers []string `json:"nsServers,omitempty"`
}

type TiProxySecurity struct {
// Whether enable the TLS connection.
TLS *TiProxyTLSConfig `json:"tls,omitempty"`
Expand All @@ -205,13 +232,37 @@ type TiProxyServer struct {

type TiProxyPorts struct {
// Client defines port for TiProxy's SQL service.
Client *Port `json:"client,omitempty"`
Client *TiProxyPortOrRange `json:"client,omitempty"`
// API defines port for TiProxy API service.
API *Port `json:"api,omitempty"`
// Peer defines port for TiProxy's peer service.
Peer *Port `json:"peer,omitempty"`
}

// TiProxyPortOrRange defines the main SQL port and optional extra listening range.
// The operator continues to use Port for Pod probes and the internal Service.
// Range is only propagated to TiProxy's proxy.port-range config.
// +kubebuilder:validation:XValidation:rule="!has(self.range) || self.range.start <= self.range.end",message="range.start must be less than or equal to range.end"
type TiProxyPortOrRange struct {
// Port defines the main SQL port exposed by the TiProxy Pod and Service.
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
Port *int32 `json:"port,omitempty"`

// Range defines additional SQL ports listened by TiProxy itself.
Range *TiProxyPortRange `json:"range,omitempty"`
}

type TiProxyPortRange struct {
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
Start int32 `json:"start"`

// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
End int32 `json:"end"`
}

type TiProxyProbes struct {
// Readiness defines the readiness probe for TiProxy.
// The default handler is a TCP socket on the client port.
Expand Down
74 changes: 72 additions & 2 deletions api/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 62 additions & 2 deletions manifests/crd/core.pingcap.com_tiproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,43 @@ spec:
config:
description: Config defines config file of TiProxy.
type: string
externalPDClusters:
description: |-
ExternalPDClusters defines additional backend PD clusters that TiProxy
should connect to besides the local cluster referenced by spec.cluster.
Operator will manage these clusters through TiProxy's reloadable
backend-clusters config and HTTP config API.
items:
properties:
name:
description: Name identifies the backend PD cluster inside TiProxy.
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
nsServers:
description: |-
NSServers defines the DNS servers TiProxy should use when resolving the
backend cluster endpoints.
items:
type: string
maxItems: 16
type: array
x-kubernetes-list-type: set
pdAddrs:
description: |-
PDAddrs is a comma separated address list of PD servers, for example:
"pd-0.example.com:2379,pd-1.example.com:2379".
minLength: 1
type: string
required:
- name
- pdAddrs
type: object
maxItems: 64
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
features:
description: Features are enabled feature
items:
Expand Down Expand Up @@ -8538,11 +8575,34 @@ spec:
description: Client defines port for TiProxy's SQL service.
properties:
port:
description: Port defines the main SQL port exposed by
the TiProxy Pod and Service.
format: int32
maximum: 65535
minimum: 1
type: integer
required:
- port
range:
description: Range defines additional SQL ports listened
by TiProxy itself.
properties:
end:
format: int32
maximum: 65535
minimum: 1
type: integer
start:
format: int32
maximum: 65535
minimum: 1
type: integer
required:
- end
- start
type: object
type: object
x-kubernetes-validations:
- message: range.start must be less than or equal to range.end
rule: '!has(self.range) || self.range.start <= self.range.end'
peer:
description: Peer defines port for TiProxy's peer service.
properties:
Expand Down
66 changes: 64 additions & 2 deletions manifests/crd/core.pingcap.com_tiproxygroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,44 @@ spec:
config:
description: Config defines config file of TiProxy.
type: string
externalPDClusters:
description: |-
ExternalPDClusters defines additional backend PD clusters that TiProxy
should connect to besides the local cluster referenced by spec.cluster.
Operator will manage these clusters through TiProxy's reloadable
backend-clusters config and HTTP config API.
items:
properties:
name:
description: Name identifies the backend PD cluster
inside TiProxy.
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
nsServers:
description: |-
NSServers defines the DNS servers TiProxy should use when resolving the
backend cluster endpoints.
items:
type: string
maxItems: 16
type: array
x-kubernetes-list-type: set
pdAddrs:
description: |-
PDAddrs is a comma separated address list of PD servers, for example:
"pd-0.example.com:2379,pd-1.example.com:2379".
minLength: 1
type: string
required:
- name
- pdAddrs
type: object
maxItems: 64
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
image:
description: |-
Image is TiProxy's image
Expand Down Expand Up @@ -8836,11 +8874,35 @@ spec:
service.
properties:
port:
description: Port defines the main SQL port exposed
by the TiProxy Pod and Service.
format: int32
maximum: 65535
minimum: 1
type: integer
required:
- port
range:
description: Range defines additional SQL ports
listened by TiProxy itself.
properties:
end:
format: int32
maximum: 65535
minimum: 1
type: integer
start:
format: int32
maximum: 65535
minimum: 1
type: integer
required:
- end
- start
type: object
type: object
x-kubernetes-validations:
- message: range.start must be less than or equal
to range.end
rule: '!has(self.range) || self.range.start <= self.range.end'
peer:
description: Peer defines port for TiProxy's peer
service.
Expand Down
18 changes: 16 additions & 2 deletions pkg/apiutil/core/v1alpha1/tiproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (

func TiProxyGroupClientPort(proxyg *v1alpha1.TiProxyGroup) int32 {
if proxyg.Spec.Template.Spec.Server.Ports.Client != nil {
return proxyg.Spec.Template.Spec.Server.Ports.Client.Port
if proxyg.Spec.Template.Spec.Server.Ports.Client.Port != nil {
return *proxyg.Spec.Template.Spec.Server.Ports.Client.Port
}
}
return v1alpha1.DefaultTiProxyPortClient
}
Expand All @@ -44,11 +46,23 @@ func TiProxyGroupPeerPort(proxyg *v1alpha1.TiProxyGroup) int32 {

func TiProxyClientPort(tiproxy *v1alpha1.TiProxy) int32 {
if tiproxy.Spec.Server.Ports.Client != nil {
return tiproxy.Spec.Server.Ports.Client.Port
if tiproxy.Spec.Server.Ports.Client.Port != nil {
return *tiproxy.Spec.Server.Ports.Client.Port
}
}
return v1alpha1.DefaultTiProxyPortClient
}

func TiProxyClientPortRange(tiproxy *v1alpha1.TiProxy) []int {
if tiproxy.Spec.Server.Ports.Client == nil || tiproxy.Spec.Server.Ports.Client.Range == nil {
return nil
}
return []int{
int(tiproxy.Spec.Server.Ports.Client.Range.Start),
int(tiproxy.Spec.Server.Ports.Client.Range.End),
}
}

func TiProxyAPIPort(tiproxy *v1alpha1.TiProxy) int32 {
if tiproxy.Spec.Server.Ports.API != nil {
return tiproxy.Spec.Server.Ports.API.Port
Expand Down
Loading
Loading