mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
add Ready column for kubectl get sts command
This commit is contained in:
parent
1f0f4cd7eb
commit
182a66f9b7
@ -203,8 +203,7 @@ func AddHandlers(h printers.PrintHandler) {
|
|||||||
|
|
||||||
statefulSetColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
statefulSetColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||||
{Name: "Desired", Type: "string", Description: appsv1beta1.StatefulSetSpec{}.SwaggerDoc()["replicas"]},
|
{Name: "Ready", Type: "string", Description: "Number of the pod with ready state"},
|
||||||
{Name: "Current", Type: "string", Description: appsv1beta1.StatefulSetStatus{}.SwaggerDoc()["replicas"]},
|
|
||||||
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
|
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
|
||||||
{Name: "Containers", Type: "string", Priority: 1, Description: "Names of each container in the template."},
|
{Name: "Containers", Type: "string", Priority: 1, Description: "Names of each container in the template."},
|
||||||
{Name: "Images", Type: "string", Priority: 1, Description: "Images referenced by each container in the template."},
|
{Name: "Images", Type: "string", Priority: 1, Description: "Images referenced by each container in the template."},
|
||||||
@ -313,8 +312,7 @@ func AddHandlers(h printers.PrintHandler) {
|
|||||||
|
|
||||||
deploymentColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
deploymentColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||||
{Name: "Desired", Type: "string", Description: extensionsv1beta1.DeploymentSpec{}.SwaggerDoc()["replicas"]},
|
{Name: "Ready", Type: "string", Description: "Number of the pod with ready state"},
|
||||||
{Name: "Current", Type: "string", Description: extensionsv1beta1.DeploymentStatus{}.SwaggerDoc()["replicas"]},
|
|
||||||
{Name: "Up-to-date", Type: "string", Description: extensionsv1beta1.DeploymentStatus{}.SwaggerDoc()["updatedReplicas"]},
|
{Name: "Up-to-date", Type: "string", Description: extensionsv1beta1.DeploymentStatus{}.SwaggerDoc()["updatedReplicas"]},
|
||||||
{Name: "Available", Type: "string", Description: extensionsv1beta1.DeploymentStatus{}.SwaggerDoc()["availableReplicas"]},
|
{Name: "Available", Type: "string", Description: extensionsv1beta1.DeploymentStatus{}.SwaggerDoc()["availableReplicas"]},
|
||||||
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
|
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
|
||||||
@ -1042,9 +1040,9 @@ func printStatefulSet(obj *apps.StatefulSet, options printers.PrintOptions) ([]m
|
|||||||
Object: runtime.RawExtension{Object: obj},
|
Object: runtime.RawExtension{Object: obj},
|
||||||
}
|
}
|
||||||
desiredReplicas := obj.Spec.Replicas
|
desiredReplicas := obj.Spec.Replicas
|
||||||
currentReplicas := obj.Status.Replicas
|
readyReplicas := obj.Status.ReadyReplicas
|
||||||
createTime := translateTimestampSince(obj.CreationTimestamp)
|
createTime := translateTimestampSince(obj.CreationTimestamp)
|
||||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), createTime)
|
row.Cells = append(row.Cells, obj.Name, fmt.Sprintf("%d/%d", int64(readyReplicas), int64(desiredReplicas)), createTime)
|
||||||
if options.Wide {
|
if options.Wide {
|
||||||
names, images := layoutContainerCells(obj.Spec.Template.Spec.Containers)
|
names, images := layoutContainerCells(obj.Spec.Template.Spec.Containers)
|
||||||
row.Cells = append(row.Cells, names, images)
|
row.Cells = append(row.Cells, names, images)
|
||||||
@ -1561,8 +1559,8 @@ func printDeployment(obj *apps.Deployment, options printers.PrintOptions) ([]met
|
|||||||
Object: runtime.RawExtension{Object: obj},
|
Object: runtime.RawExtension{Object: obj},
|
||||||
}
|
}
|
||||||
desiredReplicas := obj.Spec.Replicas
|
desiredReplicas := obj.Spec.Replicas
|
||||||
currentReplicas := obj.Status.Replicas
|
|
||||||
updatedReplicas := obj.Status.UpdatedReplicas
|
updatedReplicas := obj.Status.UpdatedReplicas
|
||||||
|
readyReplicas := obj.Status.ReadyReplicas
|
||||||
availableReplicas := obj.Status.AvailableReplicas
|
availableReplicas := obj.Status.AvailableReplicas
|
||||||
age := translateTimestampSince(obj.CreationTimestamp)
|
age := translateTimestampSince(obj.CreationTimestamp)
|
||||||
containers := obj.Spec.Template.Spec.Containers
|
containers := obj.Spec.Template.Spec.Containers
|
||||||
@ -1571,7 +1569,7 @@ func printDeployment(obj *apps.Deployment, options printers.PrintOptions) ([]met
|
|||||||
// this shouldn't happen if LabelSelector passed validation
|
// this shouldn't happen if LabelSelector passed validation
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(updatedReplicas), int64(availableReplicas), age)
|
row.Cells = append(row.Cells, obj.Name, fmt.Sprintf("%d/%d", int64(readyReplicas), int64(desiredReplicas)), int64(updatedReplicas), int64(availableReplicas), age)
|
||||||
if options.Wide {
|
if options.Wide {
|
||||||
containers, images := layoutContainerCells(containers)
|
containers, images := layoutContainerCells(containers)
|
||||||
row.Cells = append(row.Cells, containers, images, selector.String())
|
row.Cells = append(row.Cells, containers, images, selector.String())
|
||||||
|
@ -2006,8 +2006,8 @@ func TestPrintDeployment(t *testing.T) {
|
|||||||
UnavailableReplicas: 4,
|
UnavailableReplicas: 4,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"test1\t5\t10\t2\t1\t0s\n",
|
"test1\t0/5\t2\t1\t0s\n",
|
||||||
"test1\t5\t10\t2\t1\t0s\tfake-container1,fake-container2\tfake-image1,fake-image2\tfoo=bar\n",
|
"test1\t0/5\t2\t1\t0s\tfake-container1,fake-container2\tfake-image1,fake-image2\tfoo=bar\n",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user