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
353c1c64
Commit
353c1c64
authored
Feb 08, 2017
by
Chris O'Haver
Committed by
John Belamaric
Feb 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix k8s chaining (#510)
* fix k8s next middleware chaining * add chain to integration tests * if nit
parent
fa1c90a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
9 deletions
+40
-9
middleware/kubernetes/handler.go
middleware/kubernetes/handler.go
+10
-9
test/kubernetes_test.go
test/kubernetes_test.go
+30
-0
No files found.
middleware/kubernetes/handler.go
View file @
353c1c64
...
...
@@ -26,16 +26,17 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
// otherwise delegate to the next in the pipeline.
zone
:=
middleware
.
Zones
(
k
.
Zones
)
.
Matches
(
state
.
Name
())
if
zone
==
""
{
if
state
.
Type
()
==
"PTR"
{
// If this is a PTR request, and a the request is in a defined
// pod/service cidr range, process the request in this middleware,
// otherwise pass to next middleware.
if
!
k
.
IsRequestInReverseRange
(
state
)
{
return
middleware
.
NextOrFailure
(
k
.
Name
(),
k
.
Next
,
ctx
,
w
,
r
)
}
// Set the zone to this specific request.
zone
=
state
.
Name
()
if
state
.
Type
()
!=
"PTR"
{
return
middleware
.
NextOrFailure
(
k
.
Name
(),
k
.
Next
,
ctx
,
w
,
r
)
}
// If this is a PTR request, and the request is in a defined
// pod/service cidr range, process the request in this middleware,
// otherwise pass to next middleware.
if
!
k
.
IsRequestInReverseRange
(
state
)
{
return
middleware
.
NextOrFailure
(
k
.
Name
(),
k
.
Next
,
ctx
,
w
,
r
)
}
// Set the zone to this specific request.
zone
=
state
.
Name
()
}
var
(
...
...
test/kubernetes_test.go
View file @
353c1c64
...
...
@@ -225,6 +225,13 @@ var dnsTestCases = []test.Case{
test
.
TXT
(
"dns-version.cluster.local. 28800 IN TXT
\"
1.0.0
\"
"
),
},
},
{
Qname
:
"next-in-chain."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
A
(
"next-in-chain. 0 IN A 192.0.2.53"
),
},
},
}
var
dnsTestCasesPodsInsecure
=
[]
test
.
Case
{
...
...
@@ -282,6 +289,13 @@ var dnsTestCasesCidrReverseZone = []test.Case{
test
.
PTR
(
"115.0.0.10.in-addr.arpa. 303 IN PTR svc-c.test-1.svc.cluster.local."
),
},
},
{
Qname
:
"next-in-chain."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
A
(
"next-in-chain. 0 IN A 192.0.2.53"
),
},
},
}
var
dnsTestCasesPartialCidrReverseZone
=
[]
test
.
Case
{
...
...
@@ -313,6 +327,13 @@ var dnsTestCasesPartialCidrReverseZone = []test.Case{
Rcode
:
dns
.
RcodeServerFailure
,
Answer
:
[]
dns
.
RR
{},
},
{
Qname
:
"next-in-chain."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
A
(
"next-in-chain. 0 IN A 192.0.2.53"
),
},
},
}
var
dnsTestCasesAllNSExposed
=
[]
test
.
Case
{
...
...
@@ -409,6 +430,9 @@ func TestKubernetesIntegration(t *testing.T) {
namespaces test-1
pods disabled
}
erratic . {
drop 0
}
`
doIntegrationTests
(
t
,
corefile
,
dnsTestCases
)
}
...
...
@@ -445,6 +469,9 @@ func TestKubernetesIntegrationCidrReverseZone(t *testing.T) {
namespaces test-1
cidrs 10.0.0.0/24
}
erratic . {
drop 0
}
`
doIntegrationTests
(
t
,
corefile
,
dnsTestCasesCidrReverseZone
)
}
...
...
@@ -457,6 +484,9 @@ func TestKubernetesIntegrationPartialCidrReverseZone(t *testing.T) {
namespaces test-1
cidrs 10.0.0.96/28 10.0.0.120/32
}
erratic . {
drop 0
}
`
doIntegrationTests
(
t
,
corefile
,
dnsTestCasesPartialCidrReverseZone
)
}
...
...
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