Skip to content

Add dns domain select #273

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

Merged
merged 12 commits into from
Nov 18, 2024
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
4 changes: 4 additions & 0 deletions .changes/unreleased/Added-20241118-222810.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kind: Added
body: 'added the ability to create metadata announce for customize dns domain (default:
cluster.local)'
time: 2024-11-18T22:28:10.452679+03:00
3 changes: 3 additions & 0 deletions .changes/unreleased/Changed-20241118-222537.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Changed
body: up CONTROLLER_GEN_VERSION to 0.16.5 and ENVTEST_VERSION to release-0.17
time: 2024-11-18T22:25:37.274092+03:00
3 changes: 3 additions & 0 deletions .changes/unreleased/Security-20241118-222433.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Security
body: bump golang-jwt to v4.5.1 (by dependabot)
time: 2024-11-18T22:24:33.337464+03:00
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ docker-push: ## Push docker image with the manager.
docker push ${IMG}

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

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

Expand Down
7 changes: 5 additions & 2 deletions api/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ const (

ImagePathFormat = "%s:%s"

DefaultDomainName = "cluster.local"
DNSDomainAnnotation = "dns.domain"

GRPCPort = 2135
GRPCServicePortName = "grpc"
GRPCProto = "grpc://"
GRPCSProto = "grpcs://"
GRPCServiceFQDNFormat = "%s-grpc.%s.svc.cluster.local"
GRPCServiceFQDNFormat = "%s-grpc.%s.svc.%s"

InterconnectPort = 19001
InterconnectServicePortName = "interconnect"
InterconnectServiceFQDNFormat = "%s-interconnect.%s.svc.cluster.local"
InterconnectServiceFQDNFormat = "%s-interconnect.%s.svc.%s"

StatusPort = 8765
StatusServicePortName = "status"
Expand Down
6 changes: 5 additions & 1 deletion api/v1alpha1/storage_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ func (r *Storage) GetStorageEndpoint() string {
}

func (r *Storage) GetGRPCServiceEndpoint() string {
host := fmt.Sprintf(GRPCServiceFQDNFormat, r.Name, r.Namespace)
domain := DefaultDomainName
if dnsAnnotation, ok := r.GetAnnotations()[DNSDomainAnnotation]; ok {
domain = dnsAnnotation
}
host := fmt.Sprintf(GRPCServiceFQDNFormat, r.Name, r.Namespace, domain)
if r.Spec.Service.GRPC.ExternalHost != "" {
host = r.Spec.Service.GRPC.ExternalHost
}
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/banzaicloud/k8s-objectmatcher v1.7.0
github.com/go-logr/logr v1.2.4
github.com/golang-jwt/jwt/v4 v4.4.1
github.com/golang-jwt/jwt/v4 v4.5.1
github.com/google/go-cmp v0.5.9
github.com/onsi/ginkgo/v2 v2.9.4
github.com/onsi/gomega v1.27.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ=
github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down
12 changes: 10 additions & 2 deletions internal/resources/database_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func (b *DatabaseStatefulSetBuilder) buildEnv() []corev1.EnvVar {
}

func (b *DatabaseStatefulSetBuilder) buildPodTemplateSpec() corev1.PodTemplateSpec {
domain := api.DefaultDomainName
if dnsAnnotation, ok := b.GetAnnotations()[api.DNSDomainAnnotation]; ok {
domain = dnsAnnotation
}
podTemplate := corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: b.Labels,
Expand All @@ -118,7 +122,7 @@ func (b *DatabaseStatefulSetBuilder) buildPodTemplateSpec() corev1.PodTemplateSp

DNSConfig: &corev1.PodDNSConfig{
Searches: []string{
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Spec.StorageClusterRef.Name, b.Spec.StorageClusterRef.Namespace),
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Spec.StorageClusterRef.Name, b.Spec.StorageClusterRef.Namespace, domain),
},
},
},
Expand Down Expand Up @@ -541,6 +545,10 @@ func (b *DatabaseStatefulSetBuilder) buildVolumeMounts() []corev1.VolumeMount {
}

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

args := []string{
Expand Down Expand Up @@ -633,7 +641,7 @@ func (b *DatabaseStatefulSetBuilder) buildContainerArgs() ([]string, []string) {
}

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

if b.Spec.Service.GRPC.ExternalHost != "" {
publicHost = b.Spec.Service.GRPC.ExternalHost
Expand Down
6 changes: 5 additions & 1 deletion internal/resources/storage_init_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ func GetInitJobBuilder(storage *api.Storage) ResourceBuilder {
}

func (b *StorageInitJobBuilder) buildInitJobPodTemplateSpec() corev1.PodTemplateSpec {
domain := api.DefaultDomainName
if dnsAnnotation, ok := b.GetAnnotations()[api.DNSDomainAnnotation]; ok {
domain = dnsAnnotation
}
dnsConfigSearches := []string{
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Storage.Name, b.GetNamespace()),
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Storage.Name, b.GetNamespace(), domain),
}
podTemplate := corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down
6 changes: 5 additions & 1 deletion internal/resources/storage_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ func (b *StorageStatefulSetBuilder) Build(obj client.Object) error {
}

func (b *StorageStatefulSetBuilder) buildPodTemplateSpec() corev1.PodTemplateSpec {
domain := api.DefaultDomainName
if dnsAnnotation, ok := b.GetAnnotations()[api.DNSDomainAnnotation]; ok {
domain = dnsAnnotation
}
dnsConfigSearches := []string{
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Storage.Name, b.GetNamespace()),
fmt.Sprintf(api.InterconnectServiceFQDNFormat, b.Storage.Name, b.GetNamespace(), domain),
}

podTemplate := corev1.PodTemplateSpec{
Expand Down
Loading