Skip to content

Commit a5c4c07

Browse files
committed
Initial draft of KEP-2845 Deprecate klog specific flags in k8s components
1 parent 3317d4c commit a5c4c07

File tree

2 files changed

+266
-0
lines changed
  • keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components

2 files changed

+266
-0
lines changed
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# KEP-2845: Deprecate klog specific flags in Kubernetes Compnents
2+
3+
<!-- toc -->
4+
- [Release Signoff Checklist](#release-signoff-checklist)
5+
- [Summary](#summary)
6+
- [Motivation](#motivation)
7+
- [Goals](#goals)
8+
- [Non-Goals](#non-goals)
9+
- [Proposal](#proposal)
10+
- [User Stories](#user-stories)
11+
- [Writing logs to files](#writing-logs-to-files)
12+
- [Caveats](#caveats)
13+
- [Risks and Mitigations](#risks-and-mitigations)
14+
- [Users don't want to use go-runner as replacement.](#users-dont-want-to-use-go-runner-as-replacement)
15+
- [Log processing in parent process causes performance problems](#log-processing-in-parent-process-causes-performance-problems)
16+
- [Design Details](#design-details)
17+
- [Test Plan](#test-plan)
18+
- [Graduation Criteria](#graduation-criteria)
19+
- [Alpha](#alpha)
20+
- [Beta](#beta)
21+
- [GA](#ga)
22+
- [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy)
23+
- [Version Skew Strategy](#version-skew-strategy)
24+
- [Implementation History](#implementation-history)
25+
- [Drawbacks](#drawbacks)
26+
- [Alternatives](#alternatives)
27+
- [Continue supporting all klog features](#continue-supporting-all-klog-features)
28+
- [Release klog 3.0 with removed features](#release-klog-30-with-removed-features)
29+
<!-- /toc -->
30+
31+
## Release Signoff Checklist
32+
33+
Items marked with (R) are required *prior to targeting to a milestone / release*.
34+
35+
- [ ] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR)
36+
- [ ] (R) KEP approvers have approved the KEP status as `implementable`
37+
- [ ] (R) Design details are appropriately documented
38+
- [ ] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input (including test refactors)
39+
- [ ] e2e Tests for all Beta API Operations (endpoints)
40+
- [ ] (R) Ensure GA e2e tests for meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
41+
- [ ] (R) Minimum Two Week Window for GA e2e tests to prove flake free
42+
- [ ] (R) Graduation criteria is in place
43+
- [ ] (R) [all GA Endpoints](https://github.com/kubernetes/community/pull/1806) must be hit by [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
44+
- [ ] (R) Production readiness review completed
45+
- [ ] (R) Production readiness review approved
46+
- [ ] "Implementation History" section is up-to-date for milestone
47+
- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io]
48+
- [ ] Supporting documentation—e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes
49+
50+
[kubernetes.io]: https://kubernetes.io/
51+
[kubernetes/enhancements]: https://git.k8s.io/enhancements
52+
[kubernetes/kubernetes]: https://git.k8s.io/kubernetes
53+
[kubernetes/website]: https://git.k8s.io/website
54+
55+
## Summary
56+
57+
This KEP proposes to deprecate and in the future to remove a subset of the klog
58+
command line flags from Kubernetes components to encourage more diverse
59+
approaches to logging in kubernetes ecosystem logging.
60+
61+
## Motivation
62+
63+
Early on Kubernetes adopted glog logging library for logging. Overtime the glog
64+
was forked to klog and multiple improvements were implemented, but features put
65+
into klog only piled up and were never removed. Introduction of alternative log
66+
formats like JSON created a conundrum, should we implement all klog features for
67+
JSON? Most of them don't make sense and method for their configuration leaves
68+
much to be desired. Klog features are controlled by set of global flags that
69+
remain last bastion of global state in k/k repository. Those flags don't have a
70+
single naming standard (some start with log prefix, some not), don't comply to
71+
k8s flag naming (use underscore instead of hyphen) and many other problems. We
72+
need to revisit how logging configuration is done in klog so it can work with
73+
alternative log formats and comply with current best practices.
74+
75+
Large number of features added to klog has lead to large drop in quality.
76+
[#90804](https://github.com/kubernetes/kubernetes/pull/90804) shows example
77+
where kubeup (canonical way to deploy kubernetes for testing) could not use
78+
klog feature to write log files due to scalability issues. The maintainers of
79+
klog decided it's easier to re-implementing a canonical klog feature in external
80+
project than debugging the underlying problem.
81+
82+
As for what configuration options should be standardized for all logging formats
83+
I would look into 12 factor app standard (https://12factor.net/). It defines
84+
logs as steams of events and discourages applications from taking on
85+
responsibility for log file management, log rotation and any other processing
86+
that can be done externally. This is something that Kubernetes already
87+
encourages by collecting stdout and stderr logs and making them available via
88+
kubectl logs. It's somewhat confusing that K8s components don't comply to K8s
89+
best practices.
90+
91+
### Goals
92+
93+
* Unblock development of alternative logging formats
94+
* Improve quality of logging in k8s core components
95+
* Logging should use configuration mechanism developed by WG component-standard
96+
97+
### Non-Goals
98+
99+
* Change klog output format
100+
101+
## Proposal
102+
103+
I propose that Kubernetes core components (kube-apiserver, kube-scheduler,
104+
kube-controller-manager, kubelet) should drop flags that extend
105+
logging over events streams or klog specific features. This change should be
106+
scoped to only those components and not affect broader klog community.
107+
108+
Flags that should be deprecated:
109+
110+
* --log-dir, --log-file, --log-flush-frequency - responsible for writing to
111+
files and syncs to disk.
112+
Motivation: Remove complexity to make alternative loggers easier to implement
113+
and reducing feature surface to improve quality.
114+
* --logtostderr, --alsologtostderr, --one-output, --stderrthreshold -
115+
responsible enabling/disabling writing to stderr (vs file).
116+
Motivation: Not needed if writing to files is removed.
117+
* --log-file-max-size, --skip-log-headers - responsible configuration of file
118+
rotation.
119+
Motivation: Not needed if writing to files is removed.
120+
* --add-dir-header, --skip-headers - klog format specific flags .
121+
Motivation: don't apply to other log formats
122+
* --log-backtrace-at - an legacy glog feature.
123+
Motivation: No trace of anyone using this feature.
124+
125+
Flag deprecation should comply with standard k8s policy and require 3 releases before removal.
126+
127+
This leaves that two flags that should be implemented by all log formats
128+
129+
* -v - control global log verbosity of Info logs
130+
* --vmodule - control log verbosity of Info logs on per file level
131+
132+
Those flags were chosen as they have direct effect of which logs are written,
133+
directly impacting log volume and component performance.
134+
135+
### User Stories
136+
137+
#### Writing logs to files
138+
139+
We should use go-runner as a official fallback for users that want to retain
140+
writing logs to files. go-runner runs as parent process to components binary
141+
reading it's stdout/stderr and is able to route them to files. go-runner is
142+
already released as part of official K8s images it should be as simple as changing:
143+
144+
```
145+
/usr/local/bin/kube-apiserver --log-file=/var/log/kube-apiserver.log
146+
```
147+
148+
to
149+
150+
```
151+
/go-runner --log-file=/var/log/kube-apiserver.log /usr/local/bin/kube-apiserver
152+
```
153+
154+
### Caveats
155+
156+
Is it ok for K8s components to drop support for subset of klog flags?
157+
158+
Technically K8s already doesn't support klog flags. Klog flags are renamed to
159+
comply with K8s flag naming convention (underscores are replaced with hyphens).
160+
Full klog support was never promised to users and removal of those flags should
161+
be treated as removal of any other flag.
162+
163+
Is it ok for K8s components to drop support writing to files?
164+
Writing directly to files is an important feature still used by users, but this
165+
doesn't directly necessitates direct support in components. By providing a
166+
external solution like go-runner we can allow community to develop more advanced
167+
features while maintaining high quality implementation within components.
168+
Having more extendable solution developed externally should be more beneficial
169+
to community when compared to forcing closed list of features on everyone.
170+
171+
### Risks and Mitigations
172+
173+
#### Users don't want to use go-runner as replacement.
174+
175+
TODO
176+
177+
#### Log processing in parent process causes performance problems
178+
179+
TODO
180+
181+
## Design Details
182+
183+
TODO
184+
185+
### Test Plan
186+
187+
Go-runner is already used for scalability tests. We should ensure that we cover
188+
all existing klog features.
189+
190+
### Graduation Criteria
191+
192+
#### Alpha
193+
194+
- Klog can be configured without registering flags
195+
- Kubernetes logging configuration drops global state
196+
- Go-runner is feature complementary to klog flags planned for deprecation
197+
- Projects in Kubernetes Org are migrated to go-runner
198+
199+
#### Beta
200+
201+
- Go-runner project is well maintained and documented
202+
- Documentation on switching go-runner is publicly available
203+
- Kubernetes klog flags are marked as deprecated
204+
205+
#### GA
206+
207+
- Kubernetes klog flags are removed
208+
209+
### Upgrade / Downgrade Strategy
210+
211+
N/A
212+
213+
### Version Skew Strategy
214+
215+
N/A
216+
217+
## Implementation History
218+
219+
- 20/06/2021 - Original proposal created in https://github.com/kubernetes/kubernetes/issues/99270
220+
- 30/07/2021 - First KEP draft was created
221+
222+
## Drawbacks
223+
224+
Deprecating klog features outside klog might create confusion in community.
225+
Large part of community doesn't know that klog was created from necessity and
226+
is not the end goal for logging in Kubernetes. We should do due diligence to
227+
let community know about our plans and their impact on external components
228+
depending on klog.
229+
230+
## Alternatives
231+
232+
### Continue supporting all klog features
233+
At some point we should migrate all logging
234+
configuration to Options or Configuration. Doing so while supporting all klog
235+
features makes their future removal much harder.
236+
237+
### Release klog 3.0 with removed features
238+
Removal of those features cannot be done without whole k8s community instead of
239+
just k8s core components
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
title: Deprecate klog specific flags in Kubernetes components
2+
kep-number: 2845
3+
authors:
4+
- "@serathius"
5+
owning-sig: sig-instrumentation
6+
participating-sigs:
7+
- sig-arch
8+
status: provisional
9+
creation-date: 2021-07-30
10+
reviewers:
11+
- TBD
12+
approvers:
13+
- TBD
14+
15+
see-also:
16+
- "/keps/sig-instrumentation/1602-structured-logging"
17+
replaces: []
18+
stage: alpha
19+
latest-milestone: "v1.23"
20+
milestone:
21+
alpha: "v1.23"
22+
beta: "v1.24"
23+
stable: "v1.25"
24+
25+
feature-gates: []
26+
disable-supported: true
27+
metrics: []

0 commit comments

Comments
 (0)