From 8c206a6456f38cbd785549646324c041670f8a25 Mon Sep 17 00:00:00 2001 From: teijin <12318075+teijinyer@users.noreply.github.com> Date: Mon, 7 Aug 2023 16:26:51 +0800 Subject: [PATCH] support configuration domain suffix (#460) (#463) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 澄潭 --- helm/core/templates/controller-deployment.yaml | 2 ++ pkg/ingress/kube/util/util.go | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/helm/core/templates/controller-deployment.yaml b/helm/core/templates/controller-deployment.yaml index 58369440..c12d8f57 100644 --- a/helm/core/templates/controller-deployment.yaml +++ b/helm/core/templates/controller-deployment.yaml @@ -202,6 +202,8 @@ spec: fieldRef: apiVersion: v1 fieldPath: spec.serviceAccountName + - name: DOMAIN_SUFFIX + value: {{ .Values.global.proxy.clusterDomain }} {{- if .Values.controller.env }} {{- range $key, $val := .Values.controller.env }} - name: {{ $key }} diff --git a/pkg/ingress/kube/util/util.go b/pkg/ingress/kube/util/util.go index ac1851f5..a0990d2e 100644 --- a/pkg/ingress/kube/util/util.go +++ b/pkg/ingress/kube/util/util.go @@ -22,6 +22,7 @@ import ( "fmt" "path" "strings" + "os" "github.com/gogo/protobuf/types" "github.com/golang/protobuf/jsonpb" @@ -30,6 +31,7 @@ import ( ) const DefaultDomainSuffix = "cluster.local" +var domainSuffix = os.Getenv("DOMAIN_SUFFIX") type ClusterNamespacedName struct { model.NamespacedName @@ -80,7 +82,10 @@ func MessageToGoGoStruct(msg proto.Message) (*types.Struct, error) { } func CreateServiceFQDN(namespace, name string) string { - return fmt.Sprintf("%s.%s.svc.%s", name, namespace, DefaultDomainSuffix) + if domainSuffix == "" { + domainSuffix = DefaultDomainSuffix + } + return fmt.Sprintf("%s.%s.svc.%s", name, namespace, domainSuffix) } func BuildPatchStruct(config string) *types.Struct {