Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pick #3688 apiserver: move loglevel under spec #3689

Open
wants to merge 2 commits into
base: release-v1.37
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions api/v1/apiserver_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2024 Tigera, Inc. All rights reserved.
// Copyright (c) 2020-2025 Tigera, Inc. All rights reserved.
/*


Expand All @@ -25,6 +25,11 @@ import (

// APIServerSpec defines the desired state of Tigera API server.
type APIServerSpec struct {
// LogSeverity defines log level for APIServer and QueryServer containers.
// +optional
// +kubebuilder:default=Info
LogSeverity *LogSeverity `json:"logSeverity,omitempty"`

// APIServerDeployment configures the calico-apiserver (or tigera-apiserver in Enterprise) Deployment. If
// used in conjunction with ControlPlaneNodeSelector or ControlPlaneTolerations, then these overrides
// take precedence.
Expand Down Expand Up @@ -86,11 +91,6 @@ type APIServerDeploymentContainer struct {
// If used in conjunction with the deprecated ComponentResources, then this value takes precedence.
// +optional
Resources *v1.ResourceRequirements `json:"resources,omitempty"`

// +kubebuilder:validation:Enum=Fatal;Error;Warn;Info;Debug;Trace
// +kubebuilder:default=Info
// +optional
LogLevel *string `json:"logLevel,omitempty"`
}

// APIServerDeploymentInitContainer is an API server Deployment init container.
Expand Down
12 changes: 7 additions & 5 deletions api/v1/common_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022, 2023 Tigera, Inc. All rights reserved.
// Copyright (c) 2022 - 2025 Tigera, Inc. All rights reserved.
/*

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -31,13 +31,15 @@ type Metadata struct {
Annotations map[string]string `json:"annotations,omitempty"`
}

// +kubebuilder:validation:Enum=Error;Warning;Info;Debug
type LogLevel string

const (
LogLevelTrace LogLevel = "Trace"
LogLevelError LogLevel = "Error"
LogLevelWarn LogLevel = "Warn"
LogLevelInfo LogLevel = "Info"
LogLevelDebug LogLevel = "Debug"
LogLevelWarn LogLevel = "Warn"
LogLevelFatal LogLevel = "Fatal"
LogLevelError LogLevel = "Error"
)

// +kubebuilder:validation:Enum=Fatal;Error;Warn;Info;Debug;Trace
type LogSeverity string
6 changes: 2 additions & 4 deletions api/v1/egressgateway_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023-2024 Tigera, Inc. All rights reserved.
// Copyright (c) 2023-2025 Tigera, Inc. All rights reserved.
/*

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -73,11 +73,9 @@ type EgressGatewaySpec struct {
ExternalNetworks []string `json:"externalNetworks,omitempty"`

// LogSeverity defines the logging level of the Egress Gateway.
// Default: Info
// +kubebuilder:validation:Enum=Trace;Debug;Info;Warn;Error;Fatal
// +optional
// +kubebuilder:default:=Info
LogSeverity *LogLevel `json:"logSeverity,omitempty"`
LogSeverity *LogSeverity `json:"logSeverity,omitempty"`

// Template describes the EGW Deployment pod that will be created.
// +optional
Expand Down
3 changes: 1 addition & 2 deletions api/v1/installation_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023-2024 Tigera, Inc. All rights reserved.
// Copyright (c) 2023-2025 Tigera, Inc. All rights reserved.
/*

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -236,7 +236,6 @@ type Logging struct {

type CNILogging struct {
// Default: Info
// +kubebuilder:validation:Enum=Error;Warning;Debug;Info
// +optional
LogSeverity *LogLevel `json:"logSeverity,omitempty"`

Expand Down
12 changes: 6 additions & 6 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions pkg/crds/operator/operator.tigera.io_apiservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1068,16 +1068,6 @@ spec:
description: APIServerDeploymentContainer is an
API server Deployment container.
properties:
logLevel:
default: Info
enum:
- Fatal
- Error
- Warn
- Info
- Debug
- Trace
type: string
name:
description: |-
Name is an enum which identifies the API server Deployment container by name.
Expand Down Expand Up @@ -1458,6 +1448,18 @@ spec:
type: object
type: object
type: object
logSeverity:
default: Info
description: LogSeverity defines log level for APIServer and QueryServer
containers.
enum:
- Fatal
- Error
- Warn
- Info
- Debug
- Trace
type: string
type: object
status:
description: Most recently observed status for the Tigera API server.
Expand Down
14 changes: 6 additions & 8 deletions pkg/crds/operator/operator.tigera.io_egressgateways.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,14 @@ spec:
type: array
logSeverity:
default: Info
description: |-
LogSeverity defines the logging level of the Egress Gateway.
Default: Info
description: LogSeverity defines the logging level of the Egress Gateway.
enum:
- Trace
- Debug
- Info
- Warn
- Error
- Fatal
- Error
- Warn
- Info
- Debug
- Trace
type: string
replicas:
default: 1
Expand Down
4 changes: 2 additions & 2 deletions pkg/crds/operator/operator.tigera.io_installations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6561,8 +6561,8 @@ spec:
enum:
- Error
- Warning
- Debug
- Info
- Debug
type: string
type: object
type: object
Expand Down Expand Up @@ -15008,8 +15008,8 @@ spec:
enum:
- Error
- Warning
- Debug
- Info
- Debug
type: string
type: object
type: object
Expand Down
35 changes: 8 additions & 27 deletions pkg/render/apiserver.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2024 Tigera, Inc. All rights reserved.
// Copyright (c) 2019-2025 Tigera, Inc. All rights reserved.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -19,8 +19,6 @@ import (
"net/url"
"strings"

v3 "github.com/tigera/api/pkg/apis/projectcalico/v3"
"github.com/tigera/api/pkg/lib/numorstring"
admregv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -32,6 +30,8 @@ import (
apiregv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

v3 "github.com/tigera/api/pkg/apis/projectcalico/v3"
"github.com/tigera/api/pkg/lib/numorstring"
operatorv1 "github.com/tigera/operator/api/v1"
"github.com/tigera/operator/pkg/common"
"github.com/tigera/operator/pkg/components"
Expand Down Expand Up @@ -1194,18 +1194,9 @@ func (c *apiServerComponent) apiServerContainer() corev1.Container {
env = append(env, c.cfg.K8SServiceEndpoint.EnvVars(c.hostNetwork(), c.cfg.Installation.KubernetesProvider)...)

// set Log_LEVEL for apiserver container
if c.cfg.APIServer.APIServerDeployment != nil && c.cfg.APIServer.APIServerDeployment.Spec != nil &&
c.cfg.APIServer.APIServerDeployment.Spec.Template != nil &&
c.cfg.APIServer.APIServerDeployment.Spec.Template.Spec != nil &&
c.cfg.APIServer.APIServerDeployment.Spec.Template.Spec.Containers != nil {
containers := c.cfg.APIServer.APIServerDeployment.Spec.Template.Spec.Containers
for _, con := range containers {
if strings.Contains(con.Name, "apiserver") {
if logLevel := con.LogLevel; logLevel != nil {
env = append(env, corev1.EnvVar{Name: "LOG_LEVEL", Value: strings.ToLower(*logLevel)})
}
}
}

if logLevel := c.cfg.APIServer.LogSeverity; logLevel != nil {
env = append(env, corev1.EnvVar{Name: "LOG_LEVEL", Value: strings.ToLower(string(*logLevel))})
} else {
// set default LOG_LEVEL to info when not set by the user
env = append(env, corev1.EnvVar{Name: "LOG_LEVEL", Value: "info"})
Expand Down Expand Up @@ -1301,18 +1292,8 @@ func (c *apiServerComponent) queryServerContainer() corev1.Container {
}

// set Log_LEVEL for queryserver container
if c.cfg.APIServer.APIServerDeployment != nil && c.cfg.APIServer.APIServerDeployment.Spec != nil &&
c.cfg.APIServer.APIServerDeployment.Spec.Template != nil &&
c.cfg.APIServer.APIServerDeployment.Spec.Template.Spec != nil &&
c.cfg.APIServer.APIServerDeployment.Spec.Template.Spec.Containers != nil {
containers := c.cfg.APIServer.APIServerDeployment.Spec.Template.Spec.Containers
for _, con := range containers {
if strings.Contains(con.Name, "queryserver") {
if logLevel := con.LogLevel; logLevel != nil {
env = append(env, corev1.EnvVar{Name: "LOGLEVEL", Value: strings.ToLower(*logLevel)})
}
}
}
if logLevel := c.cfg.APIServer.LogSeverity; logLevel != nil {
env = append(env, corev1.EnvVar{Name: "LOGLEVEL", Value: strings.ToLower(string(*logLevel))})
} else {
// set default LOGLEVEL to info when not set by the user
env = append(env, corev1.EnvVar{Name: "LOGLEVEL", Value: "info"})
Expand Down