aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2021-10-06 11:59:37 -0400
committerGravatar GitHub <noreply@github.com> 2021-10-06 15:59:37 +0000
commit5534625c75a0ae1f84e1f715eaddb257de4166eb (patch)
tree20d319921cdb87fd4dbcdb3b7bea462b636f5218 /plugin
parentc6bcc8f2ffc70033f9177fad7b715e81ea8d8d05 (diff)
downloadcoredns-5534625c75a0ae1f84e1f715eaddb257de4166eb.tar.gz
coredns-5534625c75a0ae1f84e1f715eaddb257de4166eb.tar.zst
coredns-5534625c75a0ae1f84e1f715eaddb257de4166eb.zip
plugin/kubernetes: Don't use pod names longer than 63 characters as dns labels (#4908)
Automatically submitted.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/kubernetes/README.md2
-rw-r--r--plugin/kubernetes/object/endpoint.go6
2 files changed, 5 insertions, 3 deletions
diff --git a/plugin/kubernetes/README.md b/plugin/kubernetes/README.md
index 655e24a74..de95b1e7d 100644
--- a/plugin/kubernetes/README.md
+++ b/plugin/kubernetes/README.md
@@ -87,7 +87,7 @@ kubernetes [ZONES...] {
If this directive is included, then name selection for endpoints changes as
follows: Use the hostname of the endpoint, or if hostname is not set, use the
pod name of the pod targeted by the endpoint. If there is no pod targeted by
- the endpoint, use the dashed IP address form.
+ the endpoint or pod name is longer than 63, use the dashed IP address form.
* `ttl` allows you to set a custom TTL for responses. The default is 5 seconds. The minimum TTL allowed is
0 seconds, and the maximum is capped at 3600 seconds. Setting TTL to 0 will prevent records from being cached.
* `noendpoints` will turn off the serving of endpoint records by disabling the watch on endpoints.
diff --git a/plugin/kubernetes/object/endpoint.go b/plugin/kubernetes/object/endpoint.go
index 6ce7bfefa..4af64f363 100644
--- a/plugin/kubernetes/object/endpoint.go
+++ b/plugin/kubernetes/object/endpoint.go
@@ -136,7 +136,8 @@ func EndpointSliceToEndpoints(obj meta.Object) (meta.Object, error) {
if end.Hostname != nil {
ea.Hostname = *end.Hostname
}
- if end.TargetRef != nil {
+ // ignore pod names that are too long to be a valid label
+ if end.TargetRef != nil && len(end.TargetRef.Name) < 64 {
ea.TargetRefName = end.TargetRef.Name
}
if end.NodeName != nil {
@@ -186,7 +187,8 @@ func EndpointSliceV1beta1ToEndpoints(obj meta.Object) (meta.Object, error) {
if end.Hostname != nil {
ea.Hostname = *end.Hostname
}
- if end.TargetRef != nil {
+ // ignore pod names that are too long to be a valid label
+ if end.TargetRef != nil && len(end.TargetRef.Name) < 64 {
ea.TargetRefName = end.TargetRef.Name
}
// EndpointSlice does not contain NodeName, leave blank