middleware/authpath: Fix return from k8s mw (#871)

* middleware/authpath: Fix return from k8s mw

Return the correct search path from the kubernetes' AutoPath function.
Based on preliminary discussion in #870

* PodWithIP can be private

Fix and add docs to functions.

* CR: remove the error from AutoPathFunc
This commit is contained in:
Miek Gieben 2017-08-10 19:26:31 +01:00 committed by GitHub
parent 3654361be2
commit 6cc3f47d46
4 changed files with 46 additions and 20 deletions

View file

@ -62,6 +62,8 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
Proxy: proxy.Proxy{},
}
k8s.autoPathSearch = searchFromResolvConf()
for c.Next() {
if c.Val() == "kubernetes" {
zones := c.RemainingArgs()
@ -202,6 +204,15 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
return nil, errors.New("kubernetes setup called without keyword 'kubernetes' in Corefile")
}
func searchFromResolvConf() []string {
rc, err := dns.ClientConfigFromFile("/etc/resolv.conf")
if err != nil {
return nil
}
middleware.Zones(rc.Search).Normalize()
return rc.Search
}
const (
defaultResyncPeriod = 5 * time.Minute
defautNdots = 0