1KUBERNETES(1)                      Jan 2015                      KUBERNETES(1)
2
3
4

NAME

6       kubectl logs - Print the logs for a container in a pod
7
8
9

SYNOPSIS

11       kubectl logs [OPTIONS]
12
13
14

DESCRIPTION

16       Print the logs for a container in a pod or specified resource. If the
17       pod has only one container, the container name is optional.
18
19
20

OPTIONS

22       --all-containers=false
23           Get all containers' logs in the pod(s).
24
25
26       -c, --container=""
27           Print the logs of this container
28
29
30       -f, --follow=false
31           Specify if the logs should be streamed.
32
33
34       --ignore-errors=false
35           If watching / following pod logs, allow for any errors that occur
36       to be non-fatal
37
38
39       --insecure-skip-tls-verify-backend=false
40           Skip verifying the identity of the kubelet that logs are requested
41       from.  In theory, an attacker could provide invalid log content back.
42       You might want to use this if your kubelet serving certificates have
43       expired.
44
45
46       --limit-bytes=0
47           Maximum bytes of logs to return. Defaults to no limit.
48
49
50       --max-log-requests=5
51           Specify maximum number of concurrent logs to follow when using by a
52       selector. Defaults to 5.
53
54
55       --pod-running-timeout=20s
56           The length of time (like 5s, 2m, or 3h, higher than zero) to wait
57       until at least one pod is running
58
59
60       --prefix=false
61           Prefix each log line with the log source (pod name and container
62       name)
63
64
65       -p, --previous=false
66           If true, print the logs for the previous instance of the container
67       in a pod if it exists.
68
69
70       -l, --selector=""
71           Selector (label query) to filter on.
72
73
74       --since=0s
75           Only return logs newer than a relative duration like 5s, 2m, or 3h.
76       Defaults to all logs. Only one of since-time / since may be used.
77
78
79       --since-time=""
80           Only return logs after a specific date (RFC3339). Defaults to all
81       logs. Only one of since-time / since may be used.
82
83
84       --tail=-1
85           Lines of recent log file to display. Defaults to -1 with no
86       selector, showing all log lines otherwise 10, if a selector is
87       provided.
88
89
90       --timestamps=false
91           Include timestamps on each line in the log output
92
93
94

OPTIONS INHERITED FROM PARENT COMMANDS

96       --add-dir-header=false
97           If true, adds the file directory to the header
98
99
100       --alsologtostderr=false
101           log to standard error as well as files
102
103
104       --application-metrics-count-limit=100
105           Max number of application metrics to store (per container)
106
107
108       --as=""
109           Username to impersonate for the operation
110
111
112       --as-group=[]
113           Group to impersonate for the operation, this flag can be repeated
114       to specify multiple groups.
115
116
117       --azure-container-registry-config=""
118           Path to the file containing Azure container registry configuration
119       information.
120
121
122       --boot-id-file="/proc/sys/kernel/random/boot_id"
123           Comma-separated list of files to check for boot-id. Use the first
124       one that exists.
125
126
127       --cache-dir="/builddir/.kube/http-cache"
128           Default HTTP cache directory
129
130
131       --certificate-authority=""
132           Path to a cert file for the certificate authority
133
134
135       --client-certificate=""
136           Path to a client certificate file for TLS
137
138
139       --client-key=""
140           Path to a client key file for TLS
141
142
143       --cloud-provider-gce-l7lb-src-cidrs=130.211.0.0/22,35.191.0.0/16
144           CIDRs opened in GCE firewall for L7 LB traffic proxy  health checks
145
146
147       --cloud-provider-gce-lb-src-cidrs=130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
148           CIDRs opened in GCE firewall for L4 LB traffic proxy  health checks
149
150
151       --cluster=""
152           The name of the kubeconfig cluster to use
153
154
155       --container-hints="/etc/cadvisor/container_hints.json"
156           location of the container hints file
157
158
159       --containerd="/run/containerd/containerd.sock"
160           containerd endpoint
161
162
163       --containerd-namespace="k8s.io"
164           containerd namespace
165
166
167       --context=""
168           The name of the kubeconfig context to use
169
170
171       --default-not-ready-toleration-seconds=300
172           Indicates the tolerationSeconds of the toleration for
173       notReady:NoExecute that is added by default to every pod that does not
174       already have such a toleration.
175
176
177       --default-unreachable-toleration-seconds=300
178           Indicates the tolerationSeconds of the toleration for
179       unreachable:NoExecute that is added by default to every pod that does
180       not already have such a toleration.
181
182
183       --disable-root-cgroup-stats=false
184           Disable collecting root Cgroup stats
185
186
187       --docker="unix:///var/run/docker.sock"
188           docker endpoint
189
190
191       --docker-env-metadata-whitelist=""
192           a comma-separated list of environment variable keys that needs to
193       be collected for docker containers
194
195
196       --docker-only=false
197           Only report docker containers in addition to root stats
198
199
200       --docker-root="/var/lib/docker"
201           DEPRECATED: docker root is read from docker info (this is a
202       fallback, default: /var/lib/docker)
203
204
205       --docker-tls=false
206           use TLS to connect to docker
207
208
209       --docker-tls-ca="ca.pem"
210           path to trusted CA
211
212
213       --docker-tls-cert="cert.pem"
214           path to client certificate
215
216
217       --docker-tls-key="key.pem"
218           path to private key
219
220
221       --enable-load-reader=false
222           Whether to enable cpu load reader
223
224
225       --event-storage-age-limit="default=0"
226           Max length of time for which to store events (per type). Value is a
227       comma separated list of key values, where the keys are event types
228       (e.g.: creation, oom) or "default" and the value is a duration. Default
229       is applied to all non-specified event types
230
231
232       --event-storage-event-limit="default=0"
233           Max number of events to store (per type). Value is a comma
234       separated list of key values, where the keys are event types (e.g.:
235       creation, oom) or "default" and the value is an integer. Default is
236       applied to all non-specified event types
237
238
239       --global-housekeeping-interval=1m0s
240           Interval between global housekeepings
241
242
243       --housekeeping-interval=10s
244           Interval between container housekeepings
245
246
247       --insecure-skip-tls-verify=false
248           If true, the server's certificate will not be checked for validity.
249       This will make your HTTPS connections insecure
250
251
252       --kubeconfig=""
253           Path to the kubeconfig file to use for CLI requests.
254
255
256       --log-backtrace-at=:0
257           when logging hits line file:N, emit a stack trace
258
259
260       --log-cadvisor-usage=false
261           Whether to log the usage of the cAdvisor container
262
263
264       --log-dir=""
265           If non-empty, write log files in this directory
266
267
268       --log-file=""
269           If non-empty, use this log file
270
271
272       --log-file-max-size=1800
273           Defines the maximum size a log file can grow to. Unit is megabytes.
274       If the value is 0, the maximum file size is unlimited.
275
276
277       --log-flush-frequency=5s
278           Maximum number of seconds between log flushes
279
280
281       --logtostderr=true
282           log to standard error instead of files
283
284
285       --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
286           Comma-separated list of files to check for machine-id. Use the
287       first one that exists.
288
289
290       --match-server-version=false
291           Require server version to match client version
292
293
294       -n, --namespace=""
295           If present, the namespace scope for this CLI request
296
297
298       --password=""
299           Password for basic authentication to the API server
300
301
302       --profile="none"
303           Name of profile to capture. One of
304       (none|cpu|heap|goroutine|threadcreate|block|mutex)
305
306
307       --profile-output="profile.pprof"
308           Name of the file to write the profile to
309
310
311       --request-timeout="0"
312           The length of time to wait before giving up on a single server
313       request. Non-zero values should contain a corresponding time unit (e.g.
314       1s, 2m, 3h). A value of zero means don't timeout requests.
315
316
317       -s, --server=""
318           The address and port of the Kubernetes API server
319
320
321       --skip-headers=false
322           If true, avoid header prefixes in the log messages
323
324
325       --skip-log-headers=false
326           If true, avoid headers when opening log files
327
328
329       --stderrthreshold=2
330           logs at or above this threshold go to stderr
331
332
333       --storage-driver-buffer-duration=1m0s
334           Writes in the storage driver will be buffered for this duration,
335       and committed to the non memory backends as a single transaction
336
337
338       --storage-driver-db="cadvisor"
339           database name
340
341
342       --storage-driver-host="localhost:8086"
343           database host:port
344
345
346       --storage-driver-password="root"
347           database password
348
349
350       --storage-driver-secure=false
351           use secure connection with database
352
353
354       --storage-driver-table="stats"
355           table name
356
357
358       --storage-driver-user="root"
359           database username
360
361
362       --tls-server-name=""
363           Server name to use for server certificate validation. If it is not
364       provided, the hostname used to contact the server is used
365
366
367       --token=""
368           Bearer token for authentication to the API server
369
370
371       --update-machine-info-interval=5m0s
372           Interval between machine info updates.
373
374
375       --user=""
376           The name of the kubeconfig user to use
377
378
379       --username=""
380           Username for basic authentication to the API server
381
382
383       -v, --v=0
384           number for the log level verbosity
385
386
387       --version=false
388           Print version information and quit
389
390
391       --vmodule=
392           comma-separated list of pattern=N settings for file-filtered
393       logging
394
395
396

EXAMPLE

398                # Return snapshot logs from pod nginx with only one container
399                kubectl logs nginx
400
401                # Return snapshot logs from pod nginx with multi containers
402                kubectl logs nginx --all-containers=true
403
404                # Return snapshot logs from all containers in pods defined by label app=nginx
405                kubectl logs -lapp=nginx --all-containers=true
406
407                # Return snapshot of previous terminated ruby container logs from pod web-1
408                kubectl logs -p -c ruby web-1
409
410                # Begin streaming the logs of the ruby container in pod web-1
411                kubectl logs -f -c ruby web-1
412
413                # Begin streaming the logs from all containers in pods defined by label app=nginx
414                kubectl logs -f -lapp=nginx --all-containers=true
415
416                # Display only the most recent 20 lines of output in pod nginx
417                kubectl logs --tail=20 nginx
418
419                # Show all logs from pod nginx written in the last hour
420                kubectl logs --since=1h nginx
421
422                # Show logs from a kubelet with an expired serving certificate
423                kubectl logs --insecure-skip-tls-verify-backend nginx
424
425                # Return snapshot logs from first container of a job named hello
426                kubectl logs job/hello
427
428                # Return snapshot logs from container nginx-1 of a deployment named nginx
429                kubectl logs deployment/nginx -c nginx-1
430
431
432
433

SEE ALSO

435       kubectl(1),
436
437
438

HISTORY

440       January 2015, Originally compiled by Eric Paris (eparis at redhat dot
441       com) based on the kubernetes source material, but hopefully they have
442       been automatically generated since!
443
444
445
446Eric Paris                  kubernetes User Manuals              KUBERNETES(1)
Impressum