From 51a894e6163ea465efc1bbda19d38d17cf9b24aa Mon Sep 17 00:00:00 2001 From: Michail Kargakis Date: Thu, 18 Aug 2016 11:35:18 +0200 Subject: [PATCH] kubectl: display ready replicas in 'get {rs,rc}' --- pkg/kubectl/cmd/cmd_test.go | 15 ++++++++------- pkg/kubectl/resource_printer.go | 12 ++++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/pkg/kubectl/cmd/cmd_test.go b/pkg/kubectl/cmd/cmd_test.go index 0d375432298..cf7d1af6488 100644 --- a/pkg/kubectl/cmd/cmd_test.go +++ b/pkg/kubectl/cmd/cmd_test.go @@ -420,7 +420,8 @@ func Example_printReplicationControllerWithNamespace() { }, }, Status: api.ReplicationControllerStatus{ - Replicas: 1, + Replicas: 1, + ReadyReplicas: 1, }, } mapper, _ := f.Object(false) @@ -429,8 +430,8 @@ func Example_printReplicationControllerWithNamespace() { fmt.Printf("Unexpected error: %v", err) } // Output: - // NAMESPACE NAME DESIRED CURRENT AGE - // beep foo 1 1 10y + // NAMESPACE NAME DESIRED CURRENT READY AGE + // beep foo 1 1 1 10y } func Example_printMultiContainersReplicationControllerWithWide() { @@ -481,8 +482,8 @@ func Example_printMultiContainersReplicationControllerWithWide() { fmt.Printf("Unexpected error: %v", err) } // Output: - // NAME DESIRED CURRENT AGE CONTAINER(S) IMAGE(S) SELECTOR - // foo 1 1 10y foo,foo2 someimage,someimage2 foo=bar + // NAME DESIRED CURRENT READY AGE CONTAINER(S) IMAGE(S) SELECTOR + // foo 1 1 0 10y foo,foo2 someimage,someimage2 foo=bar } func Example_printReplicationController() { @@ -532,8 +533,8 @@ func Example_printReplicationController() { fmt.Printf("Unexpected error: %v", err) } // Output: - // NAME DESIRED CURRENT AGE - // foo 1 1 10y + // NAME DESIRED CURRENT READY AGE + // foo 1 1 0 10y } func Example_printPodWithWideFormat() { diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index dcc958a33f2..8caf03ab902 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -458,8 +458,8 @@ func (h *HumanReadablePrinter) FinishPrint(output io.Writer, res string) error { // pkg/kubectl/cmd/get.go to reflect the new resource type. var podColumns = []string{"NAME", "READY", "STATUS", "RESTARTS", "AGE"} var podTemplateColumns = []string{"TEMPLATE", "CONTAINER(S)", "IMAGE(S)", "PODLABELS"} -var replicationControllerColumns = []string{"NAME", "DESIRED", "CURRENT", "AGE"} -var replicaSetColumns = []string{"NAME", "DESIRED", "CURRENT", "AGE"} +var replicationControllerColumns = []string{"NAME", "DESIRED", "CURRENT", "READY", "AGE"} +var replicaSetColumns = []string{"NAME", "DESIRED", "CURRENT", "READY", "AGE"} var jobColumns = []string{"NAME", "DESIRED", "SUCCESSFUL", "AGE"} var scheduledJobColumns = []string{"NAME", "SCHEDULE", "SUSPEND", "ACTIVE", "LAST-SCHEDULE"} var serviceColumns = []string{"NAME", "CLUSTER-IP", "EXTERNAL-IP", "PORT(S)", "AGE"} @@ -834,10 +834,12 @@ func printReplicationController(controller *api.ReplicationController, w io.Writ desiredReplicas := controller.Spec.Replicas currentReplicas := controller.Status.Replicas - if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%s", + readyReplicas := controller.Status.ReadyReplicas + if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%d\t%s", name, desiredReplicas, currentReplicas, + readyReplicas, translateTimestamp(controller.CreationTimestamp), ); err != nil { return err @@ -884,10 +886,12 @@ func printReplicaSet(rs *extensions.ReplicaSet, w io.Writer, options PrintOption desiredReplicas := rs.Spec.Replicas currentReplicas := rs.Status.Replicas - if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%s", + readyReplicas := rs.Status.ReadyReplicas + if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%d\t%s", name, desiredReplicas, currentReplicas, + readyReplicas, translateTimestamp(rs.CreationTimestamp), ); err != nil { return err