Merge pull request #11583 from dntosas/json-logging

Add support for logging-format option (text/json)
This commit is contained in:
Kubernetes Prow Robot 2021-06-21 02:18:51 -07:00 committed by GitHub
commit 4df9da09d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 120 additions and 1 deletions

View File

@ -554,6 +554,16 @@ spec:
defaultUnreachableTolerationSeconds: 600 defaultUnreachableTolerationSeconds: 600
``` ```
### LogFormat
Choose between log format. Permitted formats: "json", "text". Default: "text".
```yaml
spec:
kubeAPIServer:
logFormat: json
```
## externalDns ## externalDns
This block contains configuration options for your `external-DNS` provider. This block contains configuration options for your `external-DNS` provider.
@ -698,6 +708,16 @@ spec:
eventBurst: 10 eventBurst: 10
``` ```
### LogFormat
Choose between log format. Permitted formats: "json", "text". Default: "text".
```yaml
spec:
kubelet:
logFormat: json
```
## kubeScheduler ## kubeScheduler
This block contains configurations for `kube-scheduler`. See https://kubernetes.io/docs/admin/kube-scheduler/ This block contains configurations for `kube-scheduler`. See https://kubernetes.io/docs/admin/kube-scheduler/
@ -713,6 +733,16 @@ Will make kube-scheduler use the scheduler policy from configmap "scheduler-poli
Note that as of Kubernetes 1.8.0 kube-scheduler does not reload its configuration from configmap automatically. You will need to ssh into the master instance and restart the Docker container manually. Note that as of Kubernetes 1.8.0 kube-scheduler does not reload its configuration from configmap automatically. You will need to ssh into the master instance and restart the Docker container manually.
### LogFormat
Choose between log format. Permitted formats: "json", "text". Default: "text".
```yaml
spec:
kubeScheduler:
logFormat: json
```
## kubeDNS ## kubeDNS
This block contains configurations for [CoreDNS](https://coredns.io/). This block contains configurations for [CoreDNS](https://coredns.io/).
@ -795,6 +825,16 @@ spec:
For more details on `horizontalPodAutoscaler` flags see the [official HPA docs](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) and the [kOps guides on how to set it up](horizontal_pod_autoscaling.md). For more details on `horizontalPodAutoscaler` flags see the [official HPA docs](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) and the [kOps guides on how to set it up](horizontal_pod_autoscaling.md).
### LogFormat
Choose between log format. Permitted formats: "json", "text". Default: "text".
```yaml
spec:
kubeControllerManager:
logFormat: json
```
## Feature Gates ## Feature Gates
Feature gates can be configured on the kubelet. Feature gates can be configured on the kubelet.

View File

@ -1510,6 +1510,10 @@ spec:
items: items:
type: string type: string
type: array type: array
logFormat:
description: 'LogFormat is the logging format of the api. Supported
values: text, json. Default: text'
type: string
logLevel: logLevel:
description: LogLevel is the logging level of the api description: LogLevel is the logging level of the api
format: int32 format: int32
@ -1917,6 +1921,10 @@ spec:
is enabled. is enabled.
type: string type: string
type: object type: object
logFormat:
description: 'LogFormat is the logging format of the controler
manager. Supported values: text, json. Default: text'
type: string
logLevel: logLevel:
description: LogLevel is the defined logLevel description: LogLevel is the defined logLevel
format: int32 format: int32
@ -2259,6 +2267,10 @@ spec:
is enabled. is enabled.
type: string type: string
type: object type: object
logFormat:
description: 'LogFormat is the logging format of the scheduler.
Supported values: text, json. Default: text'
type: string
logLevel: logLevel:
description: LogLevel is the logging level description: LogLevel is the logging level
format: int32 format: int32
@ -2504,6 +2516,10 @@ spec:
description: KubeletCgroups is the absolute name of cgroups to description: KubeletCgroups is the absolute name of cgroups to
isolate the kubelet in. isolate the kubelet in.
type: string type: string
logFormat:
description: 'LogFormat is the logging format of the kubelet.
Supported values: text, json. Default: text'
type: string
logLevel: logLevel:
description: LogLevel is the logging level of the kubelet description: LogLevel is the logging level of the kubelet
format: int32 format: int32
@ -2910,6 +2926,10 @@ spec:
description: KubeletCgroups is the absolute name of cgroups to description: KubeletCgroups is the absolute name of cgroups to
isolate the kubelet in. isolate the kubelet in.
type: string type: string
logFormat:
description: 'LogFormat is the logging format of the kubelet.
Supported values: text, json. Default: text'
type: string
logLevel: logLevel:
description: LogLevel is the logging level of the kubelet description: LogLevel is the logging level of the kubelet
format: int32 format: int32

View File

@ -470,6 +470,10 @@ spec:
description: KubeletCgroups is the absolute name of cgroups to description: KubeletCgroups is the absolute name of cgroups to
isolate the kubelet in. isolate the kubelet in.
type: string type: string
logFormat:
description: 'LogFormat is the logging format of the kubelet.
Supported values: text, json. Default: text'
type: string
logLevel: logLevel:
description: LogLevel is the logging level of the kubelet description: LogLevel is the logging level of the kubelet
format: int32 format: int32

View File

@ -45,6 +45,10 @@ type KubeletConfigSpec struct {
KubeconfigPath string `json:"kubeconfigPath,omitempty" flag:"kubeconfig"` KubeconfigPath string `json:"kubeconfigPath,omitempty" flag:"kubeconfig"`
// RequireKubeconfig indicates a kubeconfig is required // RequireKubeconfig indicates a kubeconfig is required
RequireKubeconfig *bool `json:"requireKubeconfig,omitempty" flag:"require-kubeconfig"` RequireKubeconfig *bool `json:"requireKubeconfig,omitempty" flag:"require-kubeconfig"`
// LogFormat is the logging format of the kubelet.
// Supported values: text, json.
// Default: text
LogFormat string `json:"logFormat,omitempty" flag:"logging-format" flag-empty:"text"`
// LogLevel is the logging level of the kubelet // LogLevel is the logging level of the kubelet
LogLevel *int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` LogLevel *int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"`
// config is the path to the config file or directory of files // config is the path to the config file or directory of files
@ -269,6 +273,10 @@ type KubeAPIServerConfig struct {
Image string `json:"image,omitempty"` Image string `json:"image,omitempty"`
// DisableBasicAuth removes the --basic-auth-file flag // DisableBasicAuth removes the --basic-auth-file flag
DisableBasicAuth *bool `json:"disableBasicAuth,omitempty"` DisableBasicAuth *bool `json:"disableBasicAuth,omitempty"`
// LogFormat is the logging format of the api.
// Supported values: text, json.
// Default: text
LogFormat string `json:"logFormat,omitempty" flag:"logging-format" flag-empty:"text"`
// LogLevel is the logging level of the api // LogLevel is the logging level of the api
LogLevel int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` LogLevel int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"`
// CloudProvider is the name of the cloudProvider we are using, aws, gce etcd // CloudProvider is the name of the cloudProvider we are using, aws, gce etcd
@ -511,6 +519,10 @@ type KubeAPIServerConfig struct {
type KubeControllerManagerConfig struct { type KubeControllerManagerConfig struct {
// Master is the url for the kube api master // Master is the url for the kube api master
Master string `json:"master,omitempty" flag:"master"` Master string `json:"master,omitempty" flag:"master"`
// LogFormat is the logging format of the controler manager.
// Supported values: text, json.
// Default: text
LogFormat string `json:"logFormat,omitempty" flag:"logging-format" flag-empty:"text"`
// LogLevel is the defined logLevel // LogLevel is the defined logLevel
LogLevel int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` LogLevel int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"`
// ServiceAccountPrivateKeyFile is the location of the private key for service account token signing. // ServiceAccountPrivateKeyFile is the location of the private key for service account token signing.
@ -663,6 +675,10 @@ type CloudControllerManagerConfig struct {
type KubeSchedulerConfig struct { type KubeSchedulerConfig struct {
// Master is a url to the kube master // Master is a url to the kube master
Master string `json:"master,omitempty" flag:"master"` Master string `json:"master,omitempty" flag:"master"`
// LogFormat is the logging format of the scheduler.
// Supported values: text, json.
// Default: text
LogFormat string `json:"logFormat,omitempty" flag:"logging-format" flag-empty:"text"`
// LogLevel is the logging level // LogLevel is the logging level
LogLevel int32 `json:"logLevel,omitempty" flag:"v"` LogLevel int32 `json:"logLevel,omitempty" flag:"v"`
// Image is the docker image to use // Image is the docker image to use

View File

@ -45,6 +45,10 @@ type KubeletConfigSpec struct {
KubeconfigPath string `json:"kubeconfigPath,omitempty" flag:"kubeconfig"` KubeconfigPath string `json:"kubeconfigPath,omitempty" flag:"kubeconfig"`
// RequireKubeconfig indicates a kubeconfig is required // RequireKubeconfig indicates a kubeconfig is required
RequireKubeconfig *bool `json:"requireKubeconfig,omitempty" flag:"require-kubeconfig"` RequireKubeconfig *bool `json:"requireKubeconfig,omitempty" flag:"require-kubeconfig"`
// LogFormat is the logging format of the kubelet.
// Supported values: text, json.
// Default: text
LogFormat string `json:"logFormat,omitempty" flag:"logging-format" flag-empty:"text"`
// LogLevel is the logging level of the kubelet // LogLevel is the logging level of the kubelet
LogLevel *int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` LogLevel *int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"`
// config is the path to the config file or directory of files // config is the path to the config file or directory of files
@ -269,6 +273,10 @@ type KubeAPIServerConfig struct {
Image string `json:"image,omitempty"` Image string `json:"image,omitempty"`
// DisableBasicAuth removes the --basic-auth-file flag // DisableBasicAuth removes the --basic-auth-file flag
DisableBasicAuth *bool `json:"disableBasicAuth,omitempty"` DisableBasicAuth *bool `json:"disableBasicAuth,omitempty"`
// LogFormat is the logging format of the api.
// Supported values: text, json.
// Default: text
LogFormat string `json:"logFormat,omitempty" flag:"logging-format" flag-empty:"text"`
// LogLevel is the logging level of the api // LogLevel is the logging level of the api
LogLevel int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` LogLevel int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"`
// CloudProvider is the name of the cloudProvider we are using, aws, gce etcd // CloudProvider is the name of the cloudProvider we are using, aws, gce etcd
@ -511,6 +519,10 @@ type KubeAPIServerConfig struct {
type KubeControllerManagerConfig struct { type KubeControllerManagerConfig struct {
// Master is the url for the kube api master // Master is the url for the kube api master
Master string `json:"master,omitempty" flag:"master"` Master string `json:"master,omitempty" flag:"master"`
// LogFormat is the logging format of the controler manager.
// Supported values: text, json.
// Default: text
LogFormat string `json:"logFormat,omitempty" flag:"logging-format" flag-empty:"text"`
// LogLevel is the defined logLevel // LogLevel is the defined logLevel
LogLevel int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` LogLevel int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"`
// ServiceAccountPrivateKeyFile is the location of the private key for service account token signing. // ServiceAccountPrivateKeyFile is the location of the private key for service account token signing.
@ -662,6 +674,10 @@ type CloudControllerManagerConfig struct {
type KubeSchedulerConfig struct { type KubeSchedulerConfig struct {
// Master is a url to the kube master // Master is a url to the kube master
Master string `json:"master,omitempty" flag:"master"` Master string `json:"master,omitempty" flag:"master"`
// LogFormat is the logging format of the scheduler.
// Supported values: text, json.
// Default: text
LogFormat string `json:"logFormat,omitempty" flag:"logging-format" flag-empty:"text"`
// LogLevel is the logging level // LogLevel is the logging level
LogLevel int32 `json:"logLevel,omitempty" flag:"v"` LogLevel int32 `json:"logLevel,omitempty" flag:"v"`
// Image is the docker image to use // Image is the docker image to use

View File

@ -4587,6 +4587,7 @@ func Convert_kops_KopeioNetworkingSpec_To_v1alpha2_KopeioNetworkingSpec(in *kops
func autoConvert_v1alpha2_KubeAPIServerConfig_To_kops_KubeAPIServerConfig(in *KubeAPIServerConfig, out *kops.KubeAPIServerConfig, s conversion.Scope) error { func autoConvert_v1alpha2_KubeAPIServerConfig_To_kops_KubeAPIServerConfig(in *KubeAPIServerConfig, out *kops.KubeAPIServerConfig, s conversion.Scope) error {
out.Image = in.Image out.Image = in.Image
out.DisableBasicAuth = in.DisableBasicAuth out.DisableBasicAuth = in.DisableBasicAuth
out.LogFormat = in.LogFormat
out.LogLevel = in.LogLevel out.LogLevel = in.LogLevel
out.CloudProvider = in.CloudProvider out.CloudProvider = in.CloudProvider
out.SecurePort = in.SecurePort out.SecurePort = in.SecurePort
@ -4697,6 +4698,7 @@ func Convert_v1alpha2_KubeAPIServerConfig_To_kops_KubeAPIServerConfig(in *KubeAP
func autoConvert_kops_KubeAPIServerConfig_To_v1alpha2_KubeAPIServerConfig(in *kops.KubeAPIServerConfig, out *KubeAPIServerConfig, s conversion.Scope) error { func autoConvert_kops_KubeAPIServerConfig_To_v1alpha2_KubeAPIServerConfig(in *kops.KubeAPIServerConfig, out *KubeAPIServerConfig, s conversion.Scope) error {
out.Image = in.Image out.Image = in.Image
out.DisableBasicAuth = in.DisableBasicAuth out.DisableBasicAuth = in.DisableBasicAuth
out.LogFormat = in.LogFormat
out.LogLevel = in.LogLevel out.LogLevel = in.LogLevel
out.CloudProvider = in.CloudProvider out.CloudProvider = in.CloudProvider
out.SecurePort = in.SecurePort out.SecurePort = in.SecurePort
@ -4806,6 +4808,7 @@ func Convert_kops_KubeAPIServerConfig_To_v1alpha2_KubeAPIServerConfig(in *kops.K
func autoConvert_v1alpha2_KubeControllerManagerConfig_To_kops_KubeControllerManagerConfig(in *KubeControllerManagerConfig, out *kops.KubeControllerManagerConfig, s conversion.Scope) error { func autoConvert_v1alpha2_KubeControllerManagerConfig_To_kops_KubeControllerManagerConfig(in *KubeControllerManagerConfig, out *kops.KubeControllerManagerConfig, s conversion.Scope) error {
out.Master = in.Master out.Master = in.Master
out.LogFormat = in.LogFormat
out.LogLevel = in.LogLevel out.LogLevel = in.LogLevel
out.ServiceAccountPrivateKeyFile = in.ServiceAccountPrivateKeyFile out.ServiceAccountPrivateKeyFile = in.ServiceAccountPrivateKeyFile
out.Image = in.Image out.Image = in.Image
@ -4872,6 +4875,7 @@ func Convert_v1alpha2_KubeControllerManagerConfig_To_kops_KubeControllerManagerC
func autoConvert_kops_KubeControllerManagerConfig_To_v1alpha2_KubeControllerManagerConfig(in *kops.KubeControllerManagerConfig, out *KubeControllerManagerConfig, s conversion.Scope) error { func autoConvert_kops_KubeControllerManagerConfig_To_v1alpha2_KubeControllerManagerConfig(in *kops.KubeControllerManagerConfig, out *KubeControllerManagerConfig, s conversion.Scope) error {
out.Master = in.Master out.Master = in.Master
out.LogFormat = in.LogFormat
out.LogLevel = in.LogLevel out.LogLevel = in.LogLevel
out.ServiceAccountPrivateKeyFile = in.ServiceAccountPrivateKeyFile out.ServiceAccountPrivateKeyFile = in.ServiceAccountPrivateKeyFile
out.Image = in.Image out.Image = in.Image
@ -5062,6 +5066,7 @@ func Convert_kops_KubeProxyConfig_To_v1alpha2_KubeProxyConfig(in *kops.KubeProxy
func autoConvert_v1alpha2_KubeSchedulerConfig_To_kops_KubeSchedulerConfig(in *KubeSchedulerConfig, out *kops.KubeSchedulerConfig, s conversion.Scope) error { func autoConvert_v1alpha2_KubeSchedulerConfig_To_kops_KubeSchedulerConfig(in *KubeSchedulerConfig, out *kops.KubeSchedulerConfig, s conversion.Scope) error {
out.Master = in.Master out.Master = in.Master
out.LogFormat = in.LogFormat
out.LogLevel = in.LogLevel out.LogLevel = in.LogLevel
out.Image = in.Image out.Image = in.Image
if in.LeaderElection != nil { if in.LeaderElection != nil {
@ -5092,6 +5097,7 @@ func Convert_v1alpha2_KubeSchedulerConfig_To_kops_KubeSchedulerConfig(in *KubeSc
func autoConvert_kops_KubeSchedulerConfig_To_v1alpha2_KubeSchedulerConfig(in *kops.KubeSchedulerConfig, out *KubeSchedulerConfig, s conversion.Scope) error { func autoConvert_kops_KubeSchedulerConfig_To_v1alpha2_KubeSchedulerConfig(in *kops.KubeSchedulerConfig, out *KubeSchedulerConfig, s conversion.Scope) error {
out.Master = in.Master out.Master = in.Master
out.LogFormat = in.LogFormat
out.LogLevel = in.LogLevel out.LogLevel = in.LogLevel
out.Image = in.Image out.Image = in.Image
if in.LeaderElection != nil { if in.LeaderElection != nil {
@ -5132,6 +5138,7 @@ func autoConvert_v1alpha2_KubeletConfigSpec_To_kops_KubeletConfigSpec(in *Kubele
out.TLSMinVersion = in.TLSMinVersion out.TLSMinVersion = in.TLSMinVersion
out.KubeconfigPath = in.KubeconfigPath out.KubeconfigPath = in.KubeconfigPath
out.RequireKubeconfig = in.RequireKubeconfig out.RequireKubeconfig = in.RequireKubeconfig
out.LogFormat = in.LogFormat
out.LogLevel = in.LogLevel out.LogLevel = in.LogLevel
out.PodManifestPath = in.PodManifestPath out.PodManifestPath = in.PodManifestPath
out.HostnameOverride = in.HostnameOverride out.HostnameOverride = in.HostnameOverride
@ -5226,6 +5233,7 @@ func autoConvert_kops_KubeletConfigSpec_To_v1alpha2_KubeletConfigSpec(in *kops.K
out.TLSMinVersion = in.TLSMinVersion out.TLSMinVersion = in.TLSMinVersion
out.KubeconfigPath = in.KubeconfigPath out.KubeconfigPath = in.KubeconfigPath
out.RequireKubeconfig = in.RequireKubeconfig out.RequireKubeconfig = in.RequireKubeconfig
out.LogFormat = in.LogFormat
out.LogLevel = in.LogLevel out.LogLevel = in.LogLevel
out.PodManifestPath = in.PodManifestPath out.PodManifestPath = in.PodManifestPath
out.HostnameOverride = in.HostnameOverride out.HostnameOverride = in.HostnameOverride

View File

@ -574,6 +574,11 @@ func validateKubeAPIServer(v *kops.KubeAPIServerConfig, c *kops.Cluster, fldPath
} }
} }
} }
if v.LogFormat != "" {
allErrs = append(allErrs, IsValidValue(fldPath.Child("logFormat"), &v.LogFormat, []string{"text", "json"})...)
}
return allErrs return allErrs
} }
@ -637,6 +642,10 @@ func validateKubelet(k *kops.KubeletConfigSpec, c *kops.Cluster, kubeletPath *fi
} }
} }
if k.LogFormat != "" {
allErrs = append(allErrs, IsValidValue(kubeletPath.Child("logFormat"), &k.LogFormat, []string{"text", "json"})...)
}
} }
return allErrs return allErrs
} }

View File

@ -289,6 +289,12 @@ func TestValidateKubeAPIServer(t *testing.T) {
"Unsupported value::KubeAPIServer.authorizationMode", "Unsupported value::KubeAPIServer.authorizationMode",
}, },
}, },
{
Input: kops.KubeAPIServerConfig{
LogFormat: "no-json",
},
ExpectedErrors: []string{"Unsupported value::KubeAPIServer.logFormat"},
},
} }
for _, g := range grid { for _, g := range grid {
if g.Cluster == nil { if g.Cluster == nil {