mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
Support for kubeconfig files (#2053)
* Add support for authentication with kubeconfig files * Update k8s plugin documentation * Fix whitespace in README and tests * Use clientcmd package to load kubeconfig file
This commit is contained in:
committed by
John Belamaric
parent
2fc3f5e0b1
commit
fe5c731047
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/mholt/caddy"
|
||||
"github.com/miekg/dns"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
)
|
||||
|
||||
var log = clog.NewWithPlugin("kubernetes")
|
||||
@@ -261,6 +262,17 @@ func ParseStanza(c *caddy.Controller) (*Kubernetes, error) {
|
||||
return nil, fmt.Errorf("unable to parse ignore value: '%v'", ignore)
|
||||
}
|
||||
}
|
||||
case "kubeconfig":
|
||||
args := c.RemainingArgs()
|
||||
if len(args) == 2 {
|
||||
config := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: args[0]},
|
||||
&clientcmd.ConfigOverrides{CurrentContext: args[1]},
|
||||
)
|
||||
k8s.ClientConfig = config
|
||||
continue
|
||||
}
|
||||
return nil, c.ArgErr()
|
||||
default:
|
||||
return nil, c.Errf("unknown property '%s'", c.Val())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user