Skip to content

Commit 8546f19

Browse files
authored
Merge pull request #41395 from tengqm/improve-sys-logs
Improve sys logs page by clarifying options dropped
2 parents 3342cbf + 60dc217 commit 8546f19

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

content/en/docs/concepts/cluster-administration/logging.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ You can use `kubectl logs --previous` to retrieve logs from a previous instantia
7171
If your pod has multiple containers, specify which container's logs you want to access by
7272
appending a container name to the command, with a `-c` flag, like so:
7373

74-
```console
74+
```shell
7575
kubectl logs counter -c count
7676
```
7777

78-
See the [`kubectl logs` documentation](/docs/reference/generated/kubectl/kubectl-commands#logs) for more details.
78+
See the [`kubectl logs` documentation](/docs/reference/generated/kubectl/kubectl-commands#logs)
79+
for more details.
7980

8081
### How nodes handle container logs
8182

@@ -98,23 +99,23 @@ The usual way to access this is by running `kubectl logs`.
9899

99100
You can configure the kubelet to rotate logs automatically.
100101

101-
If you configure rotation, the kubelet is responsible for rotating container logs and managing the logging directory structure.
102+
If you configure rotation, the kubelet is responsible for rotating container logs and managing the
103+
logging directory structure.
102104
The kubelet sends this information to the container runtime (using CRI),
103105
and the runtime writes the container logs to the given location.
104106

105107
You can configure two kubelet [configuration settings](/docs/reference/config-api/kubelet-config.v1beta1/),
106108
`containerLogMaxSize` and `containerLogMaxFiles`,
107109
using the [kubelet configuration file](/docs/tasks/administer-cluster/kubelet-config-file/).
108-
These settings let you configure the maximum size for each log file and the maximum number of files allowed for each container respectively.
110+
These settings let you configure the maximum size for each log file and the maximum number of
111+
files allowed for each container respectively.
109112

110113
When you run [`kubectl logs`](/docs/reference/generated/kubectl/kubectl-commands#logs) as in
111114
the basic logging example, the kubelet on the node handles the request and
112115
reads directly from the log file. The kubelet returns the content of the log file.
113116

114-
115117
{{< note >}}
116-
Only the contents of the latest log file are available through
117-
`kubectl logs`.
118+
Only the contents of the latest log file are available through `kubectl logs`.
118119

119120
For example, if a Pod writes 40 MiB of logs and the kubelet rotates logs
120121
after 10 MiB, running `kubectl logs` returns at most 10MiB of data.
@@ -149,9 +150,8 @@ If systemd is not present, the kubelet and container runtime write to `.log` fil
149150
run the kubelet via a helper tool, `kube-log-runner`, and use that tool to redirect
150151
kubelet logs to a directory that you choose.
151152

152-
You can also set a logging directory using the deprecated kubelet command line
153-
argument `--log-dir`. However, the kubelet always directs your container runtime to
154-
write logs into directories within `/var/log/pods`.
153+
The kubelet always directs your container runtime to write logs into directories within
154+
`/var/log/pods`.
155155

156156
For more information on `kube-log-runner`, read [System Logs](/docs/concepts/cluster-administration/system-logs/#klog).
157157

@@ -221,7 +221,8 @@ application containers on that node.
221221
Because the logging agent must run on every node, it is recommended to run the agent
222222
as a `DaemonSet`.
223223

224-
Node-level logging creates only one agent per node and doesn't require any changes to the applications running on the node.
224+
Node-level logging creates only one agent per node and doesn't require any changes to the
225+
applications running on the node.
225226

226227
Containers write to stdout and stderr, but with no agreed format. A node-level agent collects
227228
these logs and forwards them for aggregation.
@@ -231,7 +232,8 @@ these logs and forwards them for aggregation.
231232
You can use a sidecar container in one of the following ways:
232233

233234
* The sidecar container streams application logs to its own `stdout`.
234-
* The sidecar container runs a logging agent, which is configured to pick up logs from an application container.
235+
* The sidecar container runs a logging agent, which is configured to pick up logs
236+
from an application container.
235237

236238
#### Streaming sidecar container
237239

@@ -346,10 +348,13 @@ The pod mounts a volume where fluentd can pick up its configuration data.
346348

347349
![Exposing logs directly from the application](/images/docs/user-guide/logging/logging-from-application.png)
348350

349-
Cluster-logging that exposes or pushes logs directly from every application is outside the scope of Kubernetes.
351+
Cluster-logging that exposes or pushes logs directly from every application is outside the scope
352+
of Kubernetes.
350353

351354
## {{% heading "whatsnext" %}}
352355

353356
* Read about [Kubernetes system logs](/docs/concepts/cluster-administration/system-logs/)
354357
* Learn about [Traces For Kubernetes System Components](/docs/concepts/cluster-administration/system-traces/)
355-
* Learn how to [customise the termination message](/docs/tasks/debug/debug-application/determine-reason-pod-failure/#customizing-the-termination-message) that Kubernetes records when a Pod fails
358+
* Learn how to [customise the termination message](/docs/tasks/debug/debug-application/determine-reason-pod-failure/#customizing-the-termination-message)
359+
that Kubernetes records when a Pod fails
360+

content/en/docs/concepts/cluster-administration/system-logs.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ scheduler decisions).
2222
klog is the Kubernetes logging library. [klog](https://github.com/kubernetes/klog)
2323
generates log messages for the Kubernetes system components.
2424

25-
For more information about klog configuration, see the [Command line tool reference](/docs/reference/command-line-tools-reference/).
26-
2725
Kubernetes is in the process of simplifying logging in its components.
2826
The following klog command line flags
2927
[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 v1.23 and removed in Kubernetes v1.26:
3129

3230
- `--add-dir-header`
3331
- `--alsologtostderr`
@@ -96,13 +94,13 @@ klog output or structured logging.
9694
The default formatting of structured log messages is as text, with a format that is backward
9795
compatible with traditional klog:
9896

99-
```ini
97+
```
10098
<klog header> "<message>" <key1>="<value1>" <key2>="<value2>" ...
10199
```
102100

103101
Example:
104102

105-
```ini
103+
```
106104
I1025 00:15:15.525108 1 controller_utils.go:116] "Pod status updated" pod="kube-system/kubedns" status="ready"
107105
```
108106

@@ -245,13 +243,15 @@ in the application log provider. On both operating systems, logs are also availa
245243

246244
Provided you are authorized to interact with node objects, you can try out this alpha feature on all your nodes or
247245
just a subset. Here is an example to retrieve the kubelet service logs from a node:
246+
248247
```shell
249248
# Fetch kubelet logs from a node named node-1.example
250249
kubectl get --raw "/api/v1/nodes/node-1.example/proxy/logs/?query=kubelet"
251250
```
252251

253252
You can also fetch files, provided that the files are in a directory that the kubelet allows for log
254253
fetches. For example, you can fetch a log from `/var/log` on a Linux node:
254+
255255
```shell
256256
kubectl get --raw "/api/v1/nodes/<insert-node-name-here>/proxy/logs/?query=/<insert-log-file-name-here>"
257257
```
@@ -273,6 +273,7 @@ Option | Description
273273
`tailLines` | specify how many lines from the end of the log to retrieve; the default is to fetch the whole log
274274

275275
Example of a more complex query:
276+
276277
```shell
277278
# Fetch kubelet logs from a node named node-1.example that have the word "error"
278279
kubectl get --raw "/api/v1/nodes/node-1.example/proxy/logs/?query=kubelet&pattern=error"

0 commit comments

Comments
 (0)