Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
a1aafbf4
Commit
a1aafbf4
authored
Jun 14, 2021
by
Chris O'Haver
Committed by
GitHub
Jun 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add NS+hosts records to xfr response. Add coredns service to test data. (#4696)
Signed-off-by:
Chris O'Haver
<
cohaver@infoblox.com
>
parent
0f061cc9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
3 deletions
+49
-3
plugin/kubernetes/handler_test.go
plugin/kubernetes/handler_test.go
+26
-0
plugin/kubernetes/xfr.go
plugin/kubernetes/xfr.go
+11
-0
plugin/kubernetes/xfr_test.go
plugin/kubernetes/xfr_test.go
+12
-3
No files found.
plugin/kubernetes/handler_test.go
View file @
a1aafbf4
...
@@ -568,6 +568,17 @@ func (APIConnServeTest) PodIndex(ip string) []*object.Pod {
...
@@ -568,6 +568,17 @@ func (APIConnServeTest) PodIndex(ip string) []*object.Pod {
}
}
var
svcIndex
=
map
[
string
][]
*
object
.
Service
{
var
svcIndex
=
map
[
string
][]
*
object
.
Service
{
"kubedns.kube-system"
:
{
{
Name
:
"kubedns"
,
Namespace
:
"kube-system"
,
Type
:
api
.
ServiceTypeClusterIP
,
ClusterIPs
:
[]
string
{
"10.0.0.10"
},
Ports
:
[]
api
.
ServicePort
{
{
Name
:
"dns"
,
Protocol
:
"udp"
,
Port
:
53
},
},
},
},
"svc1.testns"
:
{
"svc1.testns"
:
{
{
{
Name
:
"svc1"
,
Name
:
"svc1"
,
...
@@ -673,6 +684,21 @@ func (APIConnServeTest) ServiceList() []*object.Service {
...
@@ -673,6 +684,21 @@ func (APIConnServeTest) ServiceList() []*object.Service {
}
}
var
epsIndex
=
map
[
string
][]
*
object
.
Endpoints
{
var
epsIndex
=
map
[
string
][]
*
object
.
Endpoints
{
"kubedns.kube-system"
:
{{
Subsets
:
[]
object
.
EndpointSubset
{
{
Addresses
:
[]
object
.
EndpointAddress
{
{
IP
:
"172.0.0.100"
},
},
Ports
:
[]
object
.
EndpointPort
{
{
Port
:
53
,
Protocol
:
"udp"
,
Name
:
"dns"
},
},
},
},
Name
:
"kubedns"
,
Namespace
:
"kube-system"
,
Index
:
object
.
EndpointsKey
(
"kubedns"
,
"kube-system"
),
}},
"svc1.testns"
:
{{
"svc1.testns"
:
{{
Subsets
:
[]
object
.
EndpointSubset
{
Subsets
:
[]
object
.
EndpointSubset
{
{
{
...
...
plugin/kubernetes/xfr.go
View file @
a1aafbf4
...
@@ -38,6 +38,17 @@ func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, erro
...
@@ -38,6 +38,17 @@ func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, erro
}
}
ch
<-
soa
ch
<-
soa
nsAddrs
:=
k
.
nsAddrs
(
false
,
zone
)
nsHosts
:=
make
(
map
[
string
]
struct
{})
for
_
,
nsAddr
:=
range
nsAddrs
{
nsHost
:=
nsAddr
.
Header
()
.
Name
if
_
,
ok
:=
nsHosts
[
nsHost
];
!
ok
{
nsHosts
[
nsHost
]
=
struct
{}{}
ch
<-
[]
dns
.
RR
{
&
dns
.
NS
{
Hdr
:
dns
.
RR_Header
{
Name
:
zone
,
Rrtype
:
dns
.
TypeNS
,
Class
:
dns
.
ClassINET
,
Ttl
:
k
.
ttl
},
Ns
:
nsHost
}}
}
ch
<-
nsAddrs
}
sort
.
Slice
(
serviceList
,
func
(
i
,
j
int
)
bool
{
sort
.
Slice
(
serviceList
,
func
(
i
,
j
int
)
bool
{
return
serviceList
[
i
]
.
Name
<
serviceList
[
j
]
.
Name
return
serviceList
[
i
]
.
Name
<
serviceList
[
j
]
.
Name
})
})
...
...
plugin/kubernetes/xfr_test.go
View file @
a1aafbf4
package
kubernetes
package
kubernetes
import
(
import
(
"net"
"strings"
"strings"
"testing"
"testing"
...
@@ -10,7 +11,8 @@ import (
...
@@ -10,7 +11,8 @@ import (
func
TestKubernetesAXFR
(
t
*
testing
.
T
)
{
func
TestKubernetesAXFR
(
t
*
testing
.
T
)
{
k
:=
New
([]
string
{
"cluster.local."
})
k
:=
New
([]
string
{
"cluster.local."
})
k
.
APIConn
=
&
APIConnServeTest
{}
k
.
APIConn
=
&
APIConnServeTest
{}
k
.
Namespaces
=
map
[
string
]
struct
{}{
"testns"
:
{}}
k
.
Namespaces
=
map
[
string
]
struct
{}{
"testns"
:
{},
"kube-system"
:
{}}
k
.
localIPs
=
[]
net
.
IP
{
net
.
ParseIP
(
"10.0.0.10"
)}
dnsmsg
:=
&
dns
.
Msg
{}
dnsmsg
:=
&
dns
.
Msg
{}
dnsmsg
.
SetAxfr
(
k
.
Zones
[
0
])
dnsmsg
.
SetAxfr
(
k
.
Zones
[
0
])
...
@@ -25,7 +27,8 @@ func TestKubernetesAXFR(t *testing.T) {
...
@@ -25,7 +27,8 @@ func TestKubernetesAXFR(t *testing.T) {
func
TestKubernetesIXFRFallback
(
t
*
testing
.
T
)
{
func
TestKubernetesIXFRFallback
(
t
*
testing
.
T
)
{
k
:=
New
([]
string
{
"cluster.local."
})
k
:=
New
([]
string
{
"cluster.local."
})
k
.
APIConn
=
&
APIConnServeTest
{}
k
.
APIConn
=
&
APIConnServeTest
{}
k
.
Namespaces
=
map
[
string
]
struct
{}{
"testns"
:
{}}
k
.
Namespaces
=
map
[
string
]
struct
{}{
"testns"
:
{},
"kube-system"
:
{}}
k
.
localIPs
=
[]
net
.
IP
{
net
.
ParseIP
(
"10.0.0.10"
)}
dnsmsg
:=
&
dns
.
Msg
{}
dnsmsg
:=
&
dns
.
Msg
{}
dnsmsg
.
SetAxfr
(
k
.
Zones
[
0
])
dnsmsg
.
SetAxfr
(
k
.
Zones
[
0
])
...
@@ -40,7 +43,8 @@ func TestKubernetesIXFRFallback(t *testing.T) {
...
@@ -40,7 +43,8 @@ func TestKubernetesIXFRFallback(t *testing.T) {
func
TestKubernetesIXFRCurrent
(
t
*
testing
.
T
)
{
func
TestKubernetesIXFRCurrent
(
t
*
testing
.
T
)
{
k
:=
New
([]
string
{
"cluster.local."
})
k
:=
New
([]
string
{
"cluster.local."
})
k
.
APIConn
=
&
APIConnServeTest
{}
k
.
APIConn
=
&
APIConnServeTest
{}
k
.
Namespaces
=
map
[
string
]
struct
{}{
"testns"
:
{}}
k
.
Namespaces
=
map
[
string
]
struct
{}{
"testns"
:
{},
"kube-system"
:
{}}
k
.
localIPs
=
[]
net
.
IP
{
net
.
ParseIP
(
"10.0.0.10"
)}
dnsmsg
:=
&
dns
.
Msg
{}
dnsmsg
:=
&
dns
.
Msg
{}
dnsmsg
.
SetAxfr
(
k
.
Zones
[
0
])
dnsmsg
.
SetAxfr
(
k
.
Zones
[
0
])
...
@@ -91,6 +95,8 @@ func validateAXFR(t *testing.T, ch <-chan []dns.RR) {
...
@@ -91,6 +95,8 @@ func validateAXFR(t *testing.T, ch <-chan []dns.RR) {
const
expectedZone
=
`
const
expectedZone
=
`
cluster.local. 5 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 3 7200 1800 86400 5
cluster.local. 5 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 3 7200 1800 86400 5
cluster.local. 5 IN NS ns.dns.cluster.local.
ns.dns.cluster.local. 5 IN A 10.0.0.10
external.testns.svc.cluster.local. 5 IN CNAME ext.interwebs.test.
external.testns.svc.cluster.local. 5 IN CNAME ext.interwebs.test.
external-to-service.testns.svc.cluster.local. 5 IN CNAME svc1.testns.svc.cluster.local.
external-to-service.testns.svc.cluster.local. 5 IN CNAME svc1.testns.svc.cluster.local.
hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.2
hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.2
...
@@ -113,6 +119,9 @@ hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::2
...
@@ -113,6 +119,9 @@ hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::2
_http._tcp.hdls1.testns.svc.cluster.local. 5 IN SRV 0 16 80 5678-abcd--2.hdls1.testns.svc.cluster.local.
_http._tcp.hdls1.testns.svc.cluster.local. 5 IN SRV 0 16 80 5678-abcd--2.hdls1.testns.svc.cluster.local.
hdlsprtls.testns.svc.cluster.local. 5 IN A 172.0.0.20
hdlsprtls.testns.svc.cluster.local. 5 IN A 172.0.0.20
172-0-0-20.hdlsprtls.testns.svc.cluster.local. 5 IN A 172.0.0.20
172-0-0-20.hdlsprtls.testns.svc.cluster.local. 5 IN A 172.0.0.20
kubedns.kube-system.svc.cluster.local. 5 IN A 10.0.0.10
kubedns.kube-system.svc.cluster.local. 5 IN SRV 0 100 53 kubedns.kube-system.svc.cluster.local.
_dns._udp.kubedns.kube-system.svc.cluster.local. 5 IN SRV 0 100 53 kubedns.kube-system.svc.cluster.local.
svc-dual-stack.testns.svc.cluster.local. 5 IN A 10.0.0.3
svc-dual-stack.testns.svc.cluster.local. 5 IN A 10.0.0.3
svc-dual-stack.testns.svc.cluster.local. 5 IN AAAA 10::3
svc-dual-stack.testns.svc.cluster.local. 5 IN AAAA 10::3
svc-dual-stack.testns.svc.cluster.local. 5 IN SRV 0 100 80 svc-dual-stack.testns.svc.cluster.local.
svc-dual-stack.testns.svc.cluster.local. 5 IN SRV 0 100 80 svc-dual-stack.testns.svc.cluster.local.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment