Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] support to run fe-proxy under customize cluster domain instead of using default one: cluster.local #604

Merged
Merged
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
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ linters-settings:
- pattern: 'interface{}'
replacement: 'any'
goimports:
local-prefixes: github.com/StarRocks/starrocks-kubernetes-operator/pkg
local-prefixes: github.com/StarRocks/starrocks-kubernetes-operator
gomnd:
# don't include the "operation" and "assign"
checks:
Expand Down
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"
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