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
7c45f022
Commit
7c45f022
authored
Jan 15, 2017
by
John Belamaric
Committed by
GitHub
Jan 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #482 from chrisohaver/k8s_spec_txt
Add txt response per k8s spec
parents
52e01264
2d0b8293
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
middleware/kubernetes/kubernetes.go
middleware/kubernetes/kubernetes.go
+30
-4
test/kubernetes_test.go
test/kubernetes_test.go
+7
-0
No files found.
middleware/kubernetes/kubernetes.go
View file @
7c45f022
...
...
@@ -46,6 +46,7 @@ type Kubernetes struct {
const
(
PodModeDisabled
=
"disabled"
// default. pod requests are ignored
PodModeInsecure
=
"insecure"
// ALL pod requests are answered without verfying they exist
DnsSchemaVersion
=
"1.0.0"
// https://github.com/kubernetes/dns/blob/master/docs/specification.md
)
type
endpoint
struct
{
...
...
@@ -82,8 +83,28 @@ func (k *Kubernetes) Services(state request.Request, exact bool, opt middleware.
if
e
!=
nil
{
return
nil
,
nil
,
e
}
switch
state
.
Type
()
{
case
"A"
,
"SRV"
:
s
,
e
:=
k
.
Records
(
r
)
return
s
,
nil
,
e
// Haven't implemented debug queries yet.
case
"TXT"
:
s
,
e
:=
k
.
recordsForTXT
(
r
)
return
s
,
nil
,
e
}
return
nil
,
nil
,
nil
}
func
(
k
*
Kubernetes
)
recordsForTXT
(
r
recordRequest
)
([]
msg
.
Service
,
error
)
{
switch
r
.
typeName
{
case
"dns-version"
:
s
:=
msg
.
Service
{
Text
:
DnsSchemaVersion
,
TTL
:
28800
,
Key
:
msg
.
Path
(
r
.
typeName
+
"."
+
r
.
zone
,
"coredns"
)}
return
[]
msg
.
Service
{
s
},
nil
}
return
nil
,
nil
}
// PrimaryZone will return the first non-reverse zone being handled by this middleware
...
...
@@ -253,6 +274,11 @@ func (k *Kubernetes) parseRequest(lowerCasedName, qtype string) (r recordRequest
return
r
,
nil
}
if
len
(
segs
)
==
1
&&
qtype
==
"TXT"
{
r
.
typeName
=
segs
[
0
]
return
r
,
nil
}
return
r
,
errors
.
New
(
"invalid request"
)
}
...
...
test/kubernetes_test.go
View file @
7c45f022
...
...
@@ -218,6 +218,13 @@ var dnsTestCases = []test.Case{
test
.
PTR
(
"115.0.0.10.in-addr.arpa. 303 IN PTR svc-c.test-1.svc.cluster.local."
),
},
},
{
Qname
:
"dns-version.cluster.local."
,
Qtype
:
dns
.
TypeTXT
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
TXT
(
"dns-version.cluster.local. 28800 IN TXT
\"
1.0.0
\"
"
),
},
},
}
var
dnsTestCasesPodsInsecure
=
[]
test
.
Case
{
...
...
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