Support extended pod logging options

Increase the supported controls on pod logging. Add validaiton to pod
log options. Ensure the Kubelet is using a consistent, structured way to
process pod log arguments.

Add ?sinceSeconds=<durationInSeconds>, &sinceTime=<RFC3339>, ?timestamps=<bool>,
?tailLines=<number>, and ?limitBytes=<number>
This commit is contained in:
Clayton Coleman
2015-09-09 23:46:11 -04:00
parent a02bcefa10
commit c2e90cd154
30 changed files with 734 additions and 102 deletions

View File

@@ -29,10 +29,30 @@ Print the logs for a container in a pod. If the pod has only one container, the
\fB\-\-interactive\fP=true
If true, prompt the user for input when required. Default true.
.PP
\fB\-\-limit\-bytes\fP=0
Maximum bytes of logs to return. Defaults to no limit.
.PP
\fB\-p\fP, \fB\-\-previous\fP=false
If true, print the logs for the previous instance of the container in a pod if it exists.
.PP
\fB\-\-since\fP=0
Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since\-time / since may be used.
.PP
\fB\-\-since\-time\fP=""
Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since\-time / since may be used.
.PP
\fB\-\-tail\fP=\-1
Lines of recent log file to display. Defaults to \-1, showing all log lines.
.PP
\fB\-\-timestamps\fP=false
Include timestamps on each line in the log output
.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
@@ -133,14 +153,20 @@ Print the logs for a container in a pod. If the pod has only one container, the
.RS
.nf
# Return snapshot of ruby\-container logs from pod 123456\-7890.
$ kubectl logs 123456\-7890 ruby\-container
# Return snapshot logs from pod nginx with only one container
$ kubectl logs nginx
# Return snapshot of previous terminated ruby\-container logs from pod 123456\-7890.
$ kubectl logs \-p 123456\-7890 ruby\-container
# Return snapshot of previous terminated ruby container logs from pod web\-1
$ kubectl logs \-p \-c ruby web\-1
# Start streaming of ruby\-container logs from pod 123456\-7890.
$ kubectl logs \-f 123456\-7890 ruby\-container
# Begin streaming the logs of the ruby container in pod web\-1
$ kubectl logs \-f \-c ruby web\-1
# Display only the most recent 20 lines of output in pod nginx
$ kubectl logs \-\-tail=20 nginx
# Show all logs from pod nginx written in the last hour
$ kubectl logs \-\-since=1h nginx
.fi
.RE

View File

@@ -47,14 +47,20 @@ kubectl logs [-f] [-p] POD [-c CONTAINER]
### Examples
```
# Return snapshot of ruby-container logs from pod 123456-7890.
$ kubectl logs 123456-7890 ruby-container
# Return snapshot logs from pod nginx with only one container
$ kubectl logs nginx
# Return snapshot of previous terminated ruby-container logs from pod 123456-7890.
$ kubectl logs -p 123456-7890 ruby-container
# Return snapshot of previous terminated ruby container logs from pod web-1
$ kubectl logs -p -c ruby web-1
# Start streaming of ruby-container logs from pod 123456-7890.
$ kubectl logs -f 123456-7890 ruby-container
# Begin streaming the logs of the ruby container in pod web-1
$ kubectl logs -f -c ruby web-1
# Display only the most recent 20 lines of output in pod nginx
$ kubectl logs --tail=20 nginx
# Show all logs from pod nginx written in the last hour
$ kubectl logs --since=1h nginx
```
### Options
@@ -63,7 +69,12 @@ $ kubectl logs -f 123456-7890 ruby-container
-c, --container="": Container name
-f, --follow[=false]: Specify if the logs should be streamed.
--interactive[=true]: If true, prompt the user for input when required. Default true.
--limit-bytes=0: Maximum bytes of logs to return. Defaults to no limit.
-p, --previous[=false]: If true, print the logs for the previous instance of the container in a pod if it exists.
--since=0: Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since-time / since may be used.
--since-time="": Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used.
--tail=-1: Lines of recent log file to display. Defaults to -1, showing all log lines.
--timestamps[=false]: Include timestamps on each line in the log output
```
### Options inherited from parent commands
@@ -98,7 +109,7 @@ $ kubectl logs -f 123456-7890 ruby-container
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.154570214 +0000 UTC
###### Auto generated by spf13/cobra at 2015-09-16 18:54:52.319210951 +0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_logs.md?pixel)]()