From bb53e900b016e64566f8ee302e67560e563c067c Mon Sep 17 00:00:00 2001 From: Andrew McDermott Date: Mon, 29 Apr 2019 13:26:41 +0100 Subject: [PATCH] Drop usage of rest.InClusterConfig() This is automatically done in BuildConfigFromFlags(). --- .../cloudprovider/clusterapi/clusterapi_provider.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_provider.go b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_provider.go index a4433d4c51ec..6b7907e13c74 100644 --- a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_provider.go +++ b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_provider.go @@ -134,26 +134,21 @@ func newProvider( // BuildClusterAPI builds CloudProvider implementation for machine api. func BuildClusterAPI(opts config.AutoscalingOptions, do cloudprovider.NodeGroupDiscoveryOptions, rl *cloudprovider.ResourceLimiter) cloudprovider.CloudProvider { var err error - var externalConfig *rest.Config - - externalConfig, err = rest.InClusterConfig() - if err != nil && err != rest.ErrNotInCluster { - klog.Fatal(err) - } + var config *rest.Config if opts.KubeConfigPath != "" { - externalConfig, err = clientcmd.BuildConfigFromFlags("", opts.KubeConfigPath) + config, err = clientcmd.BuildConfigFromFlags("", opts.KubeConfigPath) if err != nil { klog.Fatalf("cannot build config: %v", err) } } - kubeclient, err := kubernetes.NewForConfig(externalConfig) + kubeclient, err := kubernetes.NewForConfig(config) if err != nil { klog.Fatalf("create kube clientset failed: %v", err) } - clusterclient, err := clusterclientset.NewForConfig(externalConfig) + clusterclient, err := clusterclientset.NewForConfig(config) if err != nil { klog.Fatalf("create cluster clientset failed: %v", err) }