Skip to content
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

feat(AM-6688): make kubeslice-dns as default dns server #5

Open
wants to merge 4 commits into
base: release-v1.5.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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: 2 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type Config struct {
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
OpenTelemetryEndpoint string `default:"otel-collector.observability.svc.cluster.local:4317" desc:"OpenTelemetry Collector Endpoint"`

LocalDNSServerAddress string `default:"127.0.0.1:53" desc:"Default address for local DNS server"`

LocalDNSServerAddress string `default:"127.0.0.1:53" desc:"Default address for local DNS server"`
LocalDNSServerEnabled bool `default:"false" desc:"Local DNS Server enabled/disabled"`
LivenessCheckEnabled bool `default:"true" desc:"Dataplane liveness check enabled/disabled"`
LivenessCheckInterval time.Duration `default:"200ms" desc:"Dataplane liveness check interval"`
LivenessCheckTimeout time.Duration `default:"1s" desc:"Dataplane liveness check timeout"`
Expand Down
31 changes: 17 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import (
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/kernel"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/null"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/retry"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/upstreamrefresh"
"github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext"
Expand Down Expand Up @@ -163,18 +164,21 @@ func main() {
),
)

dnsConfigsMap := new(dnsconfig.Map)
dnsServerHandler := next.NewDNSHandler(
checkmsg.NewDNSHandler(),
dnsconfigs.NewDNSHandler(dnsConfigsMap),
searches.NewDNSHandler(),
noloop.NewDNSHandler(),
cache.NewDNSHandler(),
fanout.NewDNSHandler(),
)

go dnsutils.ListenAndServe(ctx, dnsServerHandler, c.LocalDNSServerAddress)

dnsClient := null.NewClient()
if c.LocalDNSServerEnabled {
dnsConfigsMap := new(dnsconfig.Map)
dnsClient = dnscontext.NewClient(dnscontext.WithChainContext(ctx), dnscontext.WithDNSConfigsMap(dnsConfigsMap))
dnsServerHandler := next.NewDNSHandler(
checkmsg.NewDNSHandler(),
dnsconfigs.NewDNSHandler(dnsConfigsMap),
searches.NewDNSHandler(),
noloop.NewDNSHandler(),
cache.NewDNSHandler(),
fanout.NewDNSHandler(),
)

go dnsutils.ListenAndServe(ctx, dnsServerHandler, c.LocalDNSServerAddress)
}
var healOptions = []heal.Option{heal.WithLivenessCheckInterval(c.LivenessCheckInterval),
heal.WithLivenessCheckTimeout(c.LivenessCheckTimeout)}

Expand All @@ -196,7 +200,7 @@ func main() {
kernelmech.MECHANISM: chain.NewNetworkServiceClient(kernel.NewClient()),
}),
sendfd.NewClient(),
dnscontext.NewClient(dnscontext.WithChainContext(ctx), dnscontext.WithDNSConfigsMap(dnsConfigsMap)),
dnsClient,
excludedprefixes.NewClient(excludedprefixes.WithAwarenessGroups(c.AwarenessGroups)),
),
client.WithDialTimeout(c.DialTimeout),
Expand Down Expand Up @@ -299,7 +303,6 @@ func main() {
logger.Infof("successfully connected to %v. Response: %v", u.NetworkService(), resp)
}


// Wait for cancel event to terminate
<-signalCtx.Done()
}