aboutsummaryrefslogtreecommitdiff
path: root/middleware/kubernetes/setup.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-08-27 01:32:46 +0100
committerGravatar Yong Tang <yong.tang.github@outlook.com> 2017-08-26 17:32:46 -0700
commit4049ed4f4b85f9f8214a03fc1bb48c579115f9e5 (patch)
treea7730bf9a282c04b39ecd0066c300be3a2a430cf /middleware/kubernetes/setup.go
parent01f6e8cba5ab12c5401ef73b0ac9a1d6ac07fcce (diff)
downloadcoredns-4049ed4f4b85f9f8214a03fc1bb48c579115f9e5.tar.gz
coredns-4049ed4f4b85f9f8214a03fc1bb48c579115f9e5.tar.zst
coredns-4049ed4f4b85f9f8214a03fc1bb48c579115f9e5.zip
mw/kubernetes: add configurable TTL (#995)
* mw/kubernetes: add configurable TTL Add ttl option to kubernetes. This defaults to 5s but allows configuration to go up to 3600. Configure the tests so that a few actually check for the 5s, while the rest use the TTL of 303 which is ignored by the checking code. Fixes #935 * fix tests * and more
Diffstat (limited to 'middleware/kubernetes/setup.go')
-rw-r--r--middleware/kubernetes/setup.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/middleware/kubernetes/setup.go b/middleware/kubernetes/setup.go
index 557eca93d..15b87c2cd 100644
--- a/middleware/kubernetes/setup.go
+++ b/middleware/kubernetes/setup.go
@@ -3,6 +3,7 @@ package kubernetes
import (
"errors"
"fmt"
+ "strconv"
"strings"
"time"
@@ -174,6 +175,19 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, dnsControlOpts, error) {
return nil, opts, err
}
k8s.Proxy = proxy.NewLookup(ups)
+ case "ttl":
+ args := c.RemainingArgs()
+ if len(args) == 0 {
+ return nil, opts, c.ArgErr()
+ }
+ t, err := strconv.Atoi(args[0])
+ if err != nil {
+ return nil, opts, err
+ }
+ if t < 5 || t > 3600 {
+ return nil, opts, c.Errf("ttl must be in range [5, 3600]: %d", t)
+ }
+ k8s.ttl = uint32(t)
default:
return nil, opts, c.Errf("unknown property '%s'", c.Val())
}