@@ -16,11 +16,12 @@ package model
16
16
17
17
import (
18
18
"fmt"
19
+ "strconv"
20
+ "strings"
21
+
19
22
chop "github.com/altinity/clickhouse-operator/pkg/apis/clickhouse.altinity.com/v1"
20
23
"github.com/altinity/clickhouse-operator/pkg/util"
21
24
apps "k8s.io/api/apps/v1"
22
- "strconv"
23
- "strings"
24
25
)
25
26
26
27
const (
@@ -503,6 +504,15 @@ func CreateCHIServiceName(chi *chop.ClickHouseInstallation) string {
503
504
504
505
// CreateCHIServiceName creates a name of a Installation Service resource
505
506
func CreateChiServiceFQDN (chi * chop.ClickHouseInstallation ) string {
507
+ if chi .Spec .NamespaceDomainPattern != "" {
508
+ // NamespaceDomainPattern has been explicitly specified
509
+ return fmt .Sprintf (
510
+ "%s." + chi .Spec .NamespaceDomainPattern ,
511
+ CreateCHIServiceName (chi ),
512
+ chi .Namespace ,
513
+ )
514
+ }
515
+
506
516
return fmt .Sprintf (
507
517
serviceFQDNPattern ,
508
518
CreateCHIServiceName (chi ),
@@ -594,6 +604,15 @@ func IsAutoGeneratedHostName(
594
604
595
605
// CreateStatefulSetName creates a name of a StatefulSet for ClickHouse instance
596
606
func CreateStatefulSetName (host * chop.ChiHost ) string {
607
+ if template , ok := host .GetPodTemplate (); ok {
608
+ // Pod template available
609
+ if template .GenerateName != "" {
610
+ // Pod template has explicitly specified pod name template
611
+ return newNameMacroReplacerHost (host ).Replace (template .GenerateName )
612
+ }
613
+ }
614
+
615
+ // Create Statefulset name based on default Statefulset Name template
597
616
return newNameMacroReplacerHost (host ).Replace (statefulSetNamePattern )
598
617
}
599
618
@@ -620,6 +639,14 @@ func CreatePodHostname(host *chop.ChiHost) string {
620
639
// CreatePodFQDN creates a fully qualified domain name of a pod
621
640
// ss-1eb454-2-0.my-dev-domain.svc.cluster.local
622
641
func CreatePodFQDN (host * chop.ChiHost ) string {
642
+ if host .CHI .Spec .NamespaceDomainPattern != "" {
643
+ return fmt .Sprintf (
644
+ "%s." + host .CHI .Spec .NamespaceDomainPattern ,
645
+ CreatePodHostname (host ),
646
+ host .Address .Namespace ,
647
+ )
648
+ }
649
+
623
650
return fmt .Sprintf (
624
651
podFQDNPattern ,
625
652
CreatePodHostname (host ),
0 commit comments