mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #97274 from nicolehanjing/nicoleh-update-sample
Update cloud-controller-manager samples to read --cloud-config flag
This commit is contained in:
commit
a8e30f8860
@ -33,7 +33,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
cloudprovider "k8s.io/cloud-provider"
|
||||
|
||||
"k8s.io/cloud-provider"
|
||||
"k8s.io/cloud-provider/app"
|
||||
cloudcontrollerconfig "k8s.io/cloud-provider/app/config"
|
||||
"k8s.io/cloud-provider/options"
|
||||
@ -56,9 +57,6 @@ const (
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
// cloudProviderConfigFile shows an sample of parse config file from flag option
|
||||
var flagset *pflag.FlagSet = pflag.NewFlagSet("flagSet", pflag.ContinueOnError)
|
||||
var cloudProviderConfigFile *string = flagset.String("cloud-provider-configfile", "", "This is the sample input for cloud provider config file")
|
||||
pflag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
|
||||
_ = pflag.CommandLine.Parse(os.Args[1:])
|
||||
|
||||
@ -75,7 +73,7 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cloud, err := cloudprovider.InitCloudProvider(cloudProviderName, *cloudProviderConfigFile)
|
||||
cloud, err := cloudprovider.InitCloudProvider(cloudProviderName, c.ComponentConfig.KubeCloudShared.CloudProvider.CloudConfigFile)
|
||||
if err != nil {
|
||||
klog.Fatalf("Cloud provider could not be initialized: %v", err)
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"k8s.io/cloud-provider"
|
||||
"k8s.io/cloud-provider/app"
|
||||
"k8s.io/cloud-provider/options"
|
||||
@ -50,9 +51,6 @@ const (
|
||||
func advancedMain() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
// cloudProviderConfigFile shows an sample of parse config file from flag option
|
||||
var flagset *pflag.FlagSet = pflag.NewFlagSet("flagSet", pflag.ContinueOnError)
|
||||
var cloudProviderConfigFile *string = flagset.String("cloud-provider-configfile", "", "This is the sample input for cloud provider config file")
|
||||
pflag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
|
||||
_ = pflag.CommandLine.Parse(os.Args[1:])
|
||||
|
||||
@ -69,7 +67,7 @@ func advancedMain() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cloud, err := cloudprovider.InitCloudProvider(cloudProviderName, *cloudProviderConfigFile)
|
||||
cloud, err := cloudprovider.InitCloudProvider(cloudProviderName, c.ComponentConfig.KubeCloudShared.CloudProvider.CloudConfigFile)
|
||||
if err != nil {
|
||||
klog.Fatalf("Cloud provider could not be initialized: %v", err)
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"k8s.io/cloud-provider"
|
||||
"k8s.io/cloud-provider/app"
|
||||
"k8s.io/cloud-provider/options"
|
||||
@ -45,8 +46,6 @@ const (
|
||||
|
||||
// sampleCloudProviderName shows an sample of using hard coded parameter for CloudProviderName
|
||||
sampleCloudProviderName = "SampleCloudProviderName"
|
||||
// sampleCloudProviderConfigFile shows an sample of using hard coded parameter for CloudProviderConfigFile
|
||||
sampleCloudProviderConfigFile = "sampleCloudProviderConfigFile"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -63,7 +62,7 @@ func main() {
|
||||
}
|
||||
|
||||
// initialize cloud provider with the cloud provider name and config file provided
|
||||
cloud, err := cloudprovider.InitCloudProvider(sampleCloudProviderName, sampleCloudProviderConfigFile)
|
||||
cloud, err := cloudprovider.InitCloudProvider(sampleCloudProviderName, c.ComponentConfig.KubeCloudShared.CloudProvider.CloudConfigFile)
|
||||
if err != nil {
|
||||
klog.Fatalf("Cloud provider could not be initialized: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user