Skip to content

Commit 4c1050f

Browse files
committed
[zh-cn]sync kubectl_logs/_index
Signed-off-by: xin.li
1 parent 3afda07 commit 4c1050f

File tree

1 file changed

+85
-47
lines changed
  • content/zh-cn/docs/reference/kubectl/generated/kubectl_logs

1 file changed

+85
-47
lines changed

content/zh-cn/docs/reference/kubectl/generated/kubectl_logs/_index.md

Lines changed: 85 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ no_list: true
1616

1717
2420
打印 Pod 或指定资源中某个容器的日志。如果 Pod 只有一个容器,则容器名称是可选的。
2521

@@ -33,76 +29,118 @@ kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]
3329
```
3430
# Return snapshot logs from pod nginx with only one container
3531
kubectl logs nginx
32+
33+
# Return snapshot logs from pod nginx, prefixing each line with the source pod and container name
34+
kubectl logs nginx --prefix
3635
36+
# Return snapshot logs from pod nginx, limiting output to 500 bytes
37+
kubectl logs nginx --limit-bytes=500
38+
39+
# Return snapshot logs from pod nginx, waiting up to 20 seconds for it to start running.
40+
kubectl logs nginx --pod-running-timeout=20s
41+
3742
# Return snapshot logs from pod nginx with multi containers
3843
kubectl logs nginx --all-containers=true
39-
44+
45+
# Return snapshot logs from all pods in the deployment nginx
46+
kubectl logs deployment/nginx --all-pods=true
47+
4048
# Return snapshot logs from all containers in pods defined by label app=nginx
4149
kubectl logs -l app=nginx --all-containers=true
42-
50+
51+
# Return snapshot logs from all pods defined by label app=nginx, limiting concurrent log requests to 10 pods
52+
kubectl logs -l app=nginx --max-log-requests=10
53+
4354
# Return snapshot of previous terminated ruby container logs from pod web-1
4455
kubectl logs -p -c ruby web-1
45-
56+
57+
# Begin streaming the logs from pod nginx, continuing even if errors occur
58+
kubectl logs nginx -f --ignore-errors=true
59+
4660
# Begin streaming the logs of the ruby container in pod web-1
4761
kubectl logs -f -c ruby web-1
48-
62+
4963
# Begin streaming the logs from all containers in pods defined by label app=nginx
5064
kubectl logs -f -l app=nginx --all-containers=true
51-
65+
5266
# Display only the most recent 20 lines of output in pod nginx
5367
kubectl logs --tail=20 nginx
54-
68+
5569
# Show all logs from pod nginx written in the last hour
5670
kubectl logs --since=1h nginx
57-
71+
72+
# Show all logs with timestamps from pod nginx starting from August 30, 2024, at 06:00:00 UTC
73+
kubectl logs nginx --since-time=2024-08-30T06:00:00Z --timestamps=true
74+
5875
# Show logs from a kubelet with an expired serving certificate
5976
kubectl logs --insecure-skip-tls-verify-backend nginx
60-
77+
6178
# Return snapshot logs from first container of a job named hello
6279
kubectl logs job/hello
63-
80+
6481
# Return snapshot logs from container nginx-1 of a deployment named nginx
6582
kubectl logs deployment/nginx -c nginx-1
6683
```
6784
-->
6885
```shell
69-
# 返回只有一个容器的 nginx Pod 中的快照日志
70-
kubectl logs nginx
71-
72-
# 返回有多个容器的 nginx Pod 中的快照日志
73-
kubectl logs nginx --all-containers=true
74-
75-
# 返回带 app=nginx 标签定义的 Pod 中所有容器的快照日志
76-
kubectl logs -l app=nginx --all-containers=true
77-
78-
# 返回 web-1 Pod 中之前终止的 ruby 容器日志的日志
79-
kubectl logs -p -c ruby web-1
80-
81-
# 开始流式传输 web-1 Pod 中 ruby 容器的日志
82-
kubectl logs -f -c ruby web-1
83-
84-
# 开始流式传输带 app=nginx 标签定义的 Pod 中所有容器的日志
85-
kubectl logs -f -l app=nginx --all-containers=true
86-
87-
# 仅显示 nginx Pod 的最近 20 行输出
88-
kubectl logs --tail=20 nginx
89-
90-
# 显示 nginx Pod 在过去一小时内写入的所有日志
91-
kubectl logs --since=1h nginx
92-
93-
# 显示所提供证书过期的 kubelet 的日志
94-
kubectl logs --insecure-skip-tls-verify-backend nginx
95-
96-
# 返回名为 hello 的 Job 的第一个容器的快照日志
97-
kubectl logs job/hello
98-
99-
# 返回 nginx Deployment 的 nginx-1 容器的快照日志
100-
kubectl logs deployment/nginx -c nginx-1
86+
# 返回只有一个容器的 nginx Pod 中的快照日志
87+
kubectl logs nginx
88+
89+
# 从 nginx Pod 返回快照日志,每行前面加上来源的 Pod 和容器名称
90+
kubectl logs nginx --prefix
91+
92+
# 从 nginx Pod 返回快照日志,限制输出为 500 字节
93+
kubectl logs nginx --limit-bytes=500
94+
95+
# 从 nginx Pod 返回快照日志,等待其启动运行最多 20 秒
96+
kubectl logs nginx --pod-running-timeout=20s
97+
98+
# 返回有多个容器的 nginx Pod 中的快照日志
99+
kubectl logs nginx --all-containers=true
100+
101+
# 从 nginx Deployment 中的所有 Pod 返回快照日志
102+
kubectl logs deployment/nginx --all-pods=true
103+
104+
# 返回带 app=nginx 标签定义的 Pod 中所有容器的快照日志
105+
kubectl logs -l app=nginx --all-containers=true
106+
107+
# 返回带 app=nginx 标签定义的 Pod 中容器的快照日志,限制并发日志请求为 10 个 Pod
108+
kubectl logs -l app=nginx --max-log-requests=10
109+
110+
# 返回 web-1 Pod 中之前终止的 ruby 容器日志的日志
111+
kubectl logs -p -c ruby web-1
112+
113+
# 开始从 nginx Pod 流式传输日志,即使发生错误也继续
114+
kubectl logs nginx -f --ignore-errors=true
115+
116+
# 开始流式传输 web-1 Pod 中 ruby 容器的日志
117+
kubectl logs -f -c ruby web-1
118+
119+
# 开始流式传输带 app=nginx 标签定义的 Pod 中所有容器的日志
120+
kubectl logs -f -l app=nginx --all-containers=true
121+
122+
# 仅显示 nginx Pod 的最近 20 行输出
123+
kubectl logs --tail=20 nginx
124+
125+
# 显示 nginx Pod 在过去一小时内写入的所有日志
126+
kubectl logs --since=1h nginx
127+
128+
# 显示从 2024 年 8 月 30 日 06:00:00 UTC 开始 nginx Pod 中所有带时间戳的日志
129+
kubectl logs nginx --since-time=2024-08-30T06:00:00Z --timestamps=true
130+
131+
# 显示所提供证书过期的 kubelet 的日志
132+
kubectl logs --insecure-skip-tls-verify-backend nginx
133+
134+
# 返回名为 hello 的 Job 的第一个容器的快照日志
135+
kubectl logs job/hello
136+
137+
# 返回 nginx Deployment 的 nginx-1 容器的快照日志
138+
kubectl logs deployment/nginx -c nginx-1
101139
```
102140

103141
## {{% heading "options" %}}
104142

105-
<table style="width: 100%; table-layout: fixed;">
143+
<table style="width: 100%; table-layout: fixed;">
106144
<colgroup>
107145
<col span="1" style="width: 10px;" />
108146
<col span="1" />
@@ -325,7 +363,7 @@ Include timestamps on each line in the log output
325363

326364
## {{% heading "parentoptions" %}}
327365

328-
<table style="width: 100%; table-layout: fixed;">
366+
<table style="width: 100%; table-layout: fixed;">
329367
<colgroup>
330368
<col span="1" style="width: 10px;" />
331369
<col span="1" />

0 commit comments

Comments
 (0)