From a97e7dabaffef5c3873b34004e454ed5c061eb1a Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Thu, 4 Apr 2024 22:26:15 +0700 Subject: [PATCH] feat: adding support for UDP & TCP healthcheck --- api/v1alpha1/upstream_types.go | 23 ++- api/v1alpha1/zz_generated.deepcopy.go | 56 +++++++ charts/frp-operator/crds/crds.yaml | 34 +++- charts/releases/frp-operator-1.1.0.tgz | Bin 4451 -> 4524 bytes charts/releases/index.yaml | 8 +- .../frp.zufardhiyaulhaq.com_upstreams.yaml | 33 ++++ go.mod | 36 ++-- go.sum | 155 +++++------------- pkg/client/models/config.go | 35 +++- pkg/client/utils/template.go | 26 ++- 10 files changed, 256 insertions(+), 150 deletions(-) diff --git a/api/v1alpha1/upstream_types.go b/api/v1alpha1/upstream_types.go index 2bf0c74..d1ddfc4 100644 --- a/api/v1alpha1/upstream_types.go +++ b/api/v1alpha1/upstream_types.go @@ -24,24 +24,39 @@ import ( type UpstreamSpec struct { Client string `json:"client"` TCP *UpstreamSpec_TCP `json:"tcp"` + UDP *UpstreamSpec_UDP `json:"udp"` } type UpstreamSpec_TCP struct { - Name string `json:"name"` - Type string `json:"type"` - SubDomain string `json:"subdomain"` Host string `json:"host"` Port int `json:"port"` Server UpstreamSpec_TCP_Server `json:"server"` // +kubebuilder:validation:Enum=v1;v2 // +optional - ProxyProtocol *string `json:"proxyProtocol"` + ProxyProtocol *string `json:"proxyProtocol"` + HealthCheck *UpstreamSpec_TCP_HealthCheck `json:"healthCheck"` } type UpstreamSpec_TCP_Server struct { Port int `json:"port"` } +type UpstreamSpec_TCP_HealthCheck struct { + TimeoutSeconds int `json:"timeoutSeconds"` + MaxFailed int `json:"maxFailed"` + IntervalSeconds int `json:"intervalSeconds"` +} + +type UpstreamSpec_UDP struct { + Host string `json:"host"` + Port int `json:"port"` + Server UpstreamSpec_UDP_Server `json:"server"` +} + +type UpstreamSpec_UDP_Server struct { + Port int `json:"port"` +} + // UpstreamStatus defines the observed state of Upstream type UpstreamStatus struct { } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 5bcea15..8c8fae8 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -249,6 +249,11 @@ func (in *UpstreamSpec) DeepCopyInto(out *UpstreamSpec) { *out = new(UpstreamSpec_TCP) (*in).DeepCopyInto(*out) } + if in.UDP != nil { + in, out := &in.UDP, &out.UDP + *out = new(UpstreamSpec_UDP) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamSpec. @@ -270,6 +275,11 @@ func (in *UpstreamSpec_TCP) DeepCopyInto(out *UpstreamSpec_TCP) { *out = new(string) **out = **in } + if in.HealthCheck != nil { + in, out := &in.HealthCheck, &out.HealthCheck + *out = new(UpstreamSpec_TCP_HealthCheck) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamSpec_TCP. @@ -282,6 +292,21 @@ func (in *UpstreamSpec_TCP) DeepCopy() *UpstreamSpec_TCP { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *UpstreamSpec_TCP_HealthCheck) DeepCopyInto(out *UpstreamSpec_TCP_HealthCheck) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamSpec_TCP_HealthCheck. +func (in *UpstreamSpec_TCP_HealthCheck) DeepCopy() *UpstreamSpec_TCP_HealthCheck { + if in == nil { + return nil + } + out := new(UpstreamSpec_TCP_HealthCheck) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UpstreamSpec_TCP_Server) DeepCopyInto(out *UpstreamSpec_TCP_Server) { *out = *in @@ -297,6 +322,37 @@ func (in *UpstreamSpec_TCP_Server) DeepCopy() *UpstreamSpec_TCP_Server { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *UpstreamSpec_UDP) DeepCopyInto(out *UpstreamSpec_UDP) { + *out = *in + out.Server = in.Server +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamSpec_UDP. +func (in *UpstreamSpec_UDP) DeepCopy() *UpstreamSpec_UDP { + if in == nil { + return nil + } + out := new(UpstreamSpec_UDP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *UpstreamSpec_UDP_Server) DeepCopyInto(out *UpstreamSpec_UDP_Server) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamSpec_UDP_Server. +func (in *UpstreamSpec_UDP_Server) DeepCopy() *UpstreamSpec_UDP_Server { + if in == nil { + return nil + } + out := new(UpstreamSpec_UDP_Server) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UpstreamStatus) DeepCopyInto(out *UpstreamStatus) { *out = *in diff --git a/charts/frp-operator/crds/crds.yaml b/charts/frp-operator/crds/crds.yaml index 79055fb..12242eb 100644 --- a/charts/frp-operator/crds/crds.yaml +++ b/charts/frp-operator/crds/crds.yaml @@ -84,7 +84,6 @@ status: conditions: [] storedVersions: [] --- ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -125,6 +124,19 @@ spec: type: string tcp: properties: + healthCheck: + properties: + intervalSeconds: + type: integer + maxFailed: + type: integer + timeoutSeconds: + type: integer + required: + - intervalSeconds + - maxFailed + - timeoutSeconds + type: object host: type: string port: @@ -142,6 +154,25 @@ spec: - port type: object required: + - healthCheck + - host + - port + - server + type: object + udp: + properties: + host: + type: string + port: + type: integer + server: + properties: + port: + type: integer + required: + - port + type: object + required: - host - port - server @@ -149,6 +180,7 @@ spec: required: - client - tcp + - udp type: object status: description: UpstreamStatus defines the observed state of Upstream diff --git a/charts/releases/frp-oper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