@@ -22,12 +22,10 @@ scheduler decisions).
22
22
klog is the Kubernetes logging library. [ klog] ( https://github.com/kubernetes/klog )
23
23
generates log messages for the Kubernetes system components.
24
24
25
- For more information about klog configuration, see the [ Command line tool reference] ( /docs/reference/command-line-tools-reference/ ) .
26
-
27
25
Kubernetes is in the process of simplifying logging in its components.
28
26
The following klog command line flags
29
27
[ are deprecated] ( https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components )
30
- starting with Kubernetes 1.23 and will be removed in a future release :
28
+ starting with Kubernetes 1.23 and removed in 1.26 :
31
29
32
30
- ` --add-dir-header `
33
31
- ` --alsologtostderr `
@@ -96,13 +94,13 @@ klog output or structured logging.
96
94
The default formatting of structured log messages is as text, with a format that is backward
97
95
compatible with traditional klog:
98
96
99
- ``` ini
97
+ ```
100
98
<klog header> "<message>" <key1>="<value1>" <key2>="<value2>" ...
101
99
```
102
100
103
101
Example:
104
102
105
- ``` ini
103
+ ```
106
104
I1025 00:15:15.525108 1 controller_utils.go:116] "Pod status updated" pod="kube-system/kubedns" status="ready"
107
105
```
108
106
@@ -245,13 +243,15 @@ in the application log provider. On both operating systems, logs are also availa
245
243
246
244
Provided you are authorized to interact with node objects, you can try out this alpha feature on all your nodes or
247
245
just a subset. Here is an example to retrieve the kubelet service logs from a node:
246
+
248
247
``` shell
249
248
# Fetch kubelet logs from a node named node-1.example
250
249
kubectl get --raw " /api/v1/nodes/node-1.example/proxy/logs/?query=kubelet"
251
250
```
252
251
253
252
You can also fetch files, provided that the files are in a directory that the kubelet allows for log
254
253
fetches. For example, you can fetch a log from ` /var/log ` on a Linux node:
254
+
255
255
``` shell
256
256
kubectl get --raw " /api/v1/nodes/<insert-node-name-here>/proxy/logs/?query=/<insert-log-file-name-here>"
257
257
```
@@ -273,6 +273,7 @@ Option | Description
273
273
` tailLines ` | specify how many lines from the end of the log to retrieve; the default is to fetch the whole log
274
274
275
275
Example of a more complex query:
276
+
276
277
``` shell
277
278
# Fetch kubelet logs from a node named node-1.example that have the word "error"
278
279
kubectl get --raw " /api/v1/nodes/node-1.example/proxy/logs/?query=kubelet&pattern=error"
0 commit comments