Commit Graph

954 Commits

Author SHA1 Message Date
Miek Gieben
02955d7594 Dns.join (#944)
* Add dnsutil.Join

* Create dnsutil.Join

Create Join helper function and move bits in the code over.
2017-08-19 15:22:09 +01:00
Miek Gieben
7c343982a6 backend.Records make it take request.Request (#943)
This is more general and aligns well with the other methods.
Also allows the kubernetes middleware to use it.

Fixes #940
2017-08-19 14:03:03 +01:00
Miek Gieben
627687b11f mw/kubernetes: remove zone from parseRequest (#938)
* mw/kubernetes: remove zone from parseRequest

State has the zone info as well, so don't need to have it in
parseRequest anymore.

* Fix up tests

* improve test coverage
2017-08-19 07:18:35 +01:00
Miek Gieben
f96cf27193 mw/federation: add federation back as separate mw for k8s (#929)
* mw/federaration

This PR add the federation back as a middleware to keep it more
contained from the main kubernetes code.

It also makes parseRequest less import and pushes this functionlity down
in the k.Entries. This minimizes (or tries to) the importance for the
qtype in the query. In the end the qtype checking should only happen
in ServeDNS - but for k8s this might proof difficult.

Numerous other cleanup in code and kubernetes tests.

* up test coverage
2017-08-18 14:45:20 +01:00
Miek Gieben
cc4e4a0626 mw/autopath: integration test with erratic (#930)
Add integration test with erratic. For this erratic now also returns an
autopath searchpath. This tests the whole chain; i.e registring a
searchfunction and calling that from autopath.

This tests does a autopathing domain and a non-autopathing one.
2017-08-18 12:57:23 +01:00
Miek Gieben
5a1875120c mw/kubernetes: add reverse test case (#932)
Add a non-arpa testcase to the reverse test.
2017-08-17 18:42:14 +01:00
Miek Gieben
7f46df6d27 tests: add SortAndCheck helper (#926)
There was quite some code duplication in a lot of tests to check if
an answer was considered Ok. Created a test.SortAndCheck helper function
that takes care of this.
2017-08-16 15:30:58 +01:00
John Belamaric
65b56248f0 Remove use of hostnames in upstreams (#927)
Only IP:Port or file name is allowed.
2017-08-16 10:00:32 -04:00
Miek Gieben
06644c2855 mw/kubernetes: add reverse_test.go (#922)
This PR adds a reverse tests that copies some of it from the main
integration test. This aids in local testing because you don't need
a full k8s setup running.

It does the most minimal testing, a successful return and a nodata
response that includes the SOA for in-addr.arpa.
2017-08-16 07:33:35 +01:00
Miek Gieben
479c8bbaa9 Reverse in k8s (#923)
* mw/kubernetes: reverse zone in ZONE stanza not parsed

Properly parse the reverse zone syntax in the ZONES stanza as promised
in the README.

As short test case to test.

* add test
2017-08-16 07:29:46 +01:00
insomniac
1ab8b37e7e Make CoreDNS build on Go 1.7 (#919) 2017-08-14 13:51:18 -07:00
Miek Gieben
00f5c7797e mw/kubernetes: remove federation and cidr (#916)
* mw/kubernetes: remove federation and cidr

Remove both as we have a corefile syntax change that handles cidr and
remove federation because that is going to be its own middleware.

* backwards incompat changes

This PR:
* removes cidr from kubernetes (core Corefile feature now)
* removes federation from kubernets (comes back as new middleware)
* [remove autopath - which was already gone, so that already was
  backwards incompat]
* adds `fallthrough` to the *etcd* middleware and makes you enable it.
* Fail on unknown properties
* documentation
* Disable TestHealthCheck as it uses realtime and fails
2017-08-14 08:49:26 +01:00
Miek Gieben
818d2b10ad cidr everywhere: check all middleware (#915)
* cidr everywhere: check all middleware

Add tests for cidr in only that middleware that already tests for this.
Check the other ones manually (and put reverse in the tests cases
anyway).

Make etcd setup_test run without +build etcd tag - it is not needed
for this test - move rest of the code to lookup_test.go.

Cleanup proxy test a bit and remove TempDir as there is test.TempFile
that does the same thing.

Fixes #909

* coredns package

* Fix test compile
2017-08-13 18:16:25 +01:00
Yong Tang
0c02708d63 Consolidation of Makefile and Makefile.release (#912)
* Consolidation of Makefile and Makefile.release

Several changes:
1. All go specific target like `go generate`, etc. has
been moved to Makefile. Now Makefile.release does not
repeat go build, etc. related rules.
2. In Makefile.release, the binary build is done through
`docker run` and with a fixed specific go version (currently 1.8.3).
This will help making sure build process could be reproduced
on any dev platform, with no dependency to the golang version
installed on the platform.
3. Platform related flags (e.g., "GOOS=darwin") are passed through
Makefile (not Makefile.release).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Update to only use `make` without running inside `docker run`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-13 17:41:50 +01:00
Yong Tang
8d876c770c Use logo as the title of the README.md (#911)
The logo is pointing to https://coredns.io/images/CoreDNS_Colour_Horizontal.png
and provides the link to https://coredns.io

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-13 07:34:56 +01:00
Yong Tang
c0d435d4e8 Fix log output of the version string. (#910)
Split version string into two, before:
```
2017/08/12 19:43:08 [INFO] CoreDNS-010
linux/amd64, go1.8.3, a6d2d7b5
CoreDNS-010
linux/amd64, go1.8.3, a6d2d7b5
```
After:
```
root@9bd51ffc39aa:/go/src/github.com/coredns/coredns# ./coredns
.:53
2017/08/12 19:12:59 [INFO] CoreDNS-010
2017/08/12 19:12:59 [INFO] linux/amd64, go1.8, a6d2d7b
CoreDNS-010
linux/amd64, go1.8, a6d2d7b
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-12 20:59:28 +01:00
Yong Tang
a6d2d7b5f7 go lint cleanup (#904)
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-11 19:48:11 -07:00
Yong Tang
1ddafcbdff Makefile cleanup (#903)
Remove unused distclean and misc.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-11 19:47:28 -07:00
Yong Tang
a09f208c51 Add git commit to the version output. (#900)
Now the output would be:
```
 ./coredns -version
CoreDNS-010
linux/amd64, go1.8, 241e3db
```
In case the local file has been modified, then the output would be (with --dirty):
```
 ./coredns -version
CoreDNS-010
linux/amd64, go1.8, 241e3db-dirty
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-11 17:47:37 +01:00
Chris O'Haver
ebcbe66bbd Add Autopath section to k8s readme (#898)
The primary driver for autopath was kubernetes.  It addresses a specific need in kubernetes, so it deserves a mention in the K8s README, with an example.
2017-08-11 16:25:59 +01:00
Miek Gieben
241e3dbcb7 mw/k8s: cleanups (#893)
* mw/k8s: cleanups

Remove some constants that aren't used any more. Make PrimaryZone
private because it doesn't need to be exported. Remove test that
did not cover corner case as expressed in setup.go

* cleanup this as well
2017-08-11 16:21:07 +01:00
Chris O'Haver
028a6db4d6 README Typos (#897)
Found a few typos, spelling, and grammar errors.
2017-08-11 10:16:43 -04:00
Chris O'Haver
5468a6e162 Fix some typos in README (#896)
remove extraneous "]"s from the syntax def...
2017-08-11 10:16:24 -04:00
Miek Gieben
28b8a09240 Use server block defaults (#894)
* mw/k8s: Test Federation parsing

The test case was there, but there was nothing testing it?!?!?!
Add it and split it out of the main setup test which is too long
already.

Also allow kubernetes a not have a ZONE, just default to the serverblock
in that case. Remove test that was blocking that.

Cleanup up the readme more.

* rewrite README
2017-08-11 12:50:12 +01:00
Miek Gieben
6e91408f61 mw/k8s: use request.Request in parseRequest 2017-08-11 12:12:21 +01:00
Miek Gieben
b5d2a82ed7 mw/k8s: remove k.defaultNsMsg() (#892)
Remove k.defaultNSMsg() it is just one line of getting the service and
it is another method that needlessly uses recordRequest.
2017-08-11 08:34:35 +01:00
Yong Tang
c0f62e3f65 go lint cleanup (#891)
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-10 18:00:23 -07:00
Yong Tang
26d8680a11 Support multiple k8s api servers specification and load balance among api servers (#820)
* Support multiple k8s api servers specification and load balance among api servers

This fix adds supports for multiple k8s api servers specification,
load balance among api servers.

When two or more api servers are specified in kubernetes block (endpoint ...),
a proxy is created locally (with randomly generately port). The coredns
will points to the generated proxy so that load balancing could be achieved.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Setup initial healthcheck at the beginning

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Update README.md for kubernetes middleware and remove whitespaces.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Use middleware/pkg/healthcheck in middleware/kubernetes

for api proxy

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-10 17:14:56 -07:00
Miek Gieben
acfa6501e0 mw/k8s: remove dependence on global var (#888)
* mw/k8s: remove dependence on global var

Remove the global coreDNSRecord that was used. Remove tests the
referenced that var. Cleanup the rest.

* Rename function as well

* fixes
2017-08-10 23:13:08 +01:00
Miek Gieben
c65fdb5fc3 kw/middleware: compress the README (#889)
Remove the examples, save one in the syntax section. The example
section covers all.

This brings the kubernetes README inline with other READMEs.
2017-08-10 22:47:09 +01:00
Miek Gieben
a38a34c7e0 Kubernetes cleanup6 (#887)
* mw/kubernetes: handle dns.TypeNS better.

* mw/kubernetes: cleanup typeNS replies a bit.
2017-08-10 22:14:19 +01:00
Miek Gieben
ea77f2a2ca core: replace GetMiddleware (#885)
* core: replace GetMiddleware

See the discussion in #881. GetMiddleware would add a `nil` middleware
to the callstack thereby breaking functionality.

This PR drops it in favor of RegisterHandler which is a completely
standalone registry for middleware that want to let it self know to
other middleware.

Currenly *autopath* uses this to call *kubernetes*'s AutoPath method
for dynamic autopathing.

* Drop GetMiddleware

* Register metrics

* drop the panic
2017-08-10 21:31:36 +01:00
Miek Gieben
10681c6bf0 mw/kubernetes: remove subzones (#878)
Only use was in k8s middleware; no tests other than subzone_test.go
existed; not exercised: remove.
2017-08-10 20:53:15 +01:00
Miek Gieben
4d0dae8deb middleware/autopath: some fixes (#883)
* middleware/autopath: some fixes

This fix a small issue in autopath, but unearthed a bigger one.
See #881.

* Fix test
2017-08-10 19:27:54 +01:00
Miek Gieben
6cc3f47d46 middleware/authpath: Fix return from k8s mw (#871)
* middleware/authpath: Fix return from k8s mw

Return the correct search path from the kubernetes' AutoPath function.
Based on preliminary discussion in #870

* PodWithIP can be private

Fix and add docs to functions.

* CR: remove the error from AutoPathFunc
2017-08-10 19:26:31 +01:00
Miek Gieben
3654361be2 core: small cleanup (#877)
Add some docs about normalize.Host and normalize.Name. They are used
correctly in the middleware even though they are somewhat confusing,
esp when you copy from ServerBlockKeys in your middleware.
2017-08-10 05:30:18 -07:00
Miek Gieben
28447234b1 mw/kubernetes: fix parseTests (#875)
* mw/kubernetes: fix parseTests

Make parse tests table driven to remove a duplicate code, i.e. most
of the contents of parse_test.go can be removed as well as the
expectString helper function.

* cleanup parse tests
2017-08-10 02:23:27 -07:00
Miek Gieben
7e56cc74e5 WIP: Parserequest2 cutback (#868)
* middleware/kubernetes: pull TXT out of parseRequest

Put the TXT handling one layer higher and remove it from parseRequest.
Also rename the podsvc field in there to podOrSvc. Now that it isn't
used anymore for TXT record (dns-version) that was put in there. We can
make this a boolean (in a future PR).

Make parseRequest get an optional Zone that is from state.Zone and use
that instead of its own code. Removed some tests and other smaller
cleanups.

Fixes #836

* add this reverse

* another check

* readd

* Rename to kPod and kService for some clarity
2017-08-10 01:08:58 -07:00
Yong Tang
fefc4374d7 Some go vet cleanup (#869)
Some `go vet` cleanup

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-09 11:00:03 -07:00
Yong Tang
654d127a24 Change the style from flat to regular for consistency. (#866)
The current badge styles have 4 flat and 1 regular, which were
rather inconsistent. This fix changes to one style and matches
with Caddy.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-09 09:58:32 -07:00
Yong Tang
a1b175ef78 Move Healthcheck to middleware/pkg/healthcheck (#854)
* Move healthcheck out

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Move healthcheck to middleware/pkg/healthcheck

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-09 09:21:33 -07:00
Yong Tang
57692bbccf Change Travis status to only show master branch status. (#865)
So that pull request build failure does not impact project status.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-09 09:04:49 -07:00
Miek Gieben
df1879f9ae middleware/kubernetes: put reverse function in own file (#863)
Move reverse function and (some) test code to reverse*.go
2017-08-09 05:18:46 -07:00
Miek Gieben
be037a32a5 mw/kubernetes: restore handler to pre-autopath state (#861)
Pull in the contents of routeRequest as it is only called once.
2017-08-09 04:09:37 -07:00
Miek Gieben
b8e2c476a5 mw/authpath: hook in kubernetees (#860)
Call out to kubernetes to get the search path - this still needs
to return something sensible, but all infrastructure has landed
to make it work.
2017-08-09 04:06:48 -07:00
Miek Gieben
b46b9880bd WIP: autopath as middleware (#859)
autopath as middleware
2017-08-09 03:13:38 -07:00
Miek Gieben
c3705ec68c mw/kubernetes: warn about deprecating cidr (#858)
Add log statement pointing to replacement.
remove cidr from README and use replacement syntax.

Fixes #851
2017-08-08 05:05:34 -07:00
Miek Gieben
be551f21a0 core: add missing trimzone files
*ugh*: forgot to add these files. This add the dnsutil.TrimZone
function.
2017-08-08 11:33:51 +00:00
Miek Gieben
7ed44cb6ce core: add Zone in request.Request (#857)
Add a Zone field in request.Request and a dnsutil.Trimzone help
function.
2017-08-08 04:23:16 -07:00
James Mills
fbf135d265 Fix build error with incorrect arguments to SetDo() (#856) 2017-08-08 01:29:54 -07:00