diff --git a/pkg/kubectl/cmd/cmd_test.go b/pkg/kubectl/cmd/cmd_test.go index 73c4de9fced..e54c5b3f938 100644 --- a/pkg/kubectl/cmd/cmd_test.go +++ b/pkg/kubectl/cmd/cmd_test.go @@ -515,6 +515,7 @@ func Example_printPodWithWideFormat() { {Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}}, {RestartCount: 3}, }, + PodIP: "10.1.1.3", }, } mapper, _ := f.Object(false) @@ -523,8 +524,8 @@ func Example_printPodWithWideFormat() { fmt.Printf("Unexpected error: %v", err) } // Output: - // NAME READY STATUS RESTARTS AGE NODE - // test1 1/2 podPhase 6 10y kubernetes-minion-abcd + // NAME READY STATUS RESTARTS AGE IP NODE + // test1 1/2 podPhase 6 10y 10.1.1.3 kubernetes-minion-abcd } func Example_printPodWithShowLabels() { diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index 692d2c78c1c..2c36cbd4b4f 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -633,7 +633,12 @@ func printPodBase(pod *api.Pod, w io.Writer, options PrintOptions) error { if options.Wide { nodeName := pod.Spec.NodeName - if _, err := fmt.Fprintf(w, "\t%s", + podIP := pod.Status.PodIP + if podIP == "" { + podIP = "" + } + if _, err := fmt.Fprintf(w, "\t%s\t%s", + podIP, nodeName, ); err != nil { return err @@ -1783,7 +1788,7 @@ func formatLabelHeaders(columnLabels []string) []string { func formatWideHeaders(wide bool, t reflect.Type) []string { if wide { if t.String() == "*api.Pod" || t.String() == "*api.PodList" { - return []string{"NODE"} + return []string{"IP", "NODE"} } if t.String() == "*api.ReplicationController" || t.String() == "*api.ReplicationControllerList" { return []string{"CONTAINER(S)", "IMAGE(S)", "SELECTOR"}