mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Improved CLI for PVClaims
This commit is contained in:
parent
f620b0d53d
commit
f37113aa25
@ -34,6 +34,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/types"
|
"k8s.io/kubernetes/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Describer generates output for the named resource or an error
|
// Describer generates output for the named resource or an error
|
||||||
@ -443,6 +444,8 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, er
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storage := pv.Spec.Capacity[api.ResourceStorage]
|
||||||
|
|
||||||
return tabbedString(func(out io.Writer) error {
|
return tabbedString(func(out io.Writer) error {
|
||||||
fmt.Fprintf(out, "Name:\t%s\n", pv.Name)
|
fmt.Fprintf(out, "Name:\t%s\n", pv.Name)
|
||||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pv.Labels))
|
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pv.Labels))
|
||||||
@ -453,6 +456,8 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, er
|
|||||||
fmt.Fprintf(out, "Claim:\t%s\n", "")
|
fmt.Fprintf(out, "Claim:\t%s\n", "")
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, "Reclaim Policy:\t%v\n", pv.Spec.PersistentVolumeReclaimPolicy)
|
fmt.Fprintf(out, "Reclaim Policy:\t%v\n", pv.Spec.PersistentVolumeReclaimPolicy)
|
||||||
|
fmt.Fprintf(out, "Access Modes:\t%s\n", volume.GetAccessModesAsString(pv.Spec.AccessModes))
|
||||||
|
fmt.Fprintf(out, "Capacity:\t%s\n", storage.String())
|
||||||
fmt.Fprintf(out, "Message:\t%s\n", pv.Status.Message)
|
fmt.Fprintf(out, "Message:\t%s\n", pv.Status.Message)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -470,12 +475,24 @@ func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string) (strin
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
labels := formatLabels(pvc.Labels)
|
||||||
|
storage := pvc.Spec.Resources.Requests[api.ResourceStorage]
|
||||||
|
capacity := ""
|
||||||
|
accessModes := ""
|
||||||
|
if pvc.Spec.VolumeName != "" {
|
||||||
|
accessModes = volume.GetAccessModesAsString(pvc.Status.AccessModes)
|
||||||
|
storage = pvc.Status.Capacity[api.ResourceStorage]
|
||||||
|
capacity = storage.String()
|
||||||
|
}
|
||||||
|
|
||||||
return tabbedString(func(out io.Writer) error {
|
return tabbedString(func(out io.Writer) error {
|
||||||
fmt.Fprintf(out, "Name:\t%s\n", pvc.Name)
|
fmt.Fprintf(out, "Name:\t%s\n", pvc.Name)
|
||||||
fmt.Fprintf(out, "Namespace:\t%s\n", pvc.Namespace)
|
fmt.Fprintf(out, "Namespace:\t%s\n", pvc.Namespace)
|
||||||
fmt.Fprintf(out, "Status:\t%v\n", pvc.Status.Phase)
|
fmt.Fprintf(out, "Status:\t%v\n", pvc.Status.Phase)
|
||||||
fmt.Fprintf(out, "Volume:\t%s\n", pvc.Spec.VolumeName)
|
fmt.Fprintf(out, "Volume:\t%s\n", pvc.Spec.VolumeName)
|
||||||
|
fmt.Fprintf(out, "Labels:\t%s\n", labels)
|
||||||
|
fmt.Fprintf(out, "Capacity:\t%s\n", capacity)
|
||||||
|
fmt.Fprintf(out, "Access Modes:\t%s\n", accessModes)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ var namespaceColumns = []string{"NAME", "LABELS", "STATUS", "AGE"}
|
|||||||
var secretColumns = []string{"NAME", "TYPE", "DATA", "AGE"}
|
var secretColumns = []string{"NAME", "TYPE", "DATA", "AGE"}
|
||||||
var serviceAccountColumns = []string{"NAME", "SECRETS", "AGE"}
|
var serviceAccountColumns = []string{"NAME", "SECRETS", "AGE"}
|
||||||
var persistentVolumeColumns = []string{"NAME", "LABELS", "CAPACITY", "ACCESSMODES", "STATUS", "CLAIM", "REASON", "AGE"}
|
var persistentVolumeColumns = []string{"NAME", "LABELS", "CAPACITY", "ACCESSMODES", "STATUS", "CLAIM", "REASON", "AGE"}
|
||||||
var persistentVolumeClaimColumns = []string{"NAME", "LABELS", "STATUS", "VOLUME", "AGE"}
|
var persistentVolumeClaimColumns = []string{"NAME", "LABELS", "STATUS", "VOLUME", "CAPACITY", "ACCESSMODES", "AGE"}
|
||||||
var componentStatusColumns = []string{"NAME", "STATUS", "MESSAGE", "ERROR"}
|
var componentStatusColumns = []string{"NAME", "STATUS", "MESSAGE", "ERROR"}
|
||||||
var withNamespacePrefixColumns = []string{"NAMESPACE"} // TODO(erictune): print cluster name too.
|
var withNamespacePrefixColumns = []string{"NAMESPACE"} // TODO(erictune): print cluster name too.
|
||||||
|
|
||||||
@ -779,9 +779,9 @@ func printPersistentVolume(pv *api.PersistentVolume, w io.Writer, withNamespace
|
|||||||
modesStr := volume.GetAccessModesAsString(pv.Spec.AccessModes)
|
modesStr := volume.GetAccessModesAsString(pv.Spec.AccessModes)
|
||||||
|
|
||||||
aQty := pv.Spec.Capacity[api.ResourceStorage]
|
aQty := pv.Spec.Capacity[api.ResourceStorage]
|
||||||
aSize := aQty.Value()
|
aSize := aQty.String()
|
||||||
|
|
||||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%s\t%s\t%s",
|
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s",
|
||||||
name,
|
name,
|
||||||
formatLabels(pv.Labels),
|
formatLabels(pv.Labels),
|
||||||
aSize, modesStr,
|
aSize, modesStr,
|
||||||
@ -815,13 +815,18 @@ func printPersistentVolumeClaim(pvc *api.PersistentVolumeClaim, w io.Writer, wit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if withNamespace {
|
labels := formatLabels(pvc.Labels)
|
||||||
if _, err := fmt.Fprintf(w, "%s\t", namespace); err != nil {
|
phase := pvc.Status.Phase
|
||||||
return err
|
storage := pvc.Spec.Resources.Requests[api.ResourceStorage]
|
||||||
}
|
capacity := ""
|
||||||
|
accessModes := ""
|
||||||
|
if pvc.Spec.VolumeName != "" {
|
||||||
|
accessModes = volume.GetAccessModesAsString(pvc.Status.AccessModes)
|
||||||
|
storage = pvc.Status.Capacity[api.ResourceStorage]
|
||||||
|
capacity = storage.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s", name, pvc.Labels, pvc.Status.Phase, pvc.Spec.VolumeName, translateTimestamp(pvc.CreationTimestamp)); err != nil {
|
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s", name, labels, phase, pvc.Spec.VolumeName, capacity, accessModes, translateTimestamp(pvc.CreationTimestamp)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err := fmt.Fprint(w, appendLabels(pvc.Labels, columnLabels))
|
_, err := fmt.Fprint(w, appendLabels(pvc.Labels, columnLabels))
|
||||||
|
Loading…
Reference in New Issue
Block a user