Commit Graph

301 Commits

Author SHA1 Message Date
Dave Brown
ab74d3acf2 add args: startup_timeout for kubernetes plugin (#7068)
Signed-off-by: mangoyhuang <mangoyhuang@tencent.com>
Co-authored-by: mangoyhuang <mangoyhuang@tencent.com>
2025-06-11 11:22:07 -07:00
Matthieu MOREL
186e4a1dbb chore: enable early-return and superfluous-else from revive (#7129)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-05 10:10:58 +03:00
Ville Vesilehto
9f9aed31cf test: add t.Helper() calls to test helper functions (#7351) 2025-06-04 14:36:04 -07:00
Ville Vesilehto
b4abdcacf0 fix(kubernetes): multicluster DNS race condition (#7350) 2025-06-04 06:31:41 +03:00
Ville Vesilehto
8cac83dfb5 lint: enable wastedassign linter (#7340) 2025-06-01 16:30:41 -07:00
Ville Vesilehto
384fa3285e fix: missing intrange lint fix (#7333)
Missed in #7323

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-29 04:41:27 +03:00
Ville Vesilehto
60227bd8d2 perf(kubernetes): optimize AutoPath slice allocation (#7323)
Pre-allocate slice capacity in AutoPath to eliminate unnecessary
memory reallocations. This avoids slice growth when appending
search domains and sentinel value.

Benchmark shows significant performance improvement:
- Before: 538.6 ns/op, 560 B/op, 13 allocs/op
- After:  436.8 ns/op, 336 B/op, 11 allocs/op
- Result: 19% faster, 40% less memory, 15% fewer allocations

The optimization benefits Kubernetes clusters using autopath for
server-side search path completion.

Adds benchmark test to measure AutoPath performance.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-28 17:58:01 -07:00
Ville Vesilehto
19a6ae4983 lint: enable intrange linter (#7331)
Enable intrange linter to enforce modern Go range syntax over
traditional for loops, by converting:

for i := 0; i < n; i++

to:

for i := range n

Adding type conversions where needed for compatibility
with existing uint64 parameters.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-28 17:50:55 -07:00
Ville Vesilehto
7bd43af427 fix: loop variable capture and linter (#7328)
Enable copyloopvar linter and remove redundant variable
shadowing in Kubernetes plugin metadata handling. This pattern is
no longer needed in Go 1.22+ where loop variables are automatically
captured correctly in closures.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-27 14:44:20 -07:00
Arthur Outhenin-Chalandre
5c71bd0b87 kubernetes: add multicluster support (#7266)
* kubernetes: add multicluster support

Add multicluster support via Multi-Cluster Services API (MCS-API) via a
new option `multiclusterZones` in the kubernetes plugin.

When some multicluster zones are passed to the kubernetes plugin, it
will start watching the ServiceImport objects and its associated
EndpointSlices.

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

* kubernetes: implement xfr support for multicluster zones

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

---------

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>
2025-05-18 22:58:16 -07:00
Kevin Lyda
17eb2eed34 Prepare for the k8s api upgrade (#7293)
Don't explicitly set `RetryOnError` to `false`.  It won't exist in the
next version of the k8s api and it won't make a difference in this code
since the struct would default to that.

Signed-off-by: Kevin Lyda <kevin@lyda.ie>
2025-05-14 13:48:13 +02:00
Manuel Rüger
76ba39ffe9 chore: Upgrade to golangci-lint v2 (#7236)
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2025-04-04 14:27:39 -04:00
Ben Kochie
a1cc54b719 Update for Go 1.24 (#7226)
* Update for Go 1.24

* Update Go build to 1.24.1.
* Update minimum Go version to 1.23.0.
* Bump golangci-lint version.

Signed-off-by: SuperQ <superq@gmail.com>

* Workaround confused golangci-lint error.

Signed-off-by: SuperQ <superq@gmail.com>

---------

Signed-off-by: SuperQ <superq@gmail.com>
2025-03-24 12:50:13 -04:00
momantech
1bb184aa09 chore: fix some comments (#7201)
Signed-off-by: momantech <cuimoman@qq.com>
2025-03-24 10:32:39 -04:00
Bartosz Borkowski
7c76d534d3 Fix handling of pods having DeletionTimestamp set (#7119) (#7131)
Signed-off-by: Bartosz Borkowski <bartebor@wp.pl>
Co-authored-by: Bartosz Borkowski <bartosz.borkowski@grupawp.pl>
2025-03-24 10:31:24 -04:00
Chris O'Haver
8eed5991f0 Update README.md (#7210) 2025-03-24 10:25:44 -04:00
Adrian Moisey
58d8999192 Revert "only create PTR records for endpoints with hostname defined (#6898)" (#7194)
This reverts commit f4f0d55dce.

Signed-off-by: Adrian Moisey <adrian@changeover.za.net>
2025-03-18 15:42:43 -04:00
Chris O'Haver
f4f0d55dce only create PTR records for endpoints with hostname defined (#6898)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2024-09-30 10:32:13 -04:00
Manuel Rüger
ebbbb453be kubernetes: Add useragent (#6484)
In kubernetes' audit logs you'll see:

"userAgent":"coredns/v0.0.0 (linux/amd64) kubernetes/$Format"

This change adds a userAgent to the requests made by CoreDNS against the kubernetes API:

"userAgent":"CoreDNS/v1.11.1 git_commit:ae2bbc29be1aaae0b3ded5d188968a6c97bb3144 (linux/amd64/go1.22)"

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2024-08-26 16:45:39 -04:00
Ben Kochie
0d6e113f90 Enable Prometheus native histograms (#6524)
Add a NativeHistogramBucketFactor parameter to the use of
`NewHistogramVec` in order to enable use of Prometheus Native
Histograms.

This will store automatically computed sparse buckets in CoreDNS.
If a compatible Prometeus requests native histograms this data will
returned instead of the static buckets.

The default factor of 1.05 should provide high quality resolution data.

Signed-off-by: SuperQ <superq@gmail.com>
2024-03-11 16:09:09 -04:00
miles-to-go
92b7e658e3 add client labels to k8s plugin metadata (#6475)
Signed-off-by: Nolan Miles <nolanpmiles@gmail.com>
2024-03-07 14:34:09 -05:00
Zhizhen He
5de473da1c fix: remove unnecessary conversion (#6258)
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2023-08-14 15:14:09 +02:00
Zhizhen He
2fe5890d8b Fix typos (#6235)
* Fix typos and add todo to fix spelling of dnsutil.MaximumDefaulTTL

Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2023-08-10 11:06:48 -04:00
rokkiter
6e1263d3d9 fix ports panic (#6179)
Signed-off-by: rokkiter <101091030+rokkiter@users.noreply.github.com>
2023-06-26 09:42:03 -04:00
Dan Wilson
5b5a6ac6ad plugin/kubernetes: filter ExternalName services from matching double subdomain wildcard (#6162)
remove double subdomain reference from review feedback



not subdoman

Signed-off-by: emaildanwilson <dan@controlplane.com>
Co-authored-by: emaildanwilson <dan@controlplane.com>
2023-06-19 08:42:17 -04:00
Chris O'Haver
06cd843918 plugin/kubernetes: Remove Endpoint and EndpointSlice v1beta Support (#6147)
* remove endpoint and endpointslicev1beta watch support

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

* adjust readme

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

* informer object changes

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

* remove unused funcs

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

---------

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2023-06-12 08:22:57 -07:00
Ondřej Benkovský
8c489bd400 replace reviewdog fully by golangci-lint (#6139)
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2023-06-09 18:08:23 +02:00
Chris O'Haver
6d3db023fe plugin/kubernetes: fix headless/endpoint query panics when endpoints are disabled (#6137)
* always create listers, so we dont panic

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

---------

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2023-06-07 16:22:28 -04:00
Yashpal
1b95a6042d plugin/kubernetes: rename client-go metrics label "url" to "host" (#6040) 2023-04-25 20:26:57 +02:00
cui fliter
ee3999303d fix some comments (#6052)
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-04-25 11:25:07 -04:00
Yashpal
0862dd1cb5 plugin/kubernetes: expose client-go internal request metrics (#5991) 2023-04-22 18:38:49 +02:00
Chris O'Haver
68816a42a7 update informer for client-go 0.27 (#6038)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2023-04-20 13:24:06 -04:00
Stephen Kitt
60b7161fee Drop obsolete client-go auth plugins (#5806)
* Drop obsolete client-go auth plugins

The OpenStack plugin is no longer available, even in version 0.24.4 of
client-go; see
https://github.com/kubernetes/client-go/blob/v0.24.4/plugin/pkg/client/auth/openstack/openstack_stub.go
It is replaced by the client-keystone-auth credential plugin. The
plugin has been entirely removed in client-go 0.26.0, which breaks the
build when any other dependency pulls in client-go 0.26.0 or later.

The GCP plugin is deprecated in K8s 1.22+ and unavailable in 1.26+
(although it is still stubbed in client-go 0.26.0). Is it replaced by
the gke-gcloud-auth-plugin credential plugin.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

* Update plugin/kubernetes/setup.go

Signed-off-by: Stephen Kitt <skitt@redhat.com>
Co-authored-by: Chris O'Haver <cohaver@infoblox.com>
2022-12-13 15:49:03 -05:00
LAMRobinson
c3228615e0 plugin/kubernetes: error NXDOMAIN for TXT lookups (#5737)
plugin/kubernetes: fix NXDOMAIN/NOERROR responses for TXT queries

Signed-off-by: Laurence Robinson <laurence_robinson@live.co.uk>
Co-authored-by: Laurence Robinson <laurence.robinson@deshaw.com>
2022-12-13 15:36:46 -05:00
Chris O'Haver
47c99dc73b dont match external services when endpoint is specified (#5734)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-11-04 09:54:57 -04:00
Miciah Dashiel Butler Masters
6cb5e10707 plugin/k8s_external: Fix rcode for headless services (#5657)
Signed-off-by: Miciah Masters <miciah.masters@gmail.com>

Signed-off-by: Miciah Masters <miciah.masters@gmail.com>
2022-10-20 16:30:12 -04:00
coredns[bot]
2fcc74b94e auto go fmt
Signed-off-by: coredns[bot] <bot@bot.coredns.io>
2022-09-05 10:29:36 +00:00
TomasKohout
6782b7fb42 plugin/k8s_external: Resolve headless services (#5505)
*add option for resolving headless Services without external IPs in k8s_external

Signed-off-by: Tomas Kohout <tomas.kohout1995@gmail.com>
2022-08-30 14:59:27 -04:00
Abirdcfly
b218b56063 chore: remove duplicate word in comments (#5592)
* chore: remove duplicate word in comments

Signed-off-by: Abirdcfly <fp544037857@gmail.com>

* auto go mod tidy

Signed-off-by: coredns[bot] <bot@bot.coredns.io>

Signed-off-by: Abirdcfly <fp544037857@gmail.com>
Signed-off-by: coredns[bot] <bot@bot.coredns.io>
Co-authored-by: coredns[bot] <bot@bot.coredns.io>
2022-08-30 16:35:31 +02:00
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
Ondřej Benkovský
e0dead4aa2 plugin/kubernetes : make kubernetes client log in CoreDNS format (#5461)
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2022-06-26 14:49:45 -07:00
Lorenz Brun
7a7b0a2b9b Bump Kubernetes to 1.24 (#5364)
Signed-off-by: Lorenz Brun <lorenz@monogon.tech>
2022-05-04 13:38:21 -04:00
Chris O'Haver
c02cd52208 fix k8s start up timeout ticker (#5361)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-05-03 10:06:36 -04:00
Chris O'Haver
3fe9d41a21 plugin/k8s_external: fix external nsAddrs when CoreDNS Service has no External IPs (#4891)
fix external nsAddrs; add tests;

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-03-07 12:18:23 -05: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
Chris O'Haver
967814161a use tickers instead of time.After to avoid memory leak (#5220)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-03-03 23:36:02 -08:00
Chris O'Haver
66dc74caeb plugin/etcd+kubernetes: Persist truncated state to client if CNAME lookup response is truncated (#4715)
Persist the TC bit to client response for truncated CNAME lookups.
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-02-22 09:38:57 -05:00
Chris O'Haver
74d4e9bb1b kubernetes: log server start delay and api connection failures (#5044)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-02-22 09:21:45 -05:00
Yong Tang
b1d5d7c572 Replace deprecated NewDeltaFIFO with NewDeltaFIFOWithOptions (#5200)
Replace deprecated  `cache.NewDeltaFIFO`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2022-02-22 09:20:29 -05:00