1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl logs - Print the logs for a container in a pod
10
11
12

SYNOPSIS

14       kubectl logs [OPTIONS]
15
16
17

DESCRIPTION

19       Print  the  logs for a container in a pod or specified resource. If the
20       pod has only one container, the container name is optional.
21
22
23

OPTIONS

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

OPTIONS INHERITED FROM PARENT COMMANDS

89       --as=""      Username to impersonate for the operation. User could be a
90       regular user or a service account in a namespace.
91
92
93       --as-group=[]      Group to impersonate for the  operation,  this  flag
94       can be repeated to specify multiple groups.
95
96
97       --as-uid=""      UID to impersonate for the operation.
98
99
100       --azure-container-registry-config=""       Path  to the file containing
101       Azure container registry configuration information.
102
103
104       --cache-dir="/builddir/.kube/cache"      Default cache directory
105
106
107       --certificate-authority=""      Path to a cert file for the certificate
108       authority
109
110
111       --client-certificate=""      Path to a client certificate file for TLS
112
113
114       --client-key=""      Path to a client key file for TLS
115
116
117       --cluster=""      The name of the kubeconfig cluster to use
118
119
120       --context=""      The name of the kubeconfig context to use
121
122
123       --insecure-skip-tls-verify=false      If true, the server's certificate
124       will not be checked for validity. This will make your HTTPS connections
125       insecure
126
127
128       --kubeconfig=""       Path  to  the  kubeconfig file to use for CLI re‐
129       quests.
130
131
132       --match-server-version=false       Require  server  version  to   match
133       client version
134
135
136       -n,  --namespace=""       If  present, the namespace scope for this CLI
137       request
138
139
140       --password=""      Password for basic authentication to the API server
141
142
143       --profile="none"        Name   of   profile   to   capture.   One    of
144       (none|cpu|heap|goroutine|threadcreate|block|mutex)
145
146
147       --profile-output="profile.pprof"       Name  of  the  file to write the
148       profile to
149
150
151       --request-timeout="0"      The length of time to wait before giving  up
152       on  a  single  server  request. Non-zero values should contain a corre‐
153       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
154       out requests.
155
156
157       -s, --server=""      The address and port of the Kubernetes API server
158
159
160       --tls-server-name=""       Server  name  to  use for server certificate
161       validation. If it is not provided, the hostname  used  to  contact  the
162       server is used
163
164
165       --token=""      Bearer token for authentication to the API server
166
167
168       --user=""      The name of the kubeconfig user to use
169
170
171       --username=""      Username for basic authentication to the API server
172
173
174       --version=false      Print version information and quit
175
176
177       --warnings-as-errors=false      Treat warnings received from the server
178       as errors and exit with a non-zero exit code
179
180
181

EXAMPLE

183                # Return snapshot logs from pod nginx with only one container
184                kubectl logs nginx
185
186                # Return snapshot logs from pod nginx with multi containers
187                kubectl logs nginx --all-containers=true
188
189                # Return snapshot logs from all containers in pods defined by label app=nginx
190                kubectl logs -l app=nginx --all-containers=true
191
192                # Return snapshot of previous terminated ruby container logs from pod web-1
193                kubectl logs -p -c ruby web-1
194
195                # Begin streaming the logs of the ruby container in pod web-1
196                kubectl logs -f -c ruby web-1
197
198                # Begin streaming the logs from all containers in pods defined by label app=nginx
199                kubectl logs -f -l app=nginx --all-containers=true
200
201                # Display only the most recent 20 lines of output in pod nginx
202                kubectl logs --tail=20 nginx
203
204                # Show all logs from pod nginx written in the last hour
205                kubectl logs --since=1h nginx
206
207                # Show logs from a kubelet with an expired serving certificate
208                kubectl logs --insecure-skip-tls-verify-backend nginx
209
210                # Return snapshot logs from first container of a job named hello
211                kubectl logs job/hello
212
213                # Return snapshot logs from container nginx-1 of a deployment named nginx
214                kubectl logs deployment/nginx -c nginx-1
215
216
217
218

SEE ALSO

220       kubectl(1),
221
222
223

HISTORY

225       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
226       com)  based  on the kubernetes source material, but hopefully they have
227       been automatically generated since!
228
229
230
231Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum