mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 08:17:26 +00:00
add --logging-format flag to kubelet
This commit is contained in:
parent
c53ce48d48
commit
ba8189a4f2
@ -111,6 +111,7 @@ go_library(
|
||||
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/configz:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/featuregate:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/logs:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/metrics:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/version:go_default_library",
|
||||
|
@ -540,6 +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.LogFormat, "logging-format", c.LogFormat, "Set log format of Kubelet logging. Possible value: 'text'. Default: 'text'")
|
||||
|
||||
// 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.")
|
||||
|
@ -63,6 +63,7 @@ import (
|
||||
cliflag "k8s.io/component-base/cli/flag"
|
||||
"k8s.io/component-base/configz"
|
||||
"k8s.io/component-base/featuregate"
|
||||
"k8s.io/component-base/logs"
|
||||
"k8s.io/component-base/metrics"
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
"k8s.io/component-base/version"
|
||||
@ -403,6 +404,11 @@ func UnsecuredDependencies(s *options.KubeletServer, featureGate featuregate.Fea
|
||||
// Otherwise, the caller is assumed to have set up the Dependencies object and a default one will
|
||||
// not be generated.
|
||||
func Run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, featureGate featuregate.FeatureGate, stopCh <-chan struct{}) error {
|
||||
logOption := logs.NewOptions()
|
||||
if s.LogFormat != "" {
|
||||
logOption.LogFormat = s.LogFormat
|
||||
}
|
||||
logOption.Apply()
|
||||
// To help debugging, immediately log version
|
||||
klog.Infof("Version: %+v", version.Get())
|
||||
if err := initForOS(s.KubeletFlags.WindowsService); err != nil {
|
||||
|
@ -195,6 +195,7 @@ var (
|
||||
"KubeReservedCgroup",
|
||||
"KubeReserved[*]",
|
||||
"KubeletCgroups",
|
||||
"LogFormat",
|
||||
"MakeIPTablesUtilChains",
|
||||
"RotateCertificates",
|
||||
"ServerTLSBootstrap",
|
||||
|
@ -357,6 +357,10 @@ type KubeletConfiguration struct {
|
||||
// The purpose of this format is make sure you have the opportunity to notice if the next release hides additional metrics,
|
||||
// rather than being surprised when they are permanently removed in the release after that.
|
||||
ShowHiddenMetricsForVersion string
|
||||
// LogFormat Flag specifies the structure of log messages.
|
||||
// default value of logFormat is `text`
|
||||
// Refer [Logs Options](https://github.com/kubernetes/component-base/blob/master/logs/options.go) for more information.
|
||||
LogFormat string
|
||||
}
|
||||
|
||||
// KubeletAuthorizationMode denotes the authorization mode for the kubelet
|
||||
|
@ -342,6 +342,7 @@ func autoConvert_v1beta1_KubeletConfiguration_To_config_KubeletConfiguration(in
|
||||
out.VolumePluginDir = in.VolumePluginDir
|
||||
out.ProviderID = in.ProviderID
|
||||
out.KernelMemcgNotification = in.KernelMemcgNotification
|
||||
out.LogFormat = in.LogFormat
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -486,6 +487,7 @@ func autoConvert_config_KubeletConfiguration_To_v1beta1_KubeletConfiguration(in
|
||||
out.EnforceNodeAllocatable = *(*[]string)(unsafe.Pointer(&in.EnforceNodeAllocatable))
|
||||
out.ReservedSystemCPUs = in.ReservedSystemCPUs
|
||||
out.ShowHiddenMetricsForVersion = in.ShowHiddenMetricsForVersion
|
||||
out.LogFormat = in.LogFormat
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ go_library(
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/logs:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/metrics:go_default_library",
|
||||
],
|
||||
)
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/component-base/logs"
|
||||
"k8s.io/component-base/metrics"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
|
||||
@ -158,5 +159,12 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
|
||||
allErrors = append(allErrors, err)
|
||||
}
|
||||
allErrors = append(allErrors, metrics.ValidateShowHiddenMetricsVersion(kc.ShowHiddenMetricsForVersion)...)
|
||||
|
||||
logOption := logs.NewOptions()
|
||||
if kc.LogFormat != "" {
|
||||
logOption.LogFormat = kc.LogFormat
|
||||
}
|
||||
allErrors = append(allErrors, logOption.Validate()...)
|
||||
|
||||
return utilerrors.NewAggregate(allErrors)
|
||||
}
|
||||
|
@ -793,6 +793,11 @@ type KubeletConfiguration struct {
|
||||
// Default: false
|
||||
// +optional
|
||||
KernelMemcgNotification bool `json:"kernelMemcgNotification,omitempty"`
|
||||
// LogFormat specifies the structure of log messages.
|
||||
// Refer [Logs Options](https://github.com/kubernetes/component-base/blob/master/logs/options.go) for more information.
|
||||
// Default: "text"
|
||||
// + optional
|
||||
LogFormat string `json:"logFormat,omitempty"`
|
||||
}
|
||||
|
||||
type KubeletAuthorizationMode string
|
||||
|
Loading…
Reference in New Issue
Block a user