mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
add DESIRED and CURRENT columns to rcs,ds,rs
This commit is contained in:
parent
a89b607a9c
commit
aa5c036a5c
@ -357,14 +357,17 @@ func ExamplePrintReplicationControllerWithNamespace() {
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: api.ReplicationControllerStatus{
|
||||
Replicas: 1,
|
||||
},
|
||||
}
|
||||
err := f.PrintObject(cmd, ctrl, os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Printf("Unexpected error: %v", err)
|
||||
}
|
||||
// Output:
|
||||
// NAMESPACE NAME REPLICAS AGE
|
||||
// beep foo 1 10y
|
||||
// NAMESPACE NAME DESIRED CURRENT AGE
|
||||
// beep foo 1 1 10y
|
||||
}
|
||||
|
||||
func ExamplePrintReplicationControllerWithWide() {
|
||||
@ -398,14 +401,17 @@ func ExamplePrintReplicationControllerWithWide() {
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: api.ReplicationControllerStatus{
|
||||
Replicas: 1,
|
||||
},
|
||||
}
|
||||
err := f.PrintObject(cmd, ctrl, os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Printf("Unexpected error: %v", err)
|
||||
}
|
||||
// Output:
|
||||
// NAME REPLICAS AGE CONTAINER(S) IMAGE(S) SELECTOR
|
||||
// foo 1 10y foo someimage foo=bar
|
||||
// NAME DESIRED CURRENT AGE CONTAINER(S) IMAGE(S) SELECTOR
|
||||
// foo 1 1 10y foo someimage foo=bar
|
||||
}
|
||||
|
||||
func ExamplePrintPodWithWideFormat() {
|
||||
|
@ -396,14 +396,14 @@ func (h *HumanReadablePrinter) HandledResources() []string {
|
||||
// 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", "REPLICAS", "AGE"}
|
||||
var replicaSetColumns = []string{"NAME", "REPLICAS", "AGE"}
|
||||
var replicationControllerColumns = []string{"NAME", "DESIRED", "CURRENT", "AGE"}
|
||||
var replicaSetColumns = []string{"NAME", "DESIRED", "CURRENT", "AGE"}
|
||||
var jobColumns = []string{"NAME", "SUCCESSFUL"}
|
||||
var serviceColumns = []string{"NAME", "CLUSTER-IP", "EXTERNAL-IP", "PORT(S)", "AGE"}
|
||||
var ingressColumns = []string{"NAME", "RULE", "BACKEND", "ADDRESS"}
|
||||
var endpointColumns = []string{"NAME", "ENDPOINTS", "AGE"}
|
||||
var nodeColumns = []string{"NAME", "STATUS", "AGE"}
|
||||
var daemonSetColumns = []string{"NAME", "NODE-SELECTOR"}
|
||||
var daemonSetColumns = []string{"NAME", "DESIRED", "CURRENT", "NODE-SELECTOR"}
|
||||
var eventColumns = []string{"FIRSTSEEN", "LASTSEEN", "COUNT", "NAME", "KIND", "SUBOBJECT", "TYPE", "REASON", "SOURCE", "MESSAGE"}
|
||||
var limitRangeColumns = []string{"NAME", "AGE"}
|
||||
var resourceQuotaColumns = []string{"NAME", "AGE"}
|
||||
@ -703,9 +703,13 @@ func printReplicationController(controller *api.ReplicationController, w io.Writ
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err := fmt.Fprintf(w, "%s\t%d\t%s",
|
||||
|
||||
desiredReplicas := controller.Spec.Replicas
|
||||
currentReplicas := controller.Status.Replicas
|
||||
if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%s",
|
||||
name,
|
||||
controller.Spec.Replicas,
|
||||
desiredReplicas,
|
||||
currentReplicas,
|
||||
translateTimestamp(controller.CreationTimestamp),
|
||||
); err != nil {
|
||||
return err
|
||||
@ -766,9 +770,13 @@ func printReplicaSet(rs *extensions.ReplicaSet, w io.Writer, options PrintOption
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err := fmt.Fprintf(w, "%s\t%d\t%s",
|
||||
|
||||
desiredReplicas := rs.Spec.Replicas
|
||||
currentReplicas := rs.Status.Replicas
|
||||
if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%s",
|
||||
name,
|
||||
rs.Spec.Replicas,
|
||||
desiredReplicas,
|
||||
currentReplicas,
|
||||
translateTimestamp(rs.CreationTimestamp),
|
||||
); err != nil {
|
||||
return err
|
||||
@ -1051,13 +1059,18 @@ func printDaemonSet(ds *extensions.DaemonSet, w io.Writer, options PrintOptions)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
desiredScheduled := ds.Status.DesiredNumberScheduled
|
||||
currentScheduled := ds.Status.CurrentNumberScheduled
|
||||
selector, err := unversioned.LabelSelectorAsSelector(ds.Spec.Selector)
|
||||
if err != nil {
|
||||
// this shouldn't happen if LabelSelector passed validation
|
||||
return err
|
||||
}
|
||||
if _, err := fmt.Fprintf(w, "%s\t%s",
|
||||
if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%s",
|
||||
name,
|
||||
desiredScheduled,
|
||||
currentScheduled,
|
||||
labels.FormatLabels(ds.Spec.Template.Spec.NodeSelector),
|
||||
); err != nil {
|
||||
return err
|
||||
|
@ -1305,6 +1305,41 @@ func TestPrintDeployment(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintDaemonSet(t *testing.T) {
|
||||
tests := []struct {
|
||||
ds extensions.DaemonSet
|
||||
startsWith string
|
||||
}{
|
||||
{
|
||||
extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "test1",
|
||||
CreationTimestamp: unversioned.Time{Time: time.Now().Add(1.9e9)},
|
||||
},
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Template: api.PodTemplateSpec{
|
||||
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
|
||||
},
|
||||
},
|
||||
Status: extensions.DaemonSetStatus{
|
||||
CurrentNumberScheduled: 2,
|
||||
DesiredNumberScheduled: 3,
|
||||
},
|
||||
},
|
||||
"test1\t3\t2\t<none>\n",
|
||||
},
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
for _, test := range tests {
|
||||
printDaemonSet(&test.ds, buf, PrintOptions{false, false, false, false, false, false, []string{}})
|
||||
if !strings.HasPrefix(buf.String(), test.startsWith) {
|
||||
t.Fatalf("Expected to start with %s but got %s", test.startsWith, buf.String())
|
||||
}
|
||||
buf.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintPodShowLabels(t *testing.T) {
|
||||
tests := []struct {
|
||||
pod api.Pod
|
||||
|
Loading…
Reference in New Issue
Block a user