Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
kind: fix
date: 2025-09-25
---

* Use CLUSTER_DOMAIN environment variable instead of the fixed value `cluster.local`
4 changes: 3 additions & 1 deletion controllers/searchcontroller/community_search_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/blang/semver"
"github.com/mongodb/mongodb-kubernetes/pkg/util/env"
"golang.org/x/xerrors"
"k8s.io/apimachinery/pkg/types"

Expand All @@ -26,8 +27,9 @@ type CommunitySearchSource struct {

func (r *CommunitySearchSource) HostSeeds() []string {
seeds := make([]string, r.Spec.Members)
clusterDomain := env.ReadOrDefault("CLUSTER_DOMAIN", "cluster.local")
for i := range seeds {
seeds[i] = fmt.Sprintf("%s-%d.%s.%s.svc.cluster.local:%d", r.Name, i, r.ServiceName(), r.Namespace, r.GetMongodConfiguration().GetDBPort())
seeds[i] = fmt.Sprintf("%s-%d.%s.%s.svc.%s:%d", r.Name, i, r.ServiceName(), r.Namespace, clusterDomain, r.GetMongodConfiguration().GetDBPort())
}
return seeds
}
Expand Down
4 changes: 3 additions & 1 deletion controllers/searchcontroller/enterprise_search_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/blang/semver"
"github.com/mongodb/mongodb-kubernetes/pkg/util/env"
"golang.org/x/xerrors"
"k8s.io/apimachinery/pkg/types"

Expand All @@ -24,8 +25,9 @@ func NewEnterpriseResourceSearchSource(mdb *mdbv1.MongoDB) SearchSourceDBResourc

func (r EnterpriseResourceSearchSource) HostSeeds() []string {
seeds := make([]string, r.Spec.Members)
clusterDomain := env.ReadOrDefault("CLUSTER_DOMAIN", "cluster.local")
for i := range seeds {
seeds[i] = fmt.Sprintf("%s-%d.%s.%s.svc.cluster.local:%d", r.Name, i, r.ServiceName(), r.Namespace, r.Spec.GetAdditionalMongodConfig().GetPortOrDefault())
seeds[i] = fmt.Sprintf("%s-%d.%s.%s.svc.%s:%d", r.Name, i, r.ServiceName(), r.Namespace, clusterDomain, r.Spec.GetAdditionalMongodConfig().GetPortOrDefault())
}
return seeds
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/blang/semver"
"github.com/ghodss/yaml"
"github.com/mongodb/mongodb-kubernetes/pkg/util/env"
"go.uber.org/zap"
"golang.org/x/xerrors"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -405,7 +406,8 @@ func GetMongodConfigParameters(search *searchv1.MongoDBSearch) map[string]any {

func mongotHostAndPort(search *searchv1.MongoDBSearch) string {
svcName := search.SearchServiceNamespacedName()
return fmt.Sprintf("%s.%s.svc.cluster.local:%d", svcName.Name, svcName.Namespace, search.GetMongotPort())
clusterDomain := env.ReadOrDefault("CLUSTER_DOMAIN", "cluster.local")
return fmt.Sprintf("%s.%s.svc.%s:%d", svcName.Name, svcName.Namespace, clusterDomain, search.GetMongotPort())
}

func (r *MongoDBSearchReconcileHelper) ValidateSingleMongoDBSearchForSearchSource(ctx context.Context) error {
Expand Down