add external cloudprovider to clerly denote the offloading off cloudprovider tasks

This commit is contained in:
wlan0
2017-03-01 09:43:46 -08:00
parent 61e7d1ebf1
commit 9875620388
2 changed files with 13 additions and 1 deletions

View File

@@ -420,7 +420,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.KubeletDeps) (err error) {
var externalKubeClient clientgoclientset.Interface var externalKubeClient clientgoclientset.Interface
var cloud cloudprovider.Interface var cloud cloudprovider.Interface
if s.CloudProvider != componentconfigv1alpha1.AutoDetectCloudProvider { if !cloudprovider.IsExternal(s.CloudProvider) && s.CloudProvider != componentconfigv1alpha1.AutoDetectCloudProvider {
cloud, err = cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile) cloud, err = cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
if err != nil { if err != nil {
return err return err

View File

@@ -37,6 +37,8 @@ var (
providers = make(map[string]Factory) providers = make(map[string]Factory)
) )
const externalCloudProvider = "external"
// RegisterCloudProvider registers a cloudprovider.Factory by name. This // RegisterCloudProvider registers a cloudprovider.Factory by name. This
// is expected to happen during app startup. // is expected to happen during app startup.
func RegisterCloudProvider(name string, cloud Factory) { func RegisterCloudProvider(name string, cloud Factory) {
@@ -85,6 +87,11 @@ func GetCloudProvider(name string, config io.Reader) (Interface, error) {
return f(config) return f(config)
} }
// Detects if the string is an external cloud provider
func IsExternal(name string) bool {
return name == externalCloudProvider
}
// InitCloudProvider creates an instance of the named cloud provider. // InitCloudProvider creates an instance of the named cloud provider.
func InitCloudProvider(name string, configFilePath string) (Interface, error) { func InitCloudProvider(name string, configFilePath string) (Interface, error) {
var cloud Interface var cloud Interface
@@ -95,6 +102,11 @@ func InitCloudProvider(name string, configFilePath string) (Interface, error) {
return nil, nil return nil, nil
} }
if IsExternal(name) {
glog.Info("External cloud provider specified")
return nil, nil
}
if configFilePath != "" { if configFilePath != "" {
var config *os.File var config *os.File
config, err = os.Open(configFilePath) config, err = os.Open(configFilePath)