From 3635575ce2f9c4d538e7e64d53e3e3dd68564b96 Mon Sep 17 00:00:00 2001 From: rahulsawra98 Date: Mon, 20 Feb 2023 12:26:52 +0530 Subject: [PATCH 1/3] feat(AM-6688): make kubeslice-dns as default dns server --- main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index d9f5669..48aa5ff 100644 --- a/main.go +++ b/main.go @@ -58,7 +58,7 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd" "github.com/networkservicemesh/sdk/pkg/networkservice/common/retry" "github.com/networkservicemesh/sdk/pkg/networkservice/common/upstreamrefresh" - "github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext" + _ "github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext" "github.com/networkservicemesh/sdk/pkg/networkservice/core/chain" "github.com/networkservicemesh/sdk/pkg/tools/dnsconfig" "github.com/networkservicemesh/sdk/pkg/tools/dnsutils" @@ -196,7 +196,7 @@ func main() { kernelmech.MECHANISM: chain.NewNetworkServiceClient(kernel.NewClient()), }), sendfd.NewClient(), - dnscontext.NewClient(dnscontext.WithChainContext(ctx), dnscontext.WithDNSConfigsMap(dnsConfigsMap)), + // dnscontext.NewClient(dnscontext.WithChainContext(ctx), dnscontext.WithDNSConfigsMap(dnsConfigsMap)), excludedprefixes.NewClient(excludedprefixes.WithAwarenessGroups(c.AwarenessGroups)), ), client.WithDialTimeout(c.DialTimeout), @@ -299,7 +299,6 @@ func main() { logger.Infof("successfully connected to %v. Response: %v", u.NetworkService(), resp) } - // Wait for cancel event to terminate <-signalCtx.Done() } From faa2f5b7f9e39f3684a869b84b8440219121b61f Mon Sep 17 00:00:00 2001 From: rahulsawra98 Date: Tue, 21 Feb 2023 15:44:36 +0530 Subject: [PATCH 2/3] add LocalDNSServerEnabled flag to config --- internal/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config/config.go b/internal/config/config.go index 566f8e5..5e8ada4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -44,7 +44,7 @@ type Config struct { 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"` - + 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"` From 6a63662276c587fd5b1b126b88eec680a2d75bb8 Mon Sep 17 00:00:00 2001 From: rahulsawra98 Date: Tue, 21 Feb 2023 15:49:45 +0530 Subject: [PATCH 3/3] implement LocalDNSServerEnabled flag --- internal/config/config.go | 4 ++-- main.go | 32 ++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 5e8ada4..f5cb646 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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"` - LocalDNSServerEnabled bool `default:"false" desc:"Local DNS Server enabled/disabled"` + 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"` diff --git a/main.go b/main.go index 48aa5ff..03b0a3f 100644 --- a/main.go +++ b/main.go @@ -56,9 +56,10 @@ 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" + "github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext" "github.com/networkservicemesh/sdk/pkg/networkservice/core/chain" "github.com/networkservicemesh/sdk/pkg/tools/dnsconfig" "github.com/networkservicemesh/sdk/pkg/tools/dnsutils" @@ -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)} @@ -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),