Skip to content

Commit

Permalink
Drop usage of rest.InClusterConfig()
Browse files Browse the repository at this point in the history
This is automatically done in BuildConfigFromFlags().
  • Loading branch information
frobware committed Apr 29, 2019
1 parent d6587d6 commit bb53e90
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit bb53e90

Please sign in to comment.