package main import ( "math/rand" "os" "time" "git.giftfish.de/ston1th/cloud-controller-manager-pve/pkg/pvecloud" "k8s.io/apimachinery/pkg/util/wait" cloudprovider "k8s.io/cloud-provider" "k8s.io/cloud-provider/app" "k8s.io/cloud-provider/app/config" "k8s.io/cloud-provider/options" cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/logs" "k8s.io/klog/v2" ) func main() { rand.Seed(time.Now().UTC().UnixNano()) logs.InitLogs() defer logs.FlushLogs() opts, err := options.NewCloudControllerManagerOptions() if err != nil { klog.Fatalf("unable to initialize command options: %v", err) } controllerInitializers := app.DefaultInitFuncConstructors fss := cliflag.NamedFlagSets{} command := app.NewCloudControllerManagerCommand(opts, cloudInitializer, controllerInitializers, fss, wait.NeverStop) if err := command.Execute(); err != nil { os.Exit(1) } } func cloudInitializer(config *config.CompletedConfig) cloudprovider.Interface { cloudConfig := config.ComponentConfig.KubeCloudShared.CloudProvider providerName := cloudConfig.Name if providerName == "" { providerName = pvecloud.ProviderName } if providerName != pvecloud.ProviderName { klog.Fatalf("unknown cloud provider %s, only 'pvecloud' is supported", providerName) } // initialize cloud provider with the cloud provider name and config file provided cloud, err := cloudprovider.InitCloudProvider(providerName, cloudConfig.CloudConfigFile) if err != nil { klog.Fatalf("cloud provider could not be initialized: %v", err) } if cloud == nil { klog.Fatalf("cloud provider is nil") } if !cloud.HasClusterID() { if config.ComponentConfig.KubeCloudShared.AllowUntaggedCloud { klog.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 { klog.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") } } return cloud }