diff --git a/docs/cluster_spec.md b/docs/cluster_spec.md index 9658b0fb51..8969a6ccd2 100644 --- a/docs/cluster_spec.md +++ b/docs/cluster_spec.md @@ -554,6 +554,16 @@ spec: defaultUnreachableTolerationSeconds: 600 ``` +### LogFormat + +Choose between log format. Permitted formats: "json", "text". Default: "text". + +```yaml +spec: + kubeAPIServer: + logFormat: json +``` + ## externalDns This block contains configuration options for your `external-DNS` provider. @@ -698,6 +708,16 @@ spec: eventBurst: 10 ``` +### LogFormat + +Choose between log format. Permitted formats: "json", "text". Default: "text". + +```yaml +spec: + kubelet: + logFormat: json +``` + ## kubeScheduler 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. +### LogFormat + +Choose between log format. Permitted formats: "json", "text". Default: "text". + +```yaml +spec: + kubeScheduler: + logFormat: json +``` + ## kubeDNS 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). +### LogFormat + +Choose between log format. Permitted formats: "json", "text". Default: "text". + +```yaml +spec: + kubeControllerManager: + logFormat: json +``` + ## Feature Gates Feature gates can be configured on the kubelet. @@ -1322,7 +1362,7 @@ The `discoveryStore` option causes kOps to publish an OIDC-compatible discovery to a path in an S3 bucket. This would ordinarily be a different bucket than the state store. kOps will automatically configure `spec.kubeAPIServer.serviceAccountIssuer` and default `spec.kubeAPIServer.serviceAccountJWKSURI` to the corresponding -HTTPS URL. +HTTPS URL. The `enableAWSOIDCProvider` configures AWS to trust the service account issuer to authenticate service accounts for IAM Roles for Service Accounts (IRSA). In order for this to work, diff --git a/k8s/crds/kops.k8s.io_clusters.yaml b/k8s/crds/kops.k8s.io_clusters.yaml index de117eb23c..c30d49dfbb 100644 --- a/k8s/crds/kops.k8s.io_clusters.yaml +++ b/k8s/crds/kops.k8s.io_clusters.yaml @@ -1510,6 +1510,10 @@ spec: items: type: string type: array + logFormat: + description: 'LogFormat is the logging format of the api. Supported + values: text, json. Default: text' + type: string logLevel: description: LogLevel is the logging level of the api format: int32 @@ -1917,6 +1921,10 @@ spec: is enabled. type: string type: object + logFormat: + description: 'LogFormat is the logging format of the controler + manager. Supported values: text, json. Default: text' + type: string logLevel: description: LogLevel is the defined logLevel format: int32 @@ -2259,6 +2267,10 @@ spec: is enabled. type: string type: object + logFormat: + description: 'LogFormat is the logging format of the scheduler. + Supported values: text, json. Default: text' + type: string logLevel: description: LogLevel is the logging level format: int32 @@ -2504,6 +2516,10 @@ spec: description: KubeletCgroups is the absolute name of cgroups to isolate the kubelet in. type: string + logFormat: + description: 'LogFormat is the logging format of the kubelet. + Supported values: text, json. Default: text' + type: string logLevel: description: LogLevel is the logging level of the kubelet format: int32 @@ -2910,6 +2926,10 @@ spec: description: KubeletCgroups is the absolute name of cgroups to isolate the kubelet in. type: string + logFormat: + description: 'LogFormat is the logging format of the kubelet. + Supported values: text, json. Default: text' + type: string logLevel: description: LogLevel is the logging level of the kubelet format: int32 diff --git a/k8s/crds/kops.k8s.io_instancegroups.yaml b/k8s/crds/kops.k8s.io_instancegroups.yaml index b4335ba1ca..d8388b4619 100644 --- a/k8s/crds/kops.k8s.io_instancegroups.yaml +++ b/k8s/crds/kops.k8s.io_instancegroups.yaml @@ -470,6 +470,10 @@ spec: description: KubeletCgroups is the absolute name of cgroups to isolate the kubelet in. type: string + logFormat: + description: 'LogFormat is the logging format of the kubelet. + Supported values: text, json. Default: text' + type: string logLevel: description: LogLevel is the logging level of the kubelet format: int32 diff --git a/pkg/apis/kops/componentconfig.go b/pkg/apis/kops/componentconfig.go index e23c338e2c..195fa04a72 100644 --- a/pkg/apis/kops/componentconfig.go +++ b/pkg/apis/kops/componentconfig.go @@ -45,6 +45,10 @@ type KubeletConfigSpec struct { KubeconfigPath string `json:"kubeconfigPath,omitempty" flag:"kubeconfig"` // RequireKubeconfig indicates a kubeconfig is required 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 *int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` // config is the path to the config file or directory of files @@ -269,6 +273,10 @@ type KubeAPIServerConfig struct { Image string `json:"image,omitempty"` // DisableBasicAuth removes the --basic-auth-file flag 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 int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` // CloudProvider is the name of the cloudProvider we are using, aws, gce etcd @@ -511,6 +519,10 @@ type KubeAPIServerConfig struct { type KubeControllerManagerConfig struct { // Master is the url for the kube api 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 int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` // ServiceAccountPrivateKeyFile is the location of the private key for service account token signing. @@ -663,6 +675,10 @@ type CloudControllerManagerConfig struct { type KubeSchedulerConfig struct { // Master is a url to the kube 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 int32 `json:"logLevel,omitempty" flag:"v"` // Image is the docker image to use diff --git a/pkg/apis/kops/v1alpha2/componentconfig.go b/pkg/apis/kops/v1alpha2/componentconfig.go index 799f149f92..3669623938 100644 --- a/pkg/apis/kops/v1alpha2/componentconfig.go +++ b/pkg/apis/kops/v1alpha2/componentconfig.go @@ -45,6 +45,10 @@ type KubeletConfigSpec struct { KubeconfigPath string `json:"kubeconfigPath,omitempty" flag:"kubeconfig"` // RequireKubeconfig indicates a kubeconfig is required 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 *int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` // config is the path to the config file or directory of files @@ -269,6 +273,10 @@ type KubeAPIServerConfig struct { Image string `json:"image,omitempty"` // DisableBasicAuth removes the --basic-auth-file flag 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 int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` // CloudProvider is the name of the cloudProvider we are using, aws, gce etcd @@ -511,6 +519,10 @@ type KubeAPIServerConfig struct { type KubeControllerManagerConfig struct { // Master is the url for the kube api 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 int32 `json:"logLevel,omitempty" flag:"v" flag-empty:"0"` // ServiceAccountPrivateKeyFile is the location of the private key for service account token signing. @@ -662,6 +674,10 @@ type CloudControllerManagerConfig struct { type KubeSchedulerConfig struct { // Master is a url to the kube 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 int32 `json:"logLevel,omitempty" flag:"v"` // Image is the docker image to use diff --git a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go index 16ac72caf1..980ab2cb3e 100644 --- a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go @@ -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 { out.Image = in.Image out.DisableBasicAuth = in.DisableBasicAuth + out.LogFormat = in.LogFormat out.LogLevel = in.LogLevel out.CloudProvider = in.CloudProvider 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 { out.Image = in.Image out.DisableBasicAuth = in.DisableBasicAuth + out.LogFormat = in.LogFormat out.LogLevel = in.LogLevel out.CloudProvider = in.CloudProvider 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 { out.Master = in.Master + out.LogFormat = in.LogFormat out.LogLevel = in.LogLevel out.ServiceAccountPrivateKeyFile = in.ServiceAccountPrivateKeyFile 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 { out.Master = in.Master + out.LogFormat = in.LogFormat out.LogLevel = in.LogLevel out.ServiceAccountPrivateKeyFile = in.ServiceAccountPrivateKeyFile 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 { out.Master = in.Master + out.LogFormat = in.LogFormat out.LogLevel = in.LogLevel out.Image = in.Image 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 { out.Master = in.Master + out.LogFormat = in.LogFormat out.LogLevel = in.LogLevel out.Image = in.Image if in.LeaderElection != nil { @@ -5132,6 +5138,7 @@ func autoConvert_v1alpha2_KubeletConfigSpec_To_kops_KubeletConfigSpec(in *Kubele out.TLSMinVersion = in.TLSMinVersion out.KubeconfigPath = in.KubeconfigPath out.RequireKubeconfig = in.RequireKubeconfig + out.LogFormat = in.LogFormat out.LogLevel = in.LogLevel out.PodManifestPath = in.PodManifestPath out.HostnameOverride = in.HostnameOverride @@ -5226,6 +5233,7 @@ func autoConvert_kops_KubeletConfigSpec_To_v1alpha2_KubeletConfigSpec(in *kops.K out.TLSMinVersion = in.TLSMinVersion out.KubeconfigPath = in.KubeconfigPath out.RequireKubeconfig = in.RequireKubeconfig + out.LogFormat = in.LogFormat out.LogLevel = in.LogLevel out.PodManifestPath = in.PodManifestPath out.HostnameOverride = in.HostnameOverride diff --git a/pkg/apis/kops/validation/validation.go b/pkg/apis/kops/validation/validation.go index 652fe8e202..8fa5c3bc5c 100644 --- a/pkg/apis/kops/validation/validation.go +++ b/pkg/apis/kops/validation/validation.go @@ -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 } @@ -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 } diff --git a/pkg/apis/kops/validation/validation_test.go b/pkg/apis/kops/validation/validation_test.go index 7e502b4796..e1786cccab 100644 --- a/pkg/apis/kops/validation/validation_test.go +++ b/pkg/apis/kops/validation/validation_test.go @@ -289,6 +289,12 @@ func TestValidateKubeAPIServer(t *testing.T) { "Unsupported value::KubeAPIServer.authorizationMode", }, }, + { + Input: kops.KubeAPIServerConfig{ + LogFormat: "no-json", + }, + ExpectedErrors: []string{"Unsupported value::KubeAPIServer.logFormat"}, + }, } for _, g := range grid { if g.Cluster == nil {