mirror of https://github.com/k3s-io/k3s
Add pod name to node describe
parent
86a0193f51
commit
aec068f7ef
|
@ -289,6 +289,18 @@ func (d *MinionDescriber) Describe(namespace, name string) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
|
||||
var pods []api.Pod
|
||||
allPods, err := d.Pods(namespace).List(labels.Everything())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
for _, pod := range allPods.Items {
|
||||
if pod.Status.Host != name {
|
||||
continue
|
||||
}
|
||||
pods = append(pods, pod)
|
||||
}
|
||||
|
||||
events, _ := d.Events(namespace).Search(minion)
|
||||
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
|
@ -305,6 +317,13 @@ func (d *MinionDescriber) Describe(namespace, name string) (string, error) {
|
|||
c.Message)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(out, "Pods:\t(%d in total)\n", len(pods))
|
||||
for _, pod := range pods {
|
||||
if pod.Status.Host != name {
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(out, " %s\n", pod.Name)
|
||||
}
|
||||
if events != nil {
|
||||
describeEvents(events, out)
|
||||
}
|
||||
|
@ -318,9 +337,9 @@ func describeEvents(el *api.EventList, w io.Writer) {
|
|||
return
|
||||
}
|
||||
sort.Sort(SortableEvents(el.Items))
|
||||
fmt.Fprint(w, "Events:\nFirstSeen\tLastSeen\tCount\tFrom\tSubobjectPath\tReason\tMessage\n")
|
||||
fmt.Fprint(w, "Events:\n FirstSeen\tLastSeen\tCount\tFrom\tSubobjectPath\tReason\tMessage\n")
|
||||
for _, e := range el.Items {
|
||||
fmt.Fprintf(w, "%s\t%s\t%d\t%v\t%v\t%v\t%v\n",
|
||||
fmt.Fprintf(w, " %s\t%s\t%d\t%v\t%v\t%v\t%v\n",
|
||||
e.FirstTimestamp.Time.Format(time.RFC1123Z),
|
||||
e.LastTimestamp.Time.Format(time.RFC1123Z),
|
||||
e.Count,
|
||||
|
|
|
@ -221,7 +221,7 @@ var podColumns = []string{"POD", "IP", "CONTAINER(S)", "IMAGE(S)", "HOST", "LABE
|
|||
var replicationControllerColumns = []string{"CONTROLLER", "CONTAINER(S)", "IMAGE(S)", "SELECTOR", "REPLICAS"}
|
||||
var serviceColumns = []string{"NAME", "LABELS", "SELECTOR", "IP", "PORT"}
|
||||
var endpointColumns = []string{"NAME", "ENDPOINTS"}
|
||||
var minionColumns = []string{"NAME", "LABELS", "STATUS"}
|
||||
var nodeColumns = []string{"NAME", "LABELS", "STATUS"}
|
||||
var statusColumns = []string{"STATUS"}
|
||||
var eventColumns = []string{"FIRSTSEEN", "LASTSEEN", "COUNT", "NAME", "KIND", "SUBOBJECT", "REASON", "SOURCE", "MESSAGE"}
|
||||
var limitRangeColumns = []string{"NAME"}
|
||||
|
@ -238,8 +238,8 @@ func (h *HumanReadablePrinter) addDefaultHandlers() {
|
|||
h.Handler(serviceColumns, printService)
|
||||
h.Handler(serviceColumns, printServiceList)
|
||||
h.Handler(endpointColumns, printEndpoints)
|
||||
h.Handler(minionColumns, printMinion)
|
||||
h.Handler(minionColumns, printMinionList)
|
||||
h.Handler(nodeColumns, printNode)
|
||||
h.Handler(nodeColumns, printNodeList)
|
||||
h.Handler(statusColumns, printStatus)
|
||||
h.Handler(eventColumns, printEvent)
|
||||
h.Handler(eventColumns, printEventList)
|
||||
|
@ -408,11 +408,11 @@ func printSecretList(list *api.SecretList, w io.Writer) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func printMinion(minion *api.Node, w io.Writer) error {
|
||||
func printNode(node *api.Node, w io.Writer) error {
|
||||
conditionMap := make(map[api.NodeConditionKind]*api.NodeCondition)
|
||||
NodeAllConditions := []api.NodeConditionKind{api.NodeReady, api.NodeReachable}
|
||||
for i := range minion.Status.Conditions {
|
||||
cond := minion.Status.Conditions[i]
|
||||
for i := range node.Status.Conditions {
|
||||
cond := node.Status.Conditions[i]
|
||||
conditionMap[cond.Kind] = &cond
|
||||
}
|
||||
var status []string
|
||||
|
@ -428,13 +428,13 @@ func printMinion(minion *api.Node, w io.Writer) error {
|
|||
if len(status) == 0 {
|
||||
status = append(status, "Unknown")
|
||||
}
|
||||
_, err := fmt.Fprintf(w, "%s\t%s\t%s\n", minion.Name, formatLabels(minion.Labels), strings.Join(status, ","))
|
||||
_, err := fmt.Fprintf(w, "%s\t%s\t%s\n", node.Name, formatLabels(node.Labels), strings.Join(status, ","))
|
||||
return err
|
||||
}
|
||||
|
||||
func printMinionList(list *api.NodeList, w io.Writer) error {
|
||||
for _, minion := range list.Items {
|
||||
if err := printMinion(&minion, w); err != nil {
|
||||
func printNodeList(list *api.NodeList, w io.Writer) error {
|
||||
for _, node := range list.Items {
|
||||
if err := printNode(&node, w); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue