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
75a8a17d
Commit
75a8a17d
authored
Jan 06, 2018
by
Miek Gieben
Committed by
GitHub
Jan 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin/kubernetes: fix pod insecure mode (#1354)
Fixes #1331
parent
a8e268e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
plugin/backend.go
plugin/backend.go
+2
-2
plugin/kubernetes/handler_pod_insecure_test.go
plugin/kubernetes/handler_pod_insecure_test.go
+28
-0
plugin/kubernetes/kubernetes.go
plugin/kubernetes/kubernetes.go
+6
-0
No files found.
plugin/backend.go
View file @
75a8a17d
...
@@ -9,8 +9,8 @@ import (
...
@@ -9,8 +9,8 @@ import (
// ServiceBackend defines a (dynamic) backend that returns a slice of service definitions.
// ServiceBackend defines a (dynamic) backend that returns a slice of service definitions.
type
ServiceBackend
interface
{
type
ServiceBackend
interface
{
// Services communicates with the backend to retrieve the service definition. Exact indicates
// Services communicates with the backend to retrieve the service definition
s
. Exact indicates
// on exact m
uch are that we are allowed to recurs
.
// on exact m
atch should be returned
.
Services
(
state
request
.
Request
,
exact
bool
,
opt
Options
)
([]
msg
.
Service
,
error
)
Services
(
state
request
.
Request
,
exact
bool
,
opt
Options
)
([]
msg
.
Service
,
error
)
// Reverse communicates with the backend to retrieve service definition based on a IP address
// Reverse communicates with the backend to retrieve service definition based on a IP address
...
...
plugin/kubernetes/handler_pod_insecure_test.go
View file @
75a8a17d
...
@@ -25,6 +25,27 @@ var podModeInsecureCases = []test.Case{
...
@@ -25,6 +25,27 @@ var podModeInsecureCases = []test.Case{
test
.
A
(
"172-0-0-2.podns.pod.cluster.local. 5 IN A 172.0.0.2"
),
test
.
A
(
"172-0-0-2.podns.pod.cluster.local. 5 IN A 172.0.0.2"
),
},
},
},
},
{
Qname
:
"blah.podns.pod.cluster.local."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeNameError
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"
),
},
},
{
Qname
:
"blah.podns.pod.cluster.local."
,
Qtype
:
dns
.
TypeAAAA
,
Rcode
:
dns
.
RcodeNameError
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"
),
},
},
{
Qname
:
"blah.podns.pod.cluster.local."
,
Qtype
:
dns
.
TypeHINFO
,
Rcode
:
dns
.
RcodeNameError
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"
),
},
},
{
{
Qname
:
"blah.pod-nons.pod.cluster.local."
,
Qtype
:
dns
.
TypeA
,
Qname
:
"blah.pod-nons.pod.cluster.local."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeNameError
,
Rcode
:
dns
.
RcodeNameError
,
...
@@ -32,6 +53,13 @@ var podModeInsecureCases = []test.Case{
...
@@ -32,6 +53,13 @@ var podModeInsecureCases = []test.Case{
test
.
SOA
(
"cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"
),
test
.
SOA
(
"cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"
),
},
},
},
},
{
Qname
:
"podns.pod.cluster.local."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeNameError
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"
),
},
},
}
}
func
TestServeDNSModeInsecure
(
t
*
testing
.
T
)
{
func
TestServeDNSModeInsecure
(
t
*
testing
.
T
)
{
...
...
plugin/kubernetes/kubernetes.go
View file @
75a8a17d
...
@@ -321,6 +321,12 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
...
@@ -321,6 +321,12 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
if
!
wildcard
(
namespace
)
&&
!
k
.
namespace
(
namespace
)
{
// no wildcard, but namespace does not exist
if
!
wildcard
(
namespace
)
&&
!
k
.
namespace
(
namespace
)
{
// no wildcard, but namespace does not exist
return
nil
,
errNoItems
return
nil
,
errNoItems
}
}
// If ip does not parse as an IP address, we return an error, otherwise we assume a CNAME and will try to resolve it in backend_lookup.go
if
net
.
ParseIP
(
ip
)
==
nil
{
return
nil
,
errNoItems
}
return
[]
msg
.
Service
{{
Key
:
strings
.
Join
([]
string
{
zonePath
,
Pod
,
namespace
,
podname
},
"/"
),
Host
:
ip
,
TTL
:
k
.
ttl
}},
err
return
[]
msg
.
Service
{{
Key
:
strings
.
Join
([]
string
{
zonePath
,
Pod
,
namespace
,
podname
},
"/"
),
Host
:
ip
,
TTL
:
k
.
ttl
}},
err
}
}
...
...
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