This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Description
Logging:
To align with the upstream Kubernetes community CAPI now configures logging via component-base/logs. This provides advantages like support for the JSON logging format (via --logging-format=json) and automatic deprecation of klog flags aligned to the upstream Kubernetes deprecation period.
View main.go diff
import (
...
+ "k8s.io/component-base/logs"
+ _ "k8s.io/component-base/logs/json/register"
)
var (
...
+ logOptions = logs.NewOptions()
)
func init() {
- klog.InitFlags(nil)
func InitFlags(fs *pflag.FlagSet) {
+ logs.AddFlags(fs, logs.SkipLoggingConfigurationFlags())
+ logOptions.AddFlags(fs)
func main() {
...
pflag.Parse()
+ if err := logOptions.ValidateAndApply(); err != nil {
+ setupLog.Error(err, "unable to start manager")
+ os.Exit(1)
+ }
+
+ // klog.Background will automatically use the right logger.
+ ctrl.SetLogger(klog.Background())
- ctrl.SetLogger(klogr.New())
This change has been introduced in CAPI in the following PRs: #6072, #6190, #6602.
Note: This change is not mandatory for providers, but highly recommended.
/kind feature