mirror of https://github.com/k3s-io/k3s
Add software versions to "kubectl get nodes -o wide" output.
Added "OS-IMAGE" and "KERNEL-VERSION" two columns to "kubectl get nodes -o wide" output. This will help to provide more information for user to locate or debug issues. See discussion in ticket #25579pull/6/head
parent
de59ede6b2
commit
5edac7c575
|
@ -494,7 +494,7 @@ var (
|
|||
statefulSetColumns = []string{"NAME", "DESIRED", "CURRENT", "AGE"}
|
||||
endpointColumns = []string{"NAME", "ENDPOINTS", "AGE"}
|
||||
nodeColumns = []string{"NAME", "STATUS", "AGE", "VERSION"}
|
||||
nodeWideColumns = []string{"EXTERNAL-IP"}
|
||||
nodeWideColumns = []string{"EXTERNAL-IP", "OS-IMAGE", "KERNEL-VERSION"}
|
||||
daemonSetColumns = []string{"NAME", "DESIRED", "CURRENT", "READY", "NODE-SELECTOR", "AGE"}
|
||||
daemonSetWideColumns = []string{"CONTAINER(S)", "IMAGE(S)", "SELECTOR"}
|
||||
eventColumns = []string{"LASTSEEN", "FIRSTSEEN", "COUNT", "NAME", "KIND", "SUBOBJECT", "TYPE", "REASON", "SOURCE", "MESSAGE"}
|
||||
|
@ -1550,7 +1550,14 @@ func printNode(node *api.Node, w io.Writer, options PrintOptions) error {
|
|||
}
|
||||
|
||||
if options.Wide {
|
||||
if _, err := fmt.Fprintf(w, "\t%s", getNodeExternalIP(node)); err != nil {
|
||||
osImage, kernelVersion := node.Status.NodeInfo.OSImage, node.Status.NodeInfo.KernelVersion
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -727,6 +727,94 @@ func TestPrintNodeStatus(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPrintNodeOSImage(t *testing.T) {
|
||||
printer := NewHumanReadablePrinter(PrintOptions{
|
||||
ColumnLabels: []string{},
|
||||
Wide: true,
|
||||
})
|
||||
|
||||
table := []struct {
|
||||
node api.Node
|
||||
osImage string
|
||||
}{
|
||||
{
|
||||
node: api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo1"},
|
||||
Status: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{OSImage: "fake-os-image"},
|
||||
Addresses: []api.NodeAddress{{Type: api.NodeExternalIP, Address: "1.1.1.1"}},
|
||||
},
|
||||
},
|
||||
osImage: "fake-os-image",
|
||||
},
|
||||
{
|
||||
node: api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo2"},
|
||||
Status: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{KernelVersion: "fake-kernel-version"},
|
||||
Addresses: []api.NodeAddress{{Type: api.NodeExternalIP, Address: "1.1.1.1"}},
|
||||
},
|
||||
},
|
||||
osImage: "<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.osImage) {
|
||||
t.Fatalf("Expect printing node %s with os image %#v, got: %#v", test.node.Name, test.osImage, buffer.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintNodeKernelVersion(t *testing.T) {
|
||||
printer := NewHumanReadablePrinter(PrintOptions{
|
||||
ColumnLabels: []string{},
|
||||
Wide: true,
|
||||
})
|
||||
|
||||
table := []struct {
|
||||
node api.Node
|
||||
kernelVersion string
|
||||
}{
|
||||
{
|
||||
node: api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo1"},
|
||||
Status: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{KernelVersion: "fake-kernel-version"},
|
||||
Addresses: []api.NodeAddress{{Type: api.NodeExternalIP, Address: "1.1.1.1"}},
|
||||
},
|
||||
},
|
||||
kernelVersion: "fake-kernel-version",
|
||||
},
|
||||
{
|
||||
node: api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo2"},
|
||||
Status: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{OSImage: "fake-os-image"},
|
||||
Addresses: []api.NodeAddress{{Type: api.NodeExternalIP, Address: "1.1.1.1"}},
|
||||
},
|
||||
},
|
||||
kernelVersion: "<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.kernelVersion) {
|
||||
t.Fatalf("Expect printing node %s with kernel version %#v, got: %#v", test.node.Name, test.kernelVersion, buffer.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintNodeExternalIP(t *testing.T) {
|
||||
printer := NewHumanReadablePrinter(PrintOptions{
|
||||
Wide: true,
|
||||
|
|
Loading…
Reference in New Issue