mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #62832 from grayluck/externalname-test
Automatic merge from submit-queue (batch tested with PRs 62885, 62832). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. e2e test forwarding externalname dns lookup to upstream nameservers. **What this PR does / why we need it**: e2e test forwarding externalname dns lookup to upstream nameservers. e2e test that goes through dnsmasq -> kubedns -> upstream servers path. Updated e2e test for PTR record lookup, test for default upstreamservers from resolv.conf. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes https://github.com/kubernetes/dns/issues/226 **Special notes for your reviewer**: /assign @MrHohn **Release note**: ```release-note NONE ```
This commit is contained in:
commit
e85943f9a2
@ -22,6 +22,7 @@ import (
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
)
|
||||
@ -33,6 +34,13 @@ type dnsFederationsConfigMapTest struct {
|
||||
isValid bool
|
||||
}
|
||||
|
||||
var (
|
||||
googleDnsHostname = "google-public-dns-a.google.com"
|
||||
// The ConfigMap update mechanism takes longer than the standard
|
||||
// wait.ForeverTestTimeout.
|
||||
moreForeverTestTimeout = 2 * 60 * time.Second
|
||||
)
|
||||
|
||||
var _ = SIGDescribe("DNS configMap federations", func() {
|
||||
|
||||
t := &dnsNameserverTest{dnsTestCommon: newDnsTestCommon()}
|
||||
@ -156,10 +164,6 @@ func (t *dnsNameserverTest) run() {
|
||||
"upstreamNameservers": fmt.Sprintf(`["%v"]`, t.dnsServerPod.Status.PodIP),
|
||||
}})
|
||||
|
||||
// The ConfigMap update mechanism takes longer than the standard
|
||||
// wait.ForeverTestTimeout.
|
||||
moreForeverTestTimeout := 2 * 60 * time.Second
|
||||
|
||||
t.checkDNSRecordFrom(
|
||||
"abc.acme.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "1.1.1.1" },
|
||||
@ -199,19 +203,24 @@ func (t *dnsPtrFwdTest) run() {
|
||||
t.createDNSServerWithPtrRecord()
|
||||
defer t.deleteDNSServerPod()
|
||||
|
||||
// Should still be able to lookup public nameserver without explicit upstream nameserver set.
|
||||
t.checkDNSRecordFrom(
|
||||
"8.8.8.8.in-addr.arpa",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == googleDnsHostname+"." },
|
||||
"dnsmasq",
|
||||
moreForeverTestTimeout)
|
||||
|
||||
t.setConfigMap(&v1.ConfigMap{Data: map[string]string{
|
||||
"upstreamNameservers": fmt.Sprintf(`["%v"]`, t.dnsServerPod.Status.PodIP),
|
||||
}})
|
||||
|
||||
moreForeverTestTimeout := 2 * 60 * time.Second
|
||||
|
||||
t.checkDNSRecordFrom(
|
||||
"123.2.0.192.in-addr.arpa",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "my.test." },
|
||||
"dnsmasq",
|
||||
moreForeverTestTimeout)
|
||||
|
||||
t.c.CoreV1().ConfigMaps(t.ns).Delete(t.name, nil)
|
||||
t.setConfigMap(&v1.ConfigMap{Data: map[string]string{}})
|
||||
t.checkDNSRecordFrom(
|
||||
"123.2.0.192.in-addr.arpa",
|
||||
func(actual []string) bool { return len(actual) == 0 },
|
||||
@ -219,6 +228,63 @@ func (t *dnsPtrFwdTest) run() {
|
||||
moreForeverTestTimeout)
|
||||
}
|
||||
|
||||
type dnsExternalNameTest struct {
|
||||
dnsTestCommon
|
||||
}
|
||||
|
||||
func (t *dnsExternalNameTest) run() {
|
||||
t.init()
|
||||
|
||||
t.createUtilPod()
|
||||
defer t.deleteUtilPod()
|
||||
|
||||
fooHostname := "foo.example.com"
|
||||
t.createDNSServer(map[string]string{
|
||||
fooHostname: "192.0.2.123",
|
||||
})
|
||||
defer t.deleteDNSServerPod()
|
||||
|
||||
f := t.f
|
||||
serviceName := "dns-externalname-upstream-test"
|
||||
externalNameService := framework.CreateServiceSpec(serviceName, googleDnsHostname, false, nil)
|
||||
if _, err := f.ClientSet.CoreV1().Services(f.Namespace.Name).Create(externalNameService); err != nil {
|
||||
Fail(fmt.Sprintf("Failed when creating service: %v", err))
|
||||
}
|
||||
serviceNameLocal := "dns-externalname-upstream-local"
|
||||
externalNameServiceLocal := framework.CreateServiceSpec(serviceNameLocal, fooHostname, false, nil)
|
||||
if _, err := f.ClientSet.CoreV1().Services(f.Namespace.Name).Create(externalNameServiceLocal); err != nil {
|
||||
Fail(fmt.Sprintf("Failed when creating service: %v", err))
|
||||
}
|
||||
defer func() {
|
||||
By("deleting the test externalName service")
|
||||
defer GinkgoRecover()
|
||||
f.ClientSet.CoreV1().Services(f.Namespace.Name).Delete(externalNameService.Name, nil)
|
||||
f.ClientSet.CoreV1().Services(f.Namespace.Name).Delete(externalNameServiceLocal.Name, nil)
|
||||
}()
|
||||
|
||||
t.checkDNSRecordFrom(
|
||||
fmt.Sprintf("%s.%s.svc.cluster.local", serviceName, f.Namespace.Name),
|
||||
func(actual []string) bool {
|
||||
return len(actual) >= 1 && actual[0] == googleDnsHostname+"."
|
||||
},
|
||||
"dnsmasq",
|
||||
moreForeverTestTimeout)
|
||||
|
||||
t.setConfigMap(&v1.ConfigMap{Data: map[string]string{
|
||||
"upstreamNameservers": fmt.Sprintf(`["%v"]`, t.dnsServerPod.Status.PodIP),
|
||||
}})
|
||||
|
||||
t.checkDNSRecordFrom(
|
||||
fmt.Sprintf("%s.%s.svc.cluster.local", serviceNameLocal, f.Namespace.Name),
|
||||
func(actual []string) bool {
|
||||
return len(actual) == 2 && actual[0] == fooHostname+"." && actual[1] == "192.0.2.123"
|
||||
},
|
||||
"dnsmasq",
|
||||
moreForeverTestTimeout)
|
||||
|
||||
t.setConfigMap(&v1.ConfigMap{Data: map[string]string{}})
|
||||
}
|
||||
|
||||
var _ = SIGDescribe("DNS configMap nameserver", func() {
|
||||
|
||||
Context("Change stubDomain", func() {
|
||||
@ -238,4 +304,13 @@ var _ = SIGDescribe("DNS configMap nameserver", func() {
|
||||
fwdTest.run()
|
||||
})
|
||||
})
|
||||
|
||||
Context("Forward external name lookup", func() {
|
||||
externalNameTest := &dnsExternalNameTest{dnsTestCommon: newDnsTestCommon()}
|
||||
|
||||
It("should forward externalname lookup to upstream nameserver [Slow][Serial]", func() {
|
||||
externalNameTest.c = externalNameTest.f.ClientSet
|
||||
externalNameTest.run()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user