add --logging-format flag to kubelet

This commit is contained in:
amash
2020-05-28 18:10:17 +04:30
parent c53ce48d48
commit ba8189a4f2
9 changed files with 29 additions and 0 deletions

View File

@@ -195,6 +195,7 @@ var (
"KubeReservedCgroup",
"KubeReserved[*]",
"KubeletCgroups",
"LogFormat",
"MakeIPTablesUtilChains",
"RotateCertificates",
"ServerTLSBootstrap",

View File

@@ -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

View File

@@ -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
}

View File

@@ -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",
],
)

View File

@@ -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)
}