2016-10-07 20:39:21 -04:00
/ *
Copyright 2016 The Kubernetes Authors .
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 .
* /
// The external controller manager is responsible for running controller loops that
2016-12-17 12:27:48 -05:00
// are cloud provider dependent. It uses the API to listen to new events on resources.
2016-10-07 20:39:21 -04:00
package main
import (
"fmt"
"os"
2017-01-23 09:46:05 -05:00
"k8s.io/apiserver/pkg/util/flag"
2017-02-13 10:35:12 -05:00
"k8s.io/apiserver/pkg/util/logs"
2016-10-07 20:39:21 -04:00
"k8s.io/kubernetes/cmd/cloud-controller-manager/app"
"k8s.io/kubernetes/cmd/cloud-controller-manager/app/options"
_ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration
"k8s.io/kubernetes/pkg/cloudprovider"
2017-09-27 10:04:43 -04:00
// NOTE: Importing all in-tree cloud-providers is not required when
// implementing an out-of-tree cloud-provider.
2016-10-07 20:39:21 -04:00
_ "k8s.io/kubernetes/pkg/cloudprovider/providers"
_ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration
"k8s.io/kubernetes/pkg/version/verflag"
"github.com/golang/glog"
"github.com/spf13/pflag"
)
func main ( ) {
2016-12-17 12:27:48 -05:00
s := options . NewCloudControllerManagerServer ( )
2016-10-07 20:39:21 -04:00
s . AddFlags ( pflag . CommandLine )
flag . InitFlags ( )
logs . InitLogs ( )
defer logs . FlushLogs ( )
verflag . PrintAndExitIfRequested ( )
2017-05-01 20:57:42 -04:00
if s . CloudProvider == "" {
glog . Errorf ( "--cloud-provider cannot be empty" )
}
2016-10-07 20:39:21 -04:00
cloud , err := cloudprovider . InitCloudProvider ( s . CloudProvider , s . CloudConfigFile )
if err != nil {
glog . Fatalf ( "Cloud provider could not be initialized: %v" , err )
}
2017-07-17 00:28:57 -04:00
if cloud . HasClusterID ( ) == false {
if s . AllowUntaggedCloud == true {
glog . Warning ( "detected a cluster without a ClusterID. A ClusterID will be required in the future. Please tag your cluster to avoid any future issues" )
} else {
2017-08-25 11:16:05 -04:00
glog . Fatalf ( "no ClusterID found. A ClusterID is required for the cloud provider to function properly. This check can be bypassed by setting the allow-untagged-cloud option" )
2017-07-17 00:28:57 -04:00
}
}
2016-10-07 20:39:21 -04:00
if err := app . Run ( s , cloud ) ; err != nil {
fmt . Fprintf ( os . Stderr , "%v\n" , err )
os . Exit ( 1 )
}
}