Commit graph

47 commits

Author SHA1 Message Date
Ondřej Benkovský
c2dbb7141a
add golangci-lint linter (#5499) 2022-07-10 11:06:33 -07:00
Chris O'Haver
e80d696502
plugin/k8s_external: Add support for PTR requests (#5435)
* Exclude External IP addresses from being added to the existing kubernetes' plugin IP->Service index
* Add support for PTR requests on External IPs of Services to the k8s_external plugin

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-07-06 13:55:15 -04:00
Chris O'Haver
7263808fe1
plugin/k8s_external: implement zone transfers (#4977)
Implement transfer for k8s_external. Notifies not supported.

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-03-07 12:16:24 -05:00
Mat Lowery
9d5b8cd13d
kubernetes: Improve namespace usage (#4767)
* Use GetByKey instead of List in GetNamespaceByName.
* Add ToNamespace to reduce memory for namespace cache.

Signed-off-by: Mat Lowery <mlowery@ebay.com>
2021-07-29 23:27:25 -04:00
Jeongwook Park
faa10f61af
Fix typo on kubernetes plugin (#4753)
- modifed -> modified

Signed-off-by: jeongwook-park <jeongwook.park@navercorp.com>
2021-07-14 14:29:41 -04:00
mfleader
38e409b4b6
Correct newdnsController's documented function signature (#4717)
Signed-off-by: mleader <mleader@redhat.com>
2021-06-24 15:18:08 -04:00
Chris O'Haver
24547447d0
plugin/kubernetes: Support both v1 and v1beta1 EndpointSlices (#4570)
* support v1 and v1beta1 endpointslice

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

* update comments

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-05-10 09:57:23 -07:00
Chris O'Haver
9f72db12e7
plugin/kubernetes: do endpoint/slice check in retry loop (#4492)
* do endpoint/slice check in retry loop

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-03-26 08:54:39 -04:00
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
9121e78496
plugin/kubernetes: Fix dns programming duration metric (#4255)
* get data reqd to record latency before calling toFuncs
* refactor out unnecessary toFunc wrappers
* remove latency metric unit tests per PR feedback

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-12-01 15:29:05 -05: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
Chris O'Haver
d902e85919
plugin/kubernetes: fix tombstone unwrapping (#3924)
* fix tombstone unwrapping

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-06-15 10:15:41 -04:00
Chris O'Haver
bb7ee5010e
plugin/kubernetes: Handle endpoint tombstones (#3887)
* check for nil

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

* handle tombstone

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

* move casting to caller. add comments.

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

* more sanding

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

* more scrubbing

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

* move object unwraping to switch cases

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

* oops remove debug

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

* remove cruft

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-05-14 12:39:40 -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
janluk
d7cdb992b4 Measure and expose DNS programming latency from Kubernetes plugin. (#3171)
For now metric is measure only for headless services. Informer has been slighlty
refactored, so the code can measure latency without storing extra fields on
Endpoint struct.

Signed-off-by: Janek Łukaszewicz <janluk@google.com>

Suggestions from code review

Co-Authored-By: Chris O'Haver <cohaver@infoblox.com>
2019-10-04 16:48:43 +01:00
Anshul Sharma
f9fb9db171 ISSUE-2911 (#2923)
- Remove resyncperiod from Kubernetes plugin
2019-07-03 20:39:12 +01:00
Andras Spitzer
7dde3f3958 Fix for #2842, instead of returning the first Pod, return the one whi… (#2846)
* Fix for #2842, instead of returning the first Pod, return the one which is Running

* a more memory efficient version of the fix, string -> bool

* fix with no extra fields in struct, return nil at Pod conversion if Pod is not Running

* let Kuberneretes filter for Running Pods using FieldSelector

* filter for Pods that are Running and Pending (implicit)
2019-05-29 08:06:45 +01:00
Miek Gieben
58c703f5ef
Run gofmt -w -s on codebase (#2773)
This formats and simplifies all code by running gofmt -w -s on all Go
files.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-04-08 11:13:46 +01:00
Chris O'Haver
f6eb2a4c14 restore change detection (#2696) 2019-03-26 15:26:19 +00:00
Matt Greenfield
a3dd8cdf8d Add namespace_labels configuration for kubernetes plugin (#2707) 2019-03-22 14:32:40 +00:00
Nguyen Quang Huy
8d09cb243f Fix some typos (#2560)
* Fix some typos

Corect some words for reading more easily

* Update NOERROR response code

NOERROR is a response code so I revert the typo checking for it
2019-02-17 08:31:12 +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
c1c98924c3
Add new plugin: external - resolve k8s ingress and LB address with external names (#2379)
* Add new plugin: external

This plugin works in conjunction with the kubernetes plugin and exports
ingress and LB addresses as DNS records. It bypasses backend.go and
backend_lookup.go flow because it is not needed.

README, tests are implemented. The tests only exercise the unit tests,
this has not been tested in any ci.

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

* Rename to k8s_external

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

* go gen

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-14 09:41:51 +00:00
Miek Gieben
a044499545
kubernetes: fix the type (#2208)
client-go is a "empty interface" waste-land and we're missing an
integration test so we didn't catch. Try this.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-10-17 19:35:00 +01: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
Brad Beam
a80ec6096f Benchmark for k8s services (#2107)
* Benchmark for k8s services

* Adding k8s.io/client-go/kubernetes/fake dep
2018-09-29 16:43:09 +01:00
Miek Gieben
6f966eed41
plugin/kubernetes: use struct{} was map values (#2125)
This takes less space than a bool, the value isn't used for anything
else than "present in map" any way.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-09-22 18:13:33 +01:00
Miek Gieben
f98db6b637 plugin/kubernetes: remove unnecessary checks (#2124)
These checks are not needed and also use a var for all obj errors.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-09-22 08:54:06 -07:00
Miek Gieben
79eec38afd
plugin/kubernetes: remove var namespace (#2122)
* WIP: trying stuff out

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

* Fixes

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

* Revert "WIP: trying stuff out"

This reverts commit a18a6ae123.
2018-09-22 16:08:21 +01:00
Miek Gieben
9546b606cb
K8s remove string ops (#2119)
* plugin/kubernetes: remove bunch a string ops

This removes a bunch of appends to where not needed, makes dnsutil.Join
take variadic args which removes the need to wrap in a new string slice.

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

* Fix calls to dnsutil.Join

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

* Revert these

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-09-22 15:12:02 +01: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
Chris O'Haver
9719a47c1b plugin/kubernetes: Add noendpoints option (#1536)
* add noendpoints option

* go fmt
2018-02-16 11:05:52 -05:00
Chris O'Haver
dfd72e440f plugin/kubernetes: add namespace watch (#1533)
* add namespace watch

* start ns watch, and add sync check
2018-02-15 14:21:54 -05:00
John Belamaric
bd156dc9d1 Stop noisy modifications (#1517)
* Stop noisy modifications

* Review comments, tests

* More coverage

* vet

* Make it obvious new port name is not a typo
2018-02-09 22:32:52 +00: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
Ilya Galimyanov
1e75061aec Remove pointers to labels.Selector and pass normally instead (#1422) 2018-01-24 20:44:18 +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
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
Chris O'Haver
9b8ee1c119
plugin/k8s: fix endpoint index creation (#1222) 2017-11-10 15:38:45 -05: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
John Belamaric
6f19dda0b4 Fix autopath crash when pods verified not enabled (#1099) 2017-09-21 18:06:35 +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/controller.go (Browse further)