Skip to content

Commit 5827395

Browse files
sourcecdSergey JSergey Ierusalimov
authored
Add dns domain select (#273)
--------- Co-authored-by: Sergey J <[email protected]> Co-authored-by: Sergey Ierusalimov <[email protected]>
1 parent 8cc391a commit 5827395

12 files changed

+45
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
kind: Added
2+
body: 'added the ability to create metadata announce for customize dns domain (default:
3+
cluster.local)'
4+
time: 2024-11-18T22:28:10.452679+03:00
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Changed
2+
body: up CONTROLLER_GEN_VERSION to 0.16.5 and ENVTEST_VERSION to release-0.17
3+
time: 2024-11-18T22:25:37.274092+03:00
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Security
2+
body: bump golang-jwt to v4.5.1 (by dependabot)
3+
time: 2024-11-18T22:24:33.337464+03:00

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ docker-push: ## Push docker image with the manager.
106106
docker push ${IMG}
107107

108108
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
109-
CONTROLLER_GEN_VERSION ?= v0.6.1
109+
CONTROLLER_GEN_VERSION ?= v0.16.5
110110
controller-gen: ## Download controller-gen locally if necessary.
111111
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION))
112112

113113
# ENVTEST_VERSION is usually latest, but might need to be pinned from time to time.
114114
# Version pinning is needed due to version incompatibility between controller-runtime and setup-envtest.
115115
# For more information: https://github.com/kubernetes-sigs/controller-runtime/issues/2744
116116
ENVTEST = $(shell pwd)/bin/setup-envtest
117-
ENVTEST_VERSION ?= release-0.16
117+
ENVTEST_VERSION ?= release-0.17
118118
envtest: ## Download envtest-setup locally if necessary.
119119
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@$(ENVTEST_VERSION))
120120

api/v1alpha1/const.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ const (
66

77
ImagePathFormat = "%s:%s"
88

9+
DefaultDomainName = "cluster.local"
10+
DNSDomainAnnotation = "dns.domain"
11+
912
GRPCPort = 2135
1013
GRPCServicePortName = "grpc"
1114
GRPCProto = "grpc://"
1215
GRPCSProto = "grpcs://"
13-
GRPCServiceFQDNFormat = "%s-grpc.%s.svc.cluster.local"
16+
GRPCServiceFQDNFormat = "%s-grpc.%s.svc.%s"
1417

1518
InterconnectPort = 19001
1619
InterconnectServicePortName = "interconnect"
17-
InterconnectServiceFQDNFormat = "%s-interconnect.%s.svc.cluster.local"
20+
InterconnectServiceFQDNFormat = "%s-interconnect.%s.svc.%s"
1821

1922
StatusPort = 8765
2023
StatusServicePortName = "status"

api/v1alpha1/storage_webhook.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ func (r *Storage) GetStorageEndpoint() string {
5454
}
5555

5656
func (r *Storage) GetGRPCServiceEndpoint() string {
57-
host := fmt.Sprintf(GRPCServiceFQDNFormat, r.Name, r.Namespace)
57+
domain := DefaultDomainName
58+
if dnsAnnotation, ok := r.GetAnnotations()[DNSDomainAnnotation]; ok {
59+
domain = dnsAnnotation
60+
}
61+
host := fmt.Sprintf(GRPCServiceFQDNFormat, r.Name, r.Namespace, domain)
5862
if r.Spec.Service.GRPC.ExternalHost != "" {
5963
host = r.Spec.Service.GRPC.ExternalHost
6064
}

api/v1alpha1/zz_generated.deepcopy.go

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.20
55
require (
66
github.com/banzaicloud/k8s-objectmatcher v1.7.0
77
github.com/go-logr/logr v1.2.4
8-
github.com/golang-jwt/jwt/v4 v4.4.1
8+
github.com/golang-jwt/jwt/v4 v4.5.1
99
github.com/google/go-cmp v0.5.9
1010
github.com/onsi/ginkgo/v2 v2.9.4
1111
github.com/onsi/gomega v1.27.6

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV
173173
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
174174
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
175175
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
176-
github.com/golang-jwt/jwt/v4 v4.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ=
177-
github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
176+
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
177+
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
178178
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
179179
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
180180
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=

internal/resources/database_statefulset.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ func (b *DatabaseStatefulSetBuilder) buildEnv() []corev1.EnvVar {
100100
}
101101

102102
func (b *DatabaseStatefulSetBuilder) buildPodTemplateSpec() corev1.PodTemplateSpec {
103+
domain := api.DefaultDomainName
104+
if dnsAnnotation, ok := b.GetAnnotations()[api.DNSDomainAnnotation]; ok {
105+
domain = dnsAnnotation
106+
}
103107
podTemplate := corev1.PodTemplateSpec{
104108
ObjectMeta: metav1.ObjectMeta{
105109
Labels: b.Labels,
@@ -118,7 +122,7 @@ func (b *DatabaseStatefulSetBuilder) buildPodTemplateSpec() corev1.PodTemplateSp
118122

119123
DNSConfig: &corev1.PodDNSConfig{
120124
Searches: []string{
121-
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Spec.StorageClusterRef.Name, b.Spec.StorageClusterRef.Namespace),
125+
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Spec.StorageClusterRef.Name, b.Spec.StorageClusterRef.Namespace, domain),
122126
},
123127
},
124128
},
@@ -541,6 +545,10 @@ func (b *DatabaseStatefulSetBuilder) buildVolumeMounts() []corev1.VolumeMount {
541545
}
542546

543547
func (b *DatabaseStatefulSetBuilder) buildContainerArgs() ([]string, []string) {
548+
domain := api.DefaultDomainName
549+
if dnsAnnotation, ok := b.GetAnnotations()[api.DNSDomainAnnotation]; ok {
550+
domain = dnsAnnotation
551+
}
544552
command := []string{fmt.Sprintf("%s/%s", api.BinariesDir, api.DaemonBinaryName)}
545553

546554
args := []string{
@@ -633,7 +641,7 @@ func (b *DatabaseStatefulSetBuilder) buildContainerArgs() ([]string, []string) {
633641
}
634642

635643
publicHostOption := "--grpc-public-host"
636-
publicHost := fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Database.Name, b.GetNamespace()) // FIXME .svc.cluster.local
644+
publicHost := fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Database.Name, b.GetNamespace(), domain) // FIXME .svc.cluster.local
637645

638646
if b.Spec.Service.GRPC.ExternalHost != "" {
639647
publicHost = b.Spec.Service.GRPC.ExternalHost

internal/resources/storage_init_job.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ func GetInitJobBuilder(storage *api.Storage) ResourceBuilder {
8484
}
8585

8686
func (b *StorageInitJobBuilder) buildInitJobPodTemplateSpec() corev1.PodTemplateSpec {
87+
domain := api.DefaultDomainName
88+
if dnsAnnotation, ok := b.GetAnnotations()[api.DNSDomainAnnotation]; ok {
89+
domain = dnsAnnotation
90+
}
8791
dnsConfigSearches := []string{
88-
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Storage.Name, b.GetNamespace()),
92+
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Storage.Name, b.GetNamespace(), domain),
8993
}
9094
podTemplate := corev1.PodTemplateSpec{
9195
ObjectMeta: metav1.ObjectMeta{

internal/resources/storage_statefulset.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ func (b *StorageStatefulSetBuilder) Build(obj client.Object) error {
104104
}
105105

106106
func (b *StorageStatefulSetBuilder) buildPodTemplateSpec() corev1.PodTemplateSpec {
107+
domain := api.DefaultDomainName
108+
if dnsAnnotation, ok := b.GetAnnotations()[api.DNSDomainAnnotation]; ok {
109+
domain = dnsAnnotation
110+
}
107111
dnsConfigSearches := []string{
108-
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Storage.Name, b.GetNamespace()),
112+
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Storage.Name, b.GetNamespace(), domain),
109113
}
110114

111115
podTemplate := corev1.PodTemplateSpec{

0 commit comments

Comments
 (0)