From 27eefd6ccd1aa66c7ff09c0035d47e95607ec01e Mon Sep 17 00:00:00 2001 From: hongzhouzi Date: Fri, 6 Jan 2023 16:25:18 +0800 Subject: [PATCH] feat: Gateway supports the configuration of forwarding tcp/udp traffic. Signed-off-by: hongzhouzi --- config/crds/gateway.kubesphere.io_gateways.yaml | 8 ++++++++ config/gateway/templates/nginx-ingress.yaml | 17 ++++++++++++++++- config/gateway/values.yaml | 3 +++ .../api/gateway/v1alpha1/gateway_types.go | 4 ++++ .../gateway/v1alpha1/zz_generated.deepcopy.go | 14 ++++++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/config/crds/gateway.kubesphere.io_gateways.yaml b/config/crds/gateway.kubesphere.io_gateways.yaml index 5178a25e88..1c47bf2975 100644 --- a/config/crds/gateway.kubesphere.io_gateways.yaml +++ b/config/crds/gateway.kubesphere.io_gateways.yaml @@ -56,6 +56,14 @@ spec: namespace: type: string type: object + tcp: + additionalProperties: + type: string + type: object + udp: + additionalProperties: + type: string + type: object type: object deployment: properties: diff --git a/config/gateway/templates/nginx-ingress.yaml b/config/gateway/templates/nginx-ingress.yaml index 3250c33944..344b207851 100644 --- a/config/gateway/templates/nginx-ingress.yaml +++ b/config/gateway/templates/nginx-ingress.yaml @@ -266,7 +266,22 @@ spec: imagePullSecrets: [] # - name: secretName - + # TCP service key:value pairs + # Ref: https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/exposing-tcp-udp-services.md + ## + {{- if .Values.controller.tcp }} + tcp: {{ toYaml .Values.controller.tcp | nindent 4 }} + {{- end }} + # 8080: "default/example-tcp-svc:9000" + + + # UDP service key:value pairs + # Ref: https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/exposing-tcp-udp-services.md + ## + {{- if .Values.controller.udp }} + udp: {{ toYaml .Values.controller.udp | nindent 4 }} + {{- end }} + # 53: "kube-system/kube-dns:53" diff --git a/config/gateway/values.yaml b/config/gateway/values.yaml index 9276a485e5..e14e067e14 100644 --- a/config/gateway/values.yaml +++ b/config/gateway/values.yaml @@ -15,6 +15,9 @@ controller: tag: "v1.1.0" pullPolicy: IfNotPresent digest: "" + # add configuration of forwarding tcp/udp traffic + tcp: {} + udp: {} service: diff --git a/staging/src/kubesphere.io/api/gateway/v1alpha1/gateway_types.go b/staging/src/kubesphere.io/api/gateway/v1alpha1/gateway_types.go index ca1687048c..f2ec1f6ec2 100644 --- a/staging/src/kubesphere.io/api/gateway/v1alpha1/gateway_types.go +++ b/staging/src/kubesphere.io/api/gateway/v1alpha1/gateway_types.go @@ -38,6 +38,10 @@ type ControllerSpec struct { Config map[string]string `json:"config,omitempty"` // +optional Scope Scope `json:"scope,omitempty"` + // +optional + TCP map[string]string `json:"tcp,omitempty"` + // +optional + UDP map[string]string `json:"udp,omitempty"` } type ServiceSpec struct { diff --git a/staging/src/kubesphere.io/api/gateway/v1alpha1/zz_generated.deepcopy.go b/staging/src/kubesphere.io/api/gateway/v1alpha1/zz_generated.deepcopy.go index 61bdcf2d32..a39ee316a6 100644 --- a/staging/src/kubesphere.io/api/gateway/v1alpha1/zz_generated.deepcopy.go +++ b/staging/src/kubesphere.io/api/gateway/v1alpha1/zz_generated.deepcopy.go @@ -48,6 +48,20 @@ func (in *ControllerSpec) DeepCopyInto(out *ControllerSpec) { } } out.Scope = in.Scope + if in.TCP != nil { + in, out := &in.TCP, &out.TCP + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.UDP != nil { + in, out := &in.UDP, &out.UDP + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerSpec.