mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
cloud-provider: add more log options
Change k8s.io/cloud-provider/app.NewCloudControllerManagerCommand to create a k8s.io/component-base/logs.Options, add it to the flags for the command and apply them on startup. This adds the logging-format command line option.
This commit is contained in:
parent
f21c603417
commit
e9379b3b37
@ -47,6 +47,8 @@ import (
|
||||
cliflag "k8s.io/component-base/cli/flag"
|
||||
"k8s.io/component-base/cli/globalflag"
|
||||
"k8s.io/component-base/configz"
|
||||
"k8s.io/component-base/logs"
|
||||
logsapi "k8s.io/component-base/logs/api/v1"
|
||||
"k8s.io/component-base/metrics/features"
|
||||
controllersmetrics "k8s.io/component-base/metrics/prometheus/controllers"
|
||||
"k8s.io/component-base/metrics/prometheus/slis"
|
||||
@ -64,6 +66,7 @@ import (
|
||||
|
||||
func init() {
|
||||
utilruntime.Must(features.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
|
||||
utilruntime.Must(logsapi.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
|
||||
}
|
||||
|
||||
const (
|
||||
@ -77,6 +80,8 @@ const (
|
||||
// controllerInitFuncConstructors is a map of controller name(as defined by controllers flag in https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/#options) to their InitFuncConstructor.
|
||||
// additionalFlags provides controller specific flags to be included in the complete set of controller manager flags
|
||||
func NewCloudControllerManagerCommand(s *options.CloudControllerManagerOptions, cloudInitializer InitCloudFunc, controllerInitFuncConstructors map[string]ControllerInitFuncConstructor, additionalFlags cliflag.NamedFlagSets, stopCh <-chan struct{}) *cobra.Command {
|
||||
logOptions := logs.NewOptions()
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "cloud-controller-manager",
|
||||
Long: `The Cloud controller manager is a daemon that embeds
|
||||
@ -85,6 +90,11 @@ the cloud specific control loops shipped with Kubernetes.`,
|
||||
verflag.PrintAndExitIfRequested()
|
||||
cliflag.PrintFlags(cmd.Flags())
|
||||
|
||||
if err := logsapi.ValidateAndApply(logOptions, utilfeature.DefaultFeatureGate); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := s.Config(ControllerNames(controllerInitFuncConstructors), ControllersDisabledByDefault.List())
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
@ -113,8 +123,11 @@ the cloud specific control loops shipped with Kubernetes.`,
|
||||
|
||||
fs := cmd.Flags()
|
||||
namedFlagSets := s.Flags(ControllerNames(controllerInitFuncConstructors), ControllersDisabledByDefault.List())
|
||||
verflag.AddFlags(namedFlagSets.FlagSet("global"))
|
||||
globalflag.AddGlobalFlags(namedFlagSets.FlagSet("global"), cmd.Name())
|
||||
|
||||
globalFlagSet := namedFlagSets.FlagSet("global")
|
||||
verflag.AddFlags(globalFlagSet)
|
||||
logsapi.AddFlags(logOptions, globalFlagSet)
|
||||
globalflag.AddGlobalFlags(globalFlagSet, cmd.Name(), logs.SkipLoggingConfigurationFlags())
|
||||
|
||||
if flag.CommandLine.Lookup("cloud-provider-gce-lb-src-cidrs") != nil {
|
||||
// hoist this flag from the global flagset to preserve the commandline until
|
||||
|
Loading…
Reference in New Issue
Block a user