mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 06:01:50 +00:00
Make cloud providers be plugins
This commit is contained in:
@@ -28,8 +28,6 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/gce"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/vagrant"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
verflag "github.com/GoogleCloudPlatform/kubernetes/pkg/version/flag"
|
||||
@@ -77,23 +75,13 @@ func main() {
|
||||
glog.Fatalf("-etcd_servers flag is required.")
|
||||
}
|
||||
|
||||
var cloud cloudprovider.Interface
|
||||
switch *cloudProvider {
|
||||
case "gce":
|
||||
var err error
|
||||
cloud, err = gce_cloud.NewGCECloud()
|
||||
if err != nil {
|
||||
glog.Fatalf("Couldn't connect to GCE cloud: %#v", err)
|
||||
}
|
||||
case "vagrant":
|
||||
var err error
|
||||
cloud, err = vagrant_cloud.NewVagrantCloud()
|
||||
if err != nil {
|
||||
glog.Fatalf("Couldn't connect to vagrant cloud: %#v", err)
|
||||
}
|
||||
default:
|
||||
cloud, err := cloudprovider.GetCloudProvider(*cloudProvider)
|
||||
if err != nil {
|
||||
glog.Fatalf("Couldn't init cloud provider %q: %#v", *cloudProvider, err)
|
||||
}
|
||||
if cloud == nil {
|
||||
if len(*cloudProvider) > 0 {
|
||||
glog.Infof("Unknown cloud provider: %s", *cloudProvider)
|
||||
glog.Fatalf("Unknown cloud provider: %s", *cloudProvider)
|
||||
} else {
|
||||
glog.Info("No cloud provider specified.")
|
||||
}
|
||||
|
25
cmd/apiserver/plugins.go
Normal file
25
cmd/apiserver/plugins.go
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
// This file exists to force the desired plugin implementations to be linked.
|
||||
// This should probably be part of some configuration fed into the build for a
|
||||
// given binary target.
|
||||
import (
|
||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/gce"
|
||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/vagrant"
|
||||
)
|
Reference in New Issue
Block a user