add LoggingConfiguration struct to component-base/config

This commit is contained in:
amash
2020-06-26 01:03:27 +04:30
parent ac8d2e8978
commit 3ab25f1876
22 changed files with 102 additions and 97 deletions

View File

@@ -76,7 +76,7 @@ var kubeletMarshalCases = []struct {
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
loggingConfig: {}
logging: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
runtimeRequestTimeout: 0s
@@ -119,7 +119,7 @@ var kubeletMarshalCases = []struct {
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
loggingConfig: {}
logging: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
port: 12345

View File

@@ -540,7 +540,7 @@ func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfig
fs.StringSliceVar(&c.EnforceNodeAllocatable, "enforce-node-allocatable", c.EnforceNodeAllocatable, "A comma separated list of levels of node allocatable enforcement to be enforced by kubelet. Acceptable options are 'none', 'pods', 'system-reserved', and 'kube-reserved'. If the latter two options are specified, '--system-reserved-cgroup' and '--kube-reserved-cgroup' must also be set, respectively. If 'none' is specified, no additional options should be set. See https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/ for more details.")
fs.StringVar(&c.SystemReservedCgroup, "system-reserved-cgroup", c.SystemReservedCgroup, "Absolute name of the top level cgroup that is used to manage non-kubernetes components for which compute resources were reserved via '--system-reserved' flag. Ex. '/system-reserved'. [default='']")
fs.StringVar(&c.KubeReservedCgroup, "kube-reserved-cgroup", c.KubeReservedCgroup, "Absolute name of the top level cgroup that is used to manage kubernetes components for which compute resources were reserved via '--kube-reserved' flag. Ex. '/kube-reserved'. [default='']")
fs.StringVar(&c.LoggingConfig.LoggingFormat, "logging-format", c.LoggingConfig.LoggingFormat, `Sets the log format. Permitted formats: "text", "json".\nNon-default formats don't honor these flags: -add_dir_header, --alsologtostderr, --log_backtrace_at, --log_dir, --log_file, --log_file_max_size, --logtostderr, --skip_headers, --skip_log_headers, --stderrthreshold, --log-flush-frequency.\nNon-default choices are currently alpha and subject to change without warning.`)
fs.StringVar(&c.Logging.Format, "logging-format", c.Logging.Format, `Sets the log format. Permitted formats: "text", "json".\nNon-default formats don't honor these flags: -add_dir_header, --alsologtostderr, --log_backtrace_at, --log_dir, --log_file, --log_file_max_size, --logtostderr, --skip_headers, --skip_log_headers, --stderrthreshold, --log-flush-frequency.\nNon-default choices are currently alpha and subject to change without warning.`)
// Graduated experimental flags, kept for backward compatibility
fs.BoolVar(&c.KernelMemcgNotification, "experimental-kernel-memcg-notification", c.KernelMemcgNotification, "Use kernelMemcgNotification configuration, this flag will be removed in 1.23.")

View File

@@ -405,8 +405,8 @@ func UnsecuredDependencies(s *options.KubeletServer, featureGate featuregate.Fea
// not be generated.
func Run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, featureGate featuregate.FeatureGate, stopCh <-chan struct{}) error {
logOption := logs.NewOptions()
if s.LoggingConfig.LoggingFormat != "" {
logOption.LogFormat = s.LoggingConfig.LoggingFormat
if s.Logging.Format != "" {
logOption.LogFormat = s.Logging.Format
}
logOption.Apply()
// To help debugging, immediately log version