mirror of
https://github.com/kubernetes/kubectl.git
synced 2026-05-28 04:35:50 -04:00
Merge pull request #137547 from kfess/feature/describe-statefulset
feature: add ServiceName, PodManagementPolicy, and PersistentVolumeClaimRetentionPolicy to kubectl describe statefulset output Kubernetes-commit: c3c78e4355ac93436b4c95f39cf1ce576a3f8f41
This commit is contained in:
commit
b009727eb7
2 changed files with 37 additions and 5 deletions
|
|
@ -3703,6 +3703,12 @@ func describeStatefulSet(ps *appsv1.StatefulSet, selector labels.Selector, event
|
|||
w.Write(LEVEL_0, "Selector:\t%s\n", selector)
|
||||
printLabelsMultiline(w, "Labels", ps.Labels)
|
||||
printAnnotationsMultiline(w, "Annotations", ps.Annotations)
|
||||
if len(ps.Spec.ServiceName) > 0 {
|
||||
w.Write(LEVEL_0, "Service Name:\t%s\n", ps.Spec.ServiceName)
|
||||
}
|
||||
if len(ps.Spec.PodManagementPolicy) > 0 {
|
||||
w.Write(LEVEL_0, "Pod Management Policy:\t%s\n", ps.Spec.PodManagementPolicy)
|
||||
}
|
||||
w.Write(LEVEL_0, "Replicas:\t%d desired | %d total\n", *ps.Spec.Replicas, ps.Status.Replicas)
|
||||
w.Write(LEVEL_0, "Update Strategy:\t%s\n", ps.Spec.UpdateStrategy.Type)
|
||||
if ps.Spec.UpdateStrategy.RollingUpdate != nil {
|
||||
|
|
@ -3714,7 +3720,11 @@ func describeStatefulSet(ps *appsv1.StatefulSet, selector labels.Selector, event
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ps.Spec.PersistentVolumeClaimRetentionPolicy != nil {
|
||||
w.Write(LEVEL_0, "Persistent Volume Claim Retention Policy:\n")
|
||||
w.Write(LEVEL_1, "WhenDeleted:\t%s\n", ps.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted)
|
||||
w.Write(LEVEL_1, "WhenScaled:\t%s\n", ps.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled)
|
||||
}
|
||||
w.Write(LEVEL_0, "Pods Status:\t%d Running / %d Waiting / %d Succeeded / %d Failed\n", running, waiting, succeeded, failed)
|
||||
DescribePodTemplate(&ps.Spec.Template, w)
|
||||
describeVolumeClaimTemplates(ps.Spec.VolumeClaimTemplates, w)
|
||||
|
|
|
|||
|
|
@ -6850,15 +6850,26 @@ func TestDescribeStatefulSet(t *testing.T) {
|
|||
Namespace: "foo",
|
||||
},
|
||||
Spec: appsv1.StatefulSetSpec{
|
||||
Replicas: &replicas,
|
||||
Selector: &metav1.LabelSelector{},
|
||||
PodManagementPolicy: appsv1.ParallelPodManagement,
|
||||
Replicas: &replicas,
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{"app": "mytest"},
|
||||
},
|
||||
Template: corev1.PodTemplateSpec{
|
||||
Spec: corev1.PodSpec{
|
||||
Containers: []corev1.Container{
|
||||
{Image: "mytest-image:latest"},
|
||||
{
|
||||
Name: "mytest",
|
||||
Image: "mytest-image:latest",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ServiceName: "test-service",
|
||||
PersistentVolumeClaimRetentionPolicy: &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{
|
||||
WhenDeleted: appsv1.DeletePersistentVolumeClaimRetentionPolicyType,
|
||||
WhenScaled: appsv1.RetainPersistentVolumeClaimRetentionPolicyType,
|
||||
},
|
||||
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
|
||||
Type: appsv1.RollingUpdateStatefulSetStrategyType,
|
||||
RollingUpdate: &appsv1.RollingUpdateStatefulSetStrategy{
|
||||
|
|
@ -6874,7 +6885,18 @@ func TestDescribeStatefulSet(t *testing.T) {
|
|||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
expectedOutputs := []string{
|
||||
"bar", "foo", "Containers:", "mytest-image:latest", "Update Strategy", "RollingUpdate", "Partition", "2672",
|
||||
"Name: bar",
|
||||
"Namespace: foo",
|
||||
"CreationTimestamp: Mon, 01 Jan 0001 00:00:00 +0000",
|
||||
"Selector: app=mytest",
|
||||
"Service Name: test-service",
|
||||
"Pod Management Policy: Parallel",
|
||||
"Replicas: 1 desired | 0 total",
|
||||
"Update Strategy: RollingUpdate",
|
||||
" Partition: 2672",
|
||||
"Persistent Volume Claim Retention Policy:",
|
||||
" WhenDeleted: Delete",
|
||||
" WhenScaled: Retain",
|
||||
}
|
||||
for _, o := range expectedOutputs {
|
||||
if !strings.Contains(out, o) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue