mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 11:38:15 +00:00
add ContainerRuntimeVersion to kubectl get nodes -o=wide
output
This commit is contained in:
parent
68dd748ba1
commit
8c0c7626eb
@ -71,7 +71,7 @@ var (
|
||||
statefulSetColumns = []string{"NAME", "DESIRED", "CURRENT", "AGE"}
|
||||
endpointColumns = []string{"NAME", "ENDPOINTS", "AGE"}
|
||||
nodeColumns = []string{"NAME", "STATUS", "AGE", "VERSION"}
|
||||
nodeWideColumns = []string{"EXTERNAL-IP", "OS-IMAGE", "KERNEL-VERSION"}
|
||||
nodeWideColumns = []string{"EXTERNAL-IP", "OS-IMAGE", "KERNEL-VERSION", "CONTAINER-RUNTIME"}
|
||||
daemonSetColumns = []string{"NAME", "DESIRED", "CURRENT", "READY", "UP-TO-DATE", "AVAILABLE", "NODE-SELECTOR", "AGE"}
|
||||
daemonSetWideColumns = []string{"CONTAINER(S)", "IMAGE(S)", "SELECTOR"}
|
||||
eventColumns = []string{"LASTSEEN", "FIRSTSEEN", "COUNT", "NAME", "KIND", "SUBOBJECT", "TYPE", "REASON", "SOURCE", "MESSAGE"}
|
||||
@ -1127,14 +1127,17 @@ func printNode(node *api.Node, w io.Writer, options printers.PrintOptions) error
|
||||
}
|
||||
|
||||
if options.Wide {
|
||||
osImage, kernelVersion := node.Status.NodeInfo.OSImage, node.Status.NodeInfo.KernelVersion
|
||||
osImage, kernelVersion, crVersion := node.Status.NodeInfo.OSImage, node.Status.NodeInfo.KernelVersion, node.Status.NodeInfo.ContainerRuntimeVersion
|
||||
if osImage == "" {
|
||||
osImage = "<unknown>"
|
||||
}
|
||||
if kernelVersion == "" {
|
||||
kernelVersion = "<unknown>"
|
||||
}
|
||||
if _, err := fmt.Fprintf(w, "\t%s\t%s\t%s", getNodeExternalIP(node), osImage, kernelVersion); err != nil {
|
||||
if crVersion == "" {
|
||||
crVersion = "<unknown>"
|
||||
}
|
||||
if _, err := fmt.Fprintf(w, "\t%s\t%s\t%s\t%s", getNodeExternalIP(node), osImage, kernelVersion, crVersion); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -826,6 +826,51 @@ func TestPrintNodeKernelVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintNodeContainerRuntimeVersion(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(nil, nil, printers.PrintOptions{
|
||||
ColumnLabels: []string{},
|
||||
Wide: true,
|
||||
})
|
||||
AddHandlers(printer)
|
||||
|
||||
table := []struct {
|
||||
node api.Node
|
||||
containerRuntimeVersion string
|
||||
}{
|
||||
{
|
||||
node: api.Node{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo1"},
|
||||
Status: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{ContainerRuntimeVersion: "foo://1.2.3"},
|
||||
Addresses: []api.NodeAddress{{Type: api.NodeExternalIP, Address: "1.1.1.1"}},
|
||||
},
|
||||
},
|
||||
containerRuntimeVersion: "foo://1.2.3",
|
||||
},
|
||||
{
|
||||
node: api.Node{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo2"},
|
||||
Status: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{},
|
||||
Addresses: []api.NodeAddress{{Type: api.NodeExternalIP, Address: "1.1.1.1"}},
|
||||
},
|
||||
},
|
||||
containerRuntimeVersion: "<unknown>",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range table {
|
||||
buffer := &bytes.Buffer{}
|
||||
err := printer.PrintObj(&test.node, buffer)
|
||||
if err != nil {
|
||||
t.Fatalf("An error occurred printing Node: %#v", err)
|
||||
}
|
||||
if !contains(strings.Fields(buffer.String()), test.containerRuntimeVersion) {
|
||||
t.Fatalf("Expect printing node %s with kernel version %#v, got: %#v", test.node.Name, test.containerRuntimeVersion, buffer.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintNodeName(t *testing.T) {
|
||||
printer := printers.NewHumanReadablePrinter(nil, nil, printers.PrintOptions{
|
||||
Wide: true,
|
||||
|
Loading…
Reference in New Issue
Block a user