Skip to content

Commit

Permalink
[BugFix] support to run fe-proxy under customize cluster domain inste…
Browse files Browse the repository at this point in the history
…ad of using default one: cluster.local

Signed-off-by: yandongxiao <yandongxiao@starrocks.com>
  • Loading branch information
yandongxiao committed Nov 27, 2024
1 parent 4da71d9 commit a8501db
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
9 changes: 9 additions & 0 deletions cmd/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package config

import "fmt"

var DNSDomainSuffix string

func GetServiceDomainSuffix() string {
return fmt.Sprintf("svc.%s", DNSDomainSuffix)
}
4 changes: 3 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

"github.com/StarRocks/starrocks-kubernetes-operator/cmd/config"

Check failure on line 28 in cmd/main.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/StarRocks/starrocks-kubernetes-operator/pkg (goimports)
srapi "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1"
"github.com/StarRocks/starrocks-kubernetes-operator/pkg/controllers"
"github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils"
Expand All @@ -45,6 +46,7 @@ func main() {
"Enabling this will ensure there is only one active controller manager.")
flag.StringVar(&_namespace, "namespace", "", "if specified, "+
"restricts the manager's cache to watch objects in the desired namespace. Defaults to all namespaces.")
flag.StringVar(&config.DNSDomainSuffix, "dns-domain-suffix", "cluster.local", "The suffix of the dns domain in k8s")

// Set up logger.
opts := zap.Options{}
Expand Down Expand Up @@ -83,7 +85,7 @@ func main() {
os.Exit(1)
}

//+kubebuilder:scaffold:builder
// +kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
logger.Error(err, "unable to set up health check")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ spec:
{{- if .Values.starrocksOperator.watchNamespace }}
- --namespace={{ .Values.starrocksOperator.watchNamespace }}
{{- end }}
{{- if .Values.starrocksOperator.dnsDomainSuffix }}
- --dns-domain-suffix={{ .Values.starrocksOperator.dnsDomainSuffix }}
{{- end }}
env:
- name: TZ
value: {{ .Values.timeZone }}
Expand Down
4 changes: 4 additions & 0 deletions helm-charts/charts/kube-starrocks/charts/operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ starrocksOperator:
- --zap-encoder=console
# if you want open debug log, open this option
# - --zap-log-level 4
# Operator need to specify the FQDN in nginx.conf when it set up fe-proxy service.
# By default, Operator will use cluster.local as the dnsDomainSuffix.
# If you set up a kubernetes cluster with a different dnsDomainSuffix, you need to set this value.
dnsDomainSuffix: ""
4 changes: 4 additions & 0 deletions helm-charts/charts/kube-starrocks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ operator:
- --zap-encoder=console
# if you want open debug log, open this option
# - --zap-log-level 4
# Operator need to specify the FQDN in nginx.conf when it set up fe-proxy service.
# By default, Operator will use cluster.local as the dnsDomainSuffix.
# If you set up a kubernetes cluster with a different dnsDomainSuffix, you need to set this value.
dnsDomainSuffix: ""

starrocks:
# set the nameOverride values for creating the same resources with parent chart.
Expand Down
5 changes: 3 additions & 2 deletions pkg/subcontrollers/feproxy/feproxy_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

cmdconfig "github.com/StarRocks/starrocks-kubernetes-operator/cmd/config"
srapi "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1"
rutils "github.com/StarRocks/starrocks-kubernetes-operator/pkg/common/resource_utils"
"github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils"
Expand All @@ -27,11 +28,11 @@ func (controller *FeProxyController) SyncConfigMap(ctx context.Context, src *sra

feSearchServiceName := service.SearchServiceName(src.Name, feSpec)
feExternalServiceName := service.ExternalServiceName(src.Name, feSpec)
proxyPass := fmt.Sprintf("http://%s.%s.%s:%d", feExternalServiceName, src.GetNamespace(), "svc.cluster.local", httpPort)
proxyPass := fmt.Sprintf("http://%s.%s.%s:%d", feExternalServiceName, src.GetNamespace(), cmdconfig.GetServiceDomainSuffix(), httpPort)

resolver := feProxySpec.Resolver
if resolver == "" {
resolver = "kube-dns.kube-system.svc.cluster.local"
resolver = fmt.Sprintf("%s.%s", "kube-dns.kube-system", cmdconfig.GetServiceDomainSuffix())
}

or := metav1.NewControllerRef(src, src.GroupVersionKind())
Expand Down

0 comments on commit a8501db

Please sign in to comment.