Commit graph

48 commits

Author SHA1 Message Date
Chris O'Haver
51c05679e6
plugin/kubernetes: Add support for dual stack ClusterIP Services (#4339)
* support dual stack clusterIPs

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* stickler

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* fix ClusterIPs make

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-12-21 02:30:24 -08:00
Chris O'Haver
272ccb195d
plugin/kubernetes: Watch EndpointSlices (#4209)
* initial commit

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* convert endpointslices to object.endpoints

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* add opt hard coded for now

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* check that server supports endpointslice

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* fix import grouping

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* dont use endpoint slice in 1.17 or 1.18

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* bump kind/k8s in circle ci to latest

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* drop k8s to latest supported by kind

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* use endpointslice name as endoint Name; index by Service name

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* use index key comparison in nsAddrs()

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* add Index to object.Endpoint fixtures; fix direct endpoint name compares

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* add slice dup check and test

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* todo

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* add ep-slice skew dup test for reverse

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* nsaddrs: de-dup ep-slice skew dups; add test

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* remove todo

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* address various feedback

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* consolidate endpoint/slice informer code

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* fix endpoint informer consolidation; use clearer func name

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* log info; use major/minor fields

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* fix nsAddr and unit test

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* add latency tracking for endpointslices

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* endpointslice latency unit test & fix

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* code shuffling

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* rename endpointslices in tests

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* remove de-dup from nsAddrs and test

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* remove de-dup from findServices / test

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-10-30 08:14:30 -04:00
Yong Tang
9798dd067f
Cherry-pick: Implement notifies for transfer plugin (#3972) (#4142)
* Implement notifies for transfer plugin (#3972)

* Fix notifies in transfer plugin

Signed-off-by: Miek Gieben <miek@miek.nl>

* Make it compile

Signed-off-by: Miek Gieben <miek@miek.nl>

* Port more plugins

Signed-off-by: Miek Gieben <miek@miek.nl>

* golint

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix notifies in transfer plugin

Signed-off-by: Miek Gieben <miek@miek.nl>

* Make it compile

Signed-off-by: Miek Gieben <miek@miek.nl>

* Port more plugins

Signed-off-by: Miek Gieben <miek@miek.nl>

* golint

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>

* really fix test

Signed-off-by: Miek Gieben <miek@miek.nl>

* Implement ixfr fallback and unify file and auto for transfering

Signed-off-by: Miek Gieben <miek@miek.nl>

* Add transfer tests

copied and modified from #3452

Signed-off-by: Miek Gieben <miek@miek.nl>

* Test correct selection of plugin

Signed-off-by: Miek Gieben <miek@miek.nl>

* add upstream back in

Signed-off-by: Miek Gieben <miek@miek.nl>

* Implement ixfr fallback and unify file and auto for transfering

Signed-off-by: Miek Gieben <miek@miek.nl>

* fix test

Signed-off-by: Miek Gieben <miek@miek.nl>

* properly merge

Signed-off-by: Miek Gieben <miek@miek.nl>

* Remove plugin/kubernetes/setup_transfer_test.go

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

Co-authored-by: Miek Gieben <miek@miek.nl>
2020-09-24 20:30:39 +02:00
Yong Tang
614d08cba2
Revert "Implement notifies for transfer plugin (#3972)" (#3995)
This reverts commit 68f1dd5ddf.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2020-07-08 09:00:26 -07:00
Miek Gieben
68f1dd5ddf
Implement notifies for transfer plugin (#3972)
* Fix notifies in transfer plugin

Signed-off-by: Miek Gieben <miek@miek.nl>

* Make it compile

Signed-off-by: Miek Gieben <miek@miek.nl>

* Port more plugins

Signed-off-by: Miek Gieben <miek@miek.nl>

* golint

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix notifies in transfer plugin

Signed-off-by: Miek Gieben <miek@miek.nl>

* Make it compile

Signed-off-by: Miek Gieben <miek@miek.nl>

* Port more plugins

Signed-off-by: Miek Gieben <miek@miek.nl>

* golint

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>

* really fix test

Signed-off-by: Miek Gieben <miek@miek.nl>

* Implement ixfr fallback and unify file and auto for transfering

Signed-off-by: Miek Gieben <miek@miek.nl>

* Add transfer tests

copied and modified from #3452

Signed-off-by: Miek Gieben <miek@miek.nl>

* Test correct selection of plugin

Signed-off-by: Miek Gieben <miek@miek.nl>

* add upstream back in

Signed-off-by: Miek Gieben <miek@miek.nl>

* Implement ixfr fallback and unify file and auto for transfering

Signed-off-by: Miek Gieben <miek@miek.nl>

* fix test

Signed-off-by: Miek Gieben <miek@miek.nl>

* properly merge

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-07-07 12:38:07 -07:00
Yong Tang
ebbfffaf9d
Update k8s.io/[api|apimachinery|client-go] to v0.18.0 (#3796)
* Update k8s.io/[api|apimachinery|client-go] to v0.18.0

This PR updates k8s.io/[api|apimachinery|client-go] to v0.18.0

This PR closes 3791
This PR closes 3792
This PR closes 3793

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

* Fix test failures

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

* Fix failed tests

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

* Fix test failure

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2020-03-30 11:10:41 -07:00
Antonio Ojea
e1cf9ccdab Bump kubernetes plugin schema version (#3554)
The Kubernetes DNS specification schema version was
updated to 1.1.0 in order to support IPv6

Signed-off-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
2019-12-19 09:34:03 -05:00
Guangming Wang
081e45afa3 cleanup: remove redundant return statement (#3297)
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-09-23 14:40:14 +01:00
Chris O'Haver
a64ff8cc0a fix NXDOMAIN/NODATA fallthough case (#3118) 2019-08-12 18:43:22 +00:00
Chris O'Haver
3a59c833a0 plugin/kubernetes: Don't do a zone transfer for NS requests (#3098)
* fix switch order

* remove fallthough

* add test

* fix test

* distingush nxdomain/nodata for at least first subdomain of zone

* restore fallthough; reorder switch cases
2019-08-09 21:14:48 +00:00
John Belamaric
ffcd2f61cf Publish metadata from kubernetes plugin (#2829)
* Publish metadata from kubernetes plugin

* stickler fix

* Add a couple tests

* Add metadata section to README

* Update plugin/kubernetes/README.md

Co-Authored-By: Chris O'Haver <cohaver@infoblox.com>

* Address nit
2019-06-09 08:10:57 +01:00
Matt Greenfield
a3dd8cdf8d Add namespace_labels configuration for kubernetes plugin (#2707) 2019-03-22 14:32:40 +00:00
Sandeep Rajan
d42d80c4f6 cleanup by fmt and remove redundant type declarations (#2563) 2019-02-17 08:32:28 +00:00
Miek Gieben
29cb00aada
Remove grpc watch functionality (#2549)
This was added, but didn't see any use. For a large, complex chunk of
code we should have some users of it.

Remove all watch functionally from plugins, servers and packages.

Fixes: #2548

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-02-11 14:46:53 +00:00
Miek Gieben
725becd134
Stop importing testing in the main binary (#2479)
* Stop importing testing in the main binary

Stop importing "testing" into the main binary:

* test/helpers.go imported it; remote that and change function signature
* update all tests that use this

Signed-off-by: Miek Gieben <miek@miek.nl>

* Drop import testing from metrics plugin

Signed-off-by: Miek Gieben <miek@miek.nl>

* more fiddling

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-19 11:23:13 +00:00
Chris O'Haver
22cacc7cb1 fix soa min ttl in tests cases (#2451) 2019-01-10 15:49:53 +00:00
Chris O'Haver
875c11a0cb set minttl to ttl setting (#2446) 2019-01-10 07:34:22 +00:00
Miek Gieben
95546dfdfe plugin/kubernetes: smaller map (#2383)
* plugin/kubernetes: smaller map

to continue with a theme: the map[string]bool can be reduced
to map[string]struct{} to reduce a tiny amount of memory.

Signed-off-by: Miek Gieben <miek@miek.nl>

* fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-08 15:40:07 -08:00
stuart nelson
8dbe1fbee2 Set SOA record TTL as min of TTL/MINIMUM (#2295)
* Set SOA record TTL as min of TTL/MINIMUM

According to
https://tools.ietf.org/html/rfc2308#section-3:

  The TTL of this record is set from the minimum
  of the MINIMUM field of the SOA record and the
  TTL of the SOA itself, and indicates how long a
  resolver may cache the negative answer.

Set the TTL accordingly so as to not always
negative cache SOA records for 300 seconds.

* Inline min func

* Update SOA record tests

* Fix types
2018-11-16 08:42:49 -05:00
Kevin Nisbet
6539a10a62 Unblock startup if kubernetes API is unavailable (#2126) 2018-10-22 09:30:08 -04:00
Miek Gieben
6ed88fab74 Revert "use keys (#2167)" (#2188)
This reverts commit 974ed086f2.
2018-10-11 16:59:50 -04:00
Chris O'Haver
974ed086f2 use keys (#2167) 2018-10-10 12:28:45 -07:00
Miek Gieben
830e97f800
plugin/kubernetes: allow trimming down of cached items. (#2128)
* Convert to runtime.Object to smaller structs

This adds conversion for all the objects we want to keep in the cache.
It keeps the minimum for CoreDNS to function and throws away the rest.

The conversion:
api.Endpoints -> object.Endpoints
api.Pod       -> object.Pod
api.Serivce   -> object.Service

We needed to copy some client-go stuff to insert a conversion function
into NewIndexInformers.

Some unrelated cleanups in the watch functionality as that needed to be
touched because of the above translation of objects.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Reduce test line-count

Signed-off-by: Miek Gieben <miek@miek.nl>

* ....and fix test

Signed-off-by: Miek Gieben <miek@miek.nl>

* Drop use of append

Signed-off-by: Miek Gieben <miek@miek.nl>

* cosmetic changes

Signed-off-by: Miek Gieben <miek@miek.nl>

* that was a typo

Signed-off-by: Miek Gieben <miek@miek.nl>

* re-introduce append here

We can't really use len() here because we don't know the number before
hand.

Signed-off-by: Miek Gieben <miek@miek.nl>

* comment in better place

Signed-off-by: Miek Gieben <miek@miek.nl>

* Make the timestamp a bool; thats where it is used for

Signed-off-by: Miek Gieben <miek@miek.nl>

* Set incoming object to nil

Explicataliy discard the converted object; we did a deep copy it's
not needed anymore.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Per Chris's comment

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-10-09 21:56:09 +01:00
Chris O'Haver
e6ef320d13 handle blank name and namespaces (#2042) 2018-08-27 19:41:04 +01:00
Chris O'Haver
444472891f
plugin/kubernetes: dont transfer unexposed namespaces (#2044)
dont transfer unexposed namespaces
2018-08-27 10:38:49 -04:00
Chris O'Haver
d60993e021
plugin/kubernetes: Create records for portless services (#2052)
inject sentinels for portless services
2018-08-27 10:10:51 -04:00
Bingshen Wang
75f1b9c988 fix kubernetes in-cluster CNAME lookup (#2040)
fix #2038

Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
2018-08-25 08:53:41 -04:00
John Belamaric
99287d091c
Watch feature (#1527)
* Add part 1 watch functionality. (squashed)

* add funcs for service/endpoint fqdns

* add endpoints watch

* document exposed funcs

* only send subset deltas

* locking for watch map

* tests and docs

* add pod watch

* remove debugs prints

* feedback part 1

* add error reporting to proto

* inform clients of server stop+errors

* add grpc options param

* use proper context

* Review feedback:
 * Removed client (will move to another repo)
 * Use new log functions
 * Change watchChan to be for string not []string
 * Rework how k8s plugin stores watch tracking info to simplify
 * Normalize the qname on watch request

* Add blank line back

* Revert another spurious change

* Fix tests

* Add stop channel.
Fix tests.
Better docs for plugin interface.

* fmt.Printf -> log.Warningf

* Move from dnsserver to plugin/pkg/watch

* gofmt

* remove dead client watches

* sate linter

* linter omg
2018-06-27 07:45:32 -07:00
darkweaver87
003e104fca ADD ignoreemptyservice option for kubernetes plugin (#1813)
* ADD: ignoreemptyservice option for kubernetes plugin

* Modify documentation and rename option to add space

* UPD: Add unit tests

* UPD: gofmt

* Add unit test for ignore emptyservice

* gofmt

* xfr tests failed

* Rename emptyservice to empty_service
2018-05-23 08:57:59 -04:00
Yong Tang
67c9075331 Enforcing gofmt -s on linter check (#1820)
This fix enforces gofmt -s on linter check in Makefile,
and fixes `plugin/kubernetes/handler_test.go` and
`plugin/tls/tls_test.go` with `gofmt -s`
2018-05-21 09:52:42 -04:00
Chris O'Haver
38e27fd9ad add dup endpoint name test (#1811) 2018-05-18 07:27:25 +01:00
Miek Gieben
0930eb8beb
all: fix plugin import ordering (#1717)
Got a bit messed up with stb lib "context" usage.
2018-04-22 08:34:35 +01:00
Miek Gieben
8722336fff
global: move to context (#1699)
* global: move to context

Move from golang.org/x/net/context to std lib's context.

Change done with:

for i in $(grep -l '/context' **/*.go); do sed -e 's|golang.org/x/net/context|context|' -i $i; echo $i; done
for i in **/*.go; do goimports -w $i; done

* drop from dns.pb.go as well
2018-04-20 11:01:06 +01:00
Chris O'Haver
51e1442bd9
plugin/kubernetes: check for bare zone query (#1692)
* check for bare zone query

* check for bare type query
2018-04-18 12:12:28 -04:00
Brad Beam
6fd954f19c support for zone transfer for kubernetes (#1259)
* plugin/kubernetes: axfr

Hook up dynamic SOA serial by setting ResourceEventHandlerFuncs in
dnsController.

Add prototype of returns msg.Services via the Transfer function. Leave
expanding this to RRs out of scope for a bit.

* plugin/kubernetes: axfr

Respond to AXFR queries

* Fixing race condition

* Fixing instantiation of dnstest writer

* Updates from review
2018-02-08 16:11:04 +00:00
Miek Gieben
a91cd9c428
plugin/kubernetes: add explicit non-existing ns check (#1350)
We already do the right thing here, but add a test none-the-less.
2018-01-05 17:53:26 +00:00
Yong Tang
7fe5b0bb1f Update k8s client-go to v6.0.0 (#1340)
* Update k8s client-go to v6.0.0

This fix updates k8s client-go to v6.0.0 as CoreDNS is supported
in 1.9 and v6.0.0 is the recommended version.

There are quite some massive changes that need to be made:
1. k8s.io/client-go/pkg/api/v1 has been changed to k8s.io/api/v1 (repo changed from `client-go` to `api`)
2. kubernetes.Clientset adds one extra layer, so that `kubernetes.Clientset.Services()` and like has been changed to `kubernetes.Clientset.CoreV1().Services()`

Also, we have to stick with specific commits of `k8s.io/apimachinery` and the newly introduced `k8s.io/api`
because go dep still could not figure out the right version to fetch.

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

* Update vendor with `dep ensure --update` and `dep prune`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-01-03 11:11:28 +00:00
Yong Tang
ba4e77672c Fix a couple of typos (#1316)
`hanlder` -> `handler`

`bounderies` -> `boundaries`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-12-15 21:31:57 +00:00
Brad Beam
cee6f60ab8 Adding additional records for test cases (#1304) 2017-12-14 14:14:10 -05:00
Chris O'Haver
614ed4c80d fix external service type check (#1246) 2017-11-22 11:17:27 +00:00
Miek Gieben
70a5a098c1
plugin/kubernetes: Fix reverse TTL response (#1240)
Remove most 303 TTLs (those get skipped by the test) and use 5, which is
the default for all tests.
2017-11-15 15:04:17 +00:00
Chris O'Haver
99dd8f99f3 plugin/k8s: clean up and add some ipv6 tests (#1237)
* clean up and add some ipv6 tests

* aaaa endpoint

* gofmt
2017-11-15 07:16:04 +00:00
Miek Gieben
c37bf56b1e
plugin/kubernetes: correctly set NODATA for ns (#1229)
* plugin/kubernetes: Add GetNamespaceByName

A bare or wildcard query for just the namespace should return NODATA,
not NXDOMAIN, otherwise we deny the entirety of the names under the
namespace.

Add test to check for this in pod verified mode.

* Review

More comments and move namespace code to namespace.go
2017-11-13 21:51:51 +00:00
Miek Gieben
d64b684831 plugin/kubernetes: implement HasSynced() (#1155)
* plugin/kubernetes: wait until api is ready

Wait for HasSynced before allowing startup to avoid startup race.

Also do a small refactor in findServices() to pull a check out of the
loop - only needs to be done once.

* sigh
2017-10-20 22:53:17 +01:00
Sandeep Rajan
b6b05eae8f Plugin/Kubernetes: Service and Endpoint Indexing (#1149)
* indexing

* corrections
2017-10-17 21:30:54 -04:00
Chris O'Haver
4b3a430ff2 plugin/kubernetes: Enable protobuf, Update client api package (#1114)
* vendor

* code
2017-09-29 15:58:50 -04:00
Miek Gieben
284061eee7 pkg: add dnstest (#1098)
Add a full test server impl in this new package + tests. Move
dnsrecorder into this package as well and finish up the commented out
tests that were left in the old dnsrecorder package.

Update all callers and tests.
2017-09-21 15:15:47 +01:00
Miek Gieben
d8714e64e4 Remove the word middleware (#1067)
* Rename middleware to plugin

first pass; mostly used 'sed', few spots where I manually changed
text.

This still builds a coredns binary.

* fmt error

* Rename AddMiddleware to AddPlugin

* Readd AddMiddleware to remain backwards compat
2017-09-14 09:36:06 +01:00
Renamed from middleware/kubernetes/handler_test.go (Browse further)