ClientConfig should not default to http://localhost:8080
This changes clientcmd to skip the default cluster, but preserves the behavior in kubectl. This prevents the possibility of an administrator misconfiguration in kubelet or other server component from allowing a third party who can bind to 8080 on that host from potentially impersonating an API server and gaining root access.
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/emicklei/go-restful/swagger"
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
@@ -1219,6 +1220,9 @@ func DefaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig {
|
||||
flags.StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to the kubeconfig file to use for CLI requests.")
|
||||
|
||||
overrides := &clientcmd.ConfigOverrides{}
|
||||
// use the standard defaults for this client config
|
||||
mergo.Merge(&overrides.ClusterDefaults, clientcmd.DefaultCluster)
|
||||
|
||||
flagNames := clientcmd.RecommendedConfigOverrideFlags("")
|
||||
// short flagnames are disabled by default. These are here for compatibility with existing scripts
|
||||
flagNames.ClusterOverrideFlags.APIServer.ShortName = "s"
|
||||
|
Reference in New Issue
Block a user