deprecation of klog flags and changes in k8s.io/component-base/logs

68 views
Skip to first unread message

Patrick Ohly

unread,
Jan 31, 2022, 4:56:53 AM1/31/22
to d...@kubernetes.io
Hello!

As mentioned in the Kubernetes 1.23 release notes, klog specific flags
were marked as deprecated and will be removed eventually. User-facing
documentation about that change is here:
https://kubernetes.io/docs/concepts/cluster-administration/system-logs/#klog

In preparation for that, k8s.io/component-base/logs was updated. This is
relevant for developers who use that package and some action is required
during dependency updates:

Beware that merely importing k8s.io/component-base/logs no longer
registers the klog flags automatically. If you want to remove the flags
gradually (i.e. declare them as deprecated first, then remove them
later), then use AddFlags from k8s.io/component-base/logs to register
the flags in a pflag.FlagSet or AddGoFlags for a standard flag.FlagSet.
Otherwise just update and the flags will be gone immediately.

The current plan is to remove support for the legacy klog flags in
Kubernetes 1.26. These two functions will still be there and just not
add the legacy flags anymore, so no further action will be required at
that time.

Another change in 1.23 was that validating and applying the non-klog
logging options like --logging-format was moved into a single
Options.ValidateAndApply. That method should be called as soon as
possible after flag parsing to ensure that log output is set up as
intended before other command initialization code writes log entries.

The following example shows how to use these APIs:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/component-base/logs/example/cmd/logger.go

--
Best Regards

Patrick Ohly

Hongcai Ren

unread,
Feb 7, 2022, 2:59:19 AM2/7/22
to dev, Patrick Ohly
Thanks, Patrick, very useful notice.
Reply all
Reply to author
Forward
0 new messages