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       --disable-compression=false       If true, opt-out of response compres‐
124       sion for all requests to the server
125
126
127       --insecure-skip-tls-verify=false      If true, the server's certificate
128       will not be checked for validity. This will make your HTTPS connections
129       insecure
130
131
132       --kubeconfig=""      Path to the kubeconfig file to  use  for  CLI  re‐
133       quests.
134
135
136       --match-server-version=false        Require  server  version  to  match
137       client version
138
139
140       -n, --namespace=""      If present, the namespace scope  for  this  CLI
141       request
142
143
144       --password=""      Password for basic authentication to the API server
145
146
147       --profile="none"         Name   of   profile   to   capture.   One   of
148       (none|cpu|heap|goroutine|threadcreate|block|mutex)
149
150
151       --profile-output="profile.pprof"      Name of the  file  to  write  the
152       profile to
153
154
155       --request-timeout="0"       The length of time to wait before giving up
156       on a single server request. Non-zero values  should  contain  a  corre‐
157       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
158       out requests.
159
160
161       -s, --server=""      The address and port of the Kubernetes API server
162
163
164       --tls-server-name=""      Server name to  use  for  server  certificate
165       validation.  If  it  is  not provided, the hostname used to contact the
166       server is used
167
168
169       --token=""      Bearer token for authentication to the API server
170
171
172       --user=""      The name of the kubeconfig user to use
173
174
175       --username=""      Username for basic authentication to the API server
176
177
178       --version=false      Print version information and quit
179
180
181       --warnings-as-errors=false      Treat warnings received from the server
182       as errors and exit with a non-zero exit code
183
184
185

EXAMPLE

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

SEE ALSO

224       kubectl(1),
225
226
227

HISTORY

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