Merge pull request #8634 from csrwng/rename_pod_log

Rename 'kubectl log' to 'kubectl logs'
This commit is contained in:
Saad Ali 2015-05-26 09:55:42 -07:00
commit b7e0cc4105
8 changed files with 31 additions and 25 deletions

View File

@ -388,9 +388,9 @@ _kubectl_namespace()
must_have_one_noun=() must_have_one_noun=()
} }
_kubectl_log() _kubectl_logs()
{ {
last_command="kubectl_log" last_command="kubectl_logs"
commands=() commands=()
flags=() flags=()
@ -895,7 +895,7 @@ _kubectl()
commands+=("update") commands+=("update")
commands+=("delete") commands+=("delete")
commands+=("namespace") commands+=("namespace")
commands+=("log") commands+=("logs")
commands+=("rolling-update") commands+=("rolling-update")
commands+=("resize") commands+=("resize")
commands+=("exec") commands+=("exec")

View File

@ -16,7 +16,7 @@ kubectl_exec.md
kubectl_expose.md kubectl_expose.md
kubectl_get.md kubectl_get.md
kubectl_label.md kubectl_label.md
kubectl_log.md kubectl_logs.md
kubectl_namespace.md kubectl_namespace.md
kubectl_port-forward.md kubectl_port-forward.md
kubectl_proxy.md kubectl_proxy.md

View File

@ -54,7 +54,7 @@ kubectl
* [kubectl expose](kubectl_expose.md) - Take a replicated application and expose it as Kubernetes Service * [kubectl expose](kubectl_expose.md) - Take a replicated application and expose it as Kubernetes Service
* [kubectl get](kubectl_get.md) - Display one or many resources * [kubectl get](kubectl_get.md) - Display one or many resources
* [kubectl label](kubectl_label.md) - Update the labels on a resource * [kubectl label](kubectl_label.md) - Update the labels on a resource
* [kubectl log](kubectl_log.md) - Print the logs for a container in a pod. * [kubectl logs](kubectl_logs.md) - Print the logs for a container in a pod.
* [kubectl namespace](kubectl_namespace.md) - SUPERCEDED: Set and view the current Kubernetes namespace * [kubectl namespace](kubectl_namespace.md) - SUPERCEDED: Set and view the current Kubernetes namespace
* [kubectl port-forward](kubectl_port-forward.md) - Forward one or more local ports to a pod. * [kubectl port-forward](kubectl_port-forward.md) - Forward one or more local ports to a pod.
* [kubectl proxy](kubectl_proxy.md) - Run a proxy to the Kubernetes API server * [kubectl proxy](kubectl_proxy.md) - Run a proxy to the Kubernetes API server

View File

@ -1,4 +1,4 @@
## kubectl log ## kubectl logs
Print the logs for a container in a pod. Print the logs for a container in a pod.
@ -8,27 +8,27 @@ Print the logs for a container in a pod.
Print the logs for a container in a pod. If the pod has only one container, the container name is optional. Print the logs for a container in a pod. If the pod has only one container, the container name is optional.
``` ```
kubectl log [-f] [-p] POD [CONTAINER] kubectl logs [-f] [-p] POD [CONTAINER]
``` ```
### Examples ### Examples
``` ```
// Returns snapshot of ruby-container logs from pod 123456-7890. // Returns snapshot of ruby-container logs from pod 123456-7890.
$ kubectl log 123456-7890 ruby-container $ kubectl logs 123456-7890 ruby-container
// Returns snapshot of previous terminated ruby-container logs from pod 123456-7890. // Returns snapshot of previous terminated ruby-container logs from pod 123456-7890.
$ kubectl log -p 123456-7890 ruby-container $ kubectl logs -p 123456-7890 ruby-container
// Starts streaming of ruby-container logs from pod 123456-7890. // Starts streaming of ruby-container logs from pod 123456-7890.
$ kubectl log -f 123456-7890 ruby-container $ kubectl logs -f 123456-7890 ruby-container
``` ```
### Options ### Options
``` ```
-f, --follow=false: Specify if the logs should be streamed. -f, --follow=false: Specify if the logs should be streamed.
-h, --help=false: help for log -h, --help=false: help for logs
--interactive=true: If true, prompt the user for input when required. Default true. --interactive=true: If true, prompt the user for input when required. Default true.
-p, --previous=false: If true, print the logs for the previous instance of the container in a pod if it exists. -p, --previous=false: If true, print the logs for the previous instance of the container in a pod if it exists.
``` ```
@ -65,6 +65,6 @@ $ kubectl log -f 123456-7890 ruby-container
### SEE ALSO ### SEE ALSO
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.551041505 +0000 UTC ###### Auto generated by spf13/cobra at 2015-05-21 20:24:03.06578685 +0000 UTC
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_log.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_logs.md?pixel)]()

View File

@ -15,7 +15,7 @@ kubectl-exec.1
kubectl-expose.1 kubectl-expose.1
kubectl-get.1 kubectl-get.1
kubectl-label.1 kubectl-label.1
kubectl-log.1 kubectl-logs.1
kubectl-namespace.1 kubectl-namespace.1
kubectl-port-forward.1 kubectl-port-forward.1
kubectl-proxy.1 kubectl-proxy.1

View File

@ -3,12 +3,12 @@
.SH NAME .SH NAME
.PP .PP
kubectl log \- Print the logs for a container in a pod. kubectl logs \- Print the logs for a container in a pod.
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\fBkubectl log\fP [OPTIONS] \fBkubectl logs\fP [OPTIONS]
.SH DESCRIPTION .SH DESCRIPTION
@ -23,7 +23,7 @@ Print the logs for a container in a pod. If the pod has only one container, the
.PP .PP
\fB\-h\fP, \fB\-\-help\fP=false \fB\-h\fP, \fB\-\-help\fP=false
help for log help for logs
.PP .PP
\fB\-\-interactive\fP=true \fB\-\-interactive\fP=true
@ -138,13 +138,13 @@ Print the logs for a container in a pod. If the pod has only one container, the
.nf .nf
// Returns snapshot of ruby\-container logs from pod 123456\-7890. // Returns snapshot of ruby\-container logs from pod 123456\-7890.
$ kubectl log 123456\-7890 ruby\-container $ kubectl logs 123456\-7890 ruby\-container
// Returns snapshot of previous terminated ruby\-container logs from pod 123456\-7890. // Returns snapshot of previous terminated ruby\-container logs from pod 123456\-7890.
$ kubectl log \-p 123456\-7890 ruby\-container $ kubectl logs \-p 123456\-7890 ruby\-container
// Starts streaming of ruby\-container logs from pod 123456\-7890. // Starts streaming of ruby\-container logs from pod 123456\-7890.
$ kubectl log \-f 123456\-7890 ruby\-container $ kubectl logs \-f 123456\-7890 ruby\-container
.fi .fi
.RE .RE

View File

@ -124,7 +124,7 @@ Find more information at
.SH SEE ALSO .SH SEE ALSO
.PP .PP
\fBkubectl\-get(1)\fP, \fBkubectl\-describe(1)\fP, \fBkubectl\-create(1)\fP, \fBkubectl\-update(1)\fP, \fBkubectl\-delete(1)\fP, \fBkubectl\-namespace(1)\fP, \fBkubectl\-log(1)\fP, \fBkubectl\-rolling\-update(1)\fP, \fBkubectl\-resize(1)\fP, \fBkubectl\-exec(1)\fP, \fBkubectl\-port\-forward(1)\fP, \fBkubectl\-proxy(1)\fP, \fBkubectl\-run\-container(1)\fP, \fBkubectl\-stop(1)\fP, \fBkubectl\-expose(1)\fP, \fBkubectl\-label(1)\fP, \fBkubectl\-config(1)\fP, \fBkubectl\-cluster\-info(1)\fP, \fBkubectl\-api\-versions(1)\fP, \fBkubectl\-version(1)\fP, \fBkubectl\-get(1)\fP, \fBkubectl\-describe(1)\fP, \fBkubectl\-create(1)\fP, \fBkubectl\-update(1)\fP, \fBkubectl\-delete(1)\fP, \fBkubectl\-namespace(1)\fP, \fBkubectl\-logs(1)\fP, \fBkubectl\-rolling\-update(1)\fP, \fBkubectl\-resize(1)\fP, \fBkubectl\-exec(1)\fP, \fBkubectl\-port\-forward(1)\fP, \fBkubectl\-proxy(1)\fP, \fBkubectl\-run\-container(1)\fP, \fBkubectl\-stop(1)\fP, \fBkubectl\-expose(1)\fP, \fBkubectl\-label(1)\fP, \fBkubectl\-config(1)\fP, \fBkubectl\-cluster\-info(1)\fP, \fBkubectl\-api\-versions(1)\fP, \fBkubectl\-version(1)\fP,
.SH HISTORY .SH HISTORY

View File

@ -19,6 +19,7 @@ package cmd
import ( import (
"fmt" "fmt"
"io" "io"
"os"
"strconv" "strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
@ -29,13 +30,13 @@ import (
const ( const (
log_example = `// Returns snapshot of ruby-container logs from pod 123456-7890. log_example = `// Returns snapshot of ruby-container logs from pod 123456-7890.
$ kubectl log 123456-7890 ruby-container $ kubectl logs 123456-7890 ruby-container
// Returns snapshot of previous terminated ruby-container logs from pod 123456-7890. // Returns snapshot of previous terminated ruby-container logs from pod 123456-7890.
$ kubectl log -p 123456-7890 ruby-container $ kubectl logs -p 123456-7890 ruby-container
// Starts streaming of ruby-container logs from pod 123456-7890. // Starts streaming of ruby-container logs from pod 123456-7890.
$ kubectl log -f 123456-7890 ruby-container` $ kubectl logs -f 123456-7890 ruby-container`
) )
func selectContainer(pod *api.Pod, in io.Reader, out io.Writer) string { func selectContainer(pod *api.Pod, in io.Reader, out io.Writer) string {
@ -63,7 +64,7 @@ func selectContainer(pod *api.Pod, in io.Reader, out io.Writer) string {
// NewCmdLog creates a new pod log command // NewCmdLog creates a new pod log command
func NewCmdLog(f *cmdutil.Factory, out io.Writer) *cobra.Command { func NewCmdLog(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "log [-f] [-p] POD [CONTAINER]", Use: "logs [-f] [-p] POD [CONTAINER]",
Short: "Print the logs for a container in a pod.", Short: "Print the logs for a container in a pod.",
Long: "Print the logs for a container in a pod. If the pod has only one container, the container name is optional.", Long: "Print the logs for a container in a pod. If the pod has only one container, the container name is optional.",
Example: log_example, Example: log_example,
@ -71,6 +72,7 @@ func NewCmdLog(f *cmdutil.Factory, out io.Writer) *cobra.Command {
err := RunLog(f, out, cmd, args) err := RunLog(f, out, cmd, args)
cmdutil.CheckErr(err) cmdutil.CheckErr(err)
}, },
Aliases: []string{"log"},
} }
cmd.Flags().BoolP("follow", "f", false, "Specify if the logs should be streamed.") cmd.Flags().BoolP("follow", "f", false, "Specify if the logs should be streamed.")
cmd.Flags().Bool("interactive", true, "If true, prompt the user for input when required. Default true.") cmd.Flags().Bool("interactive", true, "If true, prompt the user for input when required. Default true.")
@ -80,6 +82,10 @@ func NewCmdLog(f *cmdutil.Factory, out io.Writer) *cobra.Command {
// RunLog retrieves a pod log // RunLog retrieves a pod log
func RunLog(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) error { func RunLog(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) error {
if len(os.Args) > 1 && os.Args[1] == "log" {
printDeprecationWarning("logs", "log")
}
if len(args) == 0 { if len(args) == 0 {
return cmdutil.UsageError(cmd, "POD is required for log") return cmdutil.UsageError(cmd, "POD is required for log")
} }