diff --git a/pkg/kubelet/network/dns/dns.go b/pkg/kubelet/network/dns/dns.go index b329b848700..f09b6f111d7 100644 --- a/pkg/kubelet/network/dns/dns.go +++ b/pkg/kubelet/network/dns/dns.go @@ -230,7 +230,11 @@ func parseResolvConf(reader io.Reader) (nameservers []string, searches []string, } } if fields[0] == "search" { - searches = fields[1:] + // Normalise search fields so the same domain with and without trailing dot will only count once, to avoid hitting search validation limits. + searches = []string{} + for _, s := range fields[1:] { + searches = append(searches, strings.TrimSuffix(s, ".")) + } } if fields[0] == "options" { options = fields[1:] diff --git a/pkg/kubelet/network/dns/dns_test.go b/pkg/kubelet/network/dns/dns_test.go index 5cbf6a8b1ab..de4bf620041 100644 --- a/pkg/kubelet/network/dns/dns_test.go +++ b/pkg/kubelet/network/dns/dns_test.go @@ -74,6 +74,7 @@ func TestParseResolvConf(t *testing.T) { {"search ", []string{}, []string{}, []string{}, false}, // search empty {"search foo", []string{}, []string{"foo"}, []string{}, false}, {"search foo bar", []string{}, []string{"foo", "bar"}, []string{}, false}, + {"search foo. bar", []string{}, []string{"foo", "bar"}, []string{}, false}, {"search foo bar bat\n", []string{}, []string{"foo", "bar", "bat"}, []string{}, false}, {"search foo\nsearch bar", []string{}, []string{"bar"}, []string{}, false}, {"nameserver 1.2.3.4\nsearch foo bar", []string{"1.2.3.4"}, []string{"foo", "bar"}, []string{}, false},