Deprecate multiple endpoints for out-of-cluster k8s api (#2454)

This fix deprecates endpoints for out-of-cluster k8s api,
The Corefile still takes multiple endpoints though only
the first one is used. A warning is shown if there are
multiple endpoints.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang 2019-01-13 10:09:51 -08:00 committed by GitHub
parent f655d404d4
commit 7bd6855155
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 72 deletions

View file

@ -195,15 +195,11 @@ func ParseStanza(c *caddy.Controller) (*Kubernetes, error) {
case "endpoint":
args := c.RemainingArgs()
if len(args) > 0 {
// Multiple endoints are deprecated but still could be specified,
// only the first one be used, though
k8s.APIServerList = args
if len(args) > 1 {
// If multiple endoints specified, then only http allowed
for i := range args {
parts := strings.SplitN(args[i], "://", 2)
if len(parts) == 2 && parts[0] != "http" {
return nil, fmt.Errorf("multiple endpoints can only accept http, found: %v", args[i])
}
}
log.Warningf("Multiple endpoints have been deprecated, only the first specified endpoint '%s' is used", args[0])
}
continue
}