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:
parent
2fc3f5e0b1
commit
fe5c731047
4 changed files with 59 additions and 0 deletions
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue