Skip to content

Commit 107713c

Browse files
committed
grpc-public-host pqv0 support
1 parent 000f685 commit 107713c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

internal/resources/storage_statefulset.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"strconv"
7+
"strings"
78

89
appsv1 "k8s.io/api/apps/v1"
910
corev1 "k8s.io/api/core/v1"
@@ -570,6 +571,37 @@ func (b *StorageStatefulSetBuilder) buildContainerArgs() ([]string, []string) {
570571
}
571572
}
572573

574+
var publicHost string
575+
if b.Spec.Service.GRPC.ExternalHost != "" {
576+
publicHost = fmt.Sprintf("%s.%s", "$(POD_NAME)", b.Spec.Service.GRPC.ExternalHost)
577+
}
578+
if value, ok := b.ObjectMeta.Annotations[api.AnnotationGRPCPublicHost]; ok {
579+
publicHost = value
580+
}
581+
if publicHost != "" {
582+
if !(strings.HasPrefix(publicHost, "$(POD_NAME)") || strings.HasPrefix(publicHost, "$(NODE_NAME)")) {
583+
publicHost = fmt.Sprintf("%s.%s", "$(POD_NAME)", publicHost)
584+
}
585+
args = append(args,
586+
"--grpc-public-host",
587+
publicHost,
588+
)
589+
}
590+
591+
var publicPort string
592+
if b.Spec.Service.GRPC.ExternalPort > 0 {
593+
publicPort = fmt.Sprintf("%d", b.Spec.Service.GRPC.ExternalPort)
594+
}
595+
if value, ok := b.ObjectMeta.Annotations[api.AnnotationGRPCPublicPort]; ok {
596+
publicPort = value
597+
}
598+
if publicPort != "" {
599+
args = append(args,
600+
"--grpc-public-port",
601+
publicPort,
602+
)
603+
}
604+
573605
return command, args
574606
}
575607

0 commit comments

Comments
 (0)