Skip to content

Commit

Permalink
feat(client): add function to gather node info (#17)
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <[email protected]>
  • Loading branch information
niladrih authored Nov 10, 2023
1 parent 02b3c15 commit ec872cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# IDEs
**/.idea

# Binaries for programs and plugins
*.exe
*.exe~
Expand Down
18 changes: 18 additions & 0 deletions pkg/client/k8s/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,21 @@ func GetOSAndKernelVersion() (string, error) {
nodedetails := firstNode.Items[0].Status.NodeInfo
return nodedetails.OSImage + ", " + nodedetails.KernelVersion, nil
}

// GetNodeInfo gathers details from the first Kubernetes Node and returns -- OS, Kernel version and Arch.
func GetNodeInfo() (nodeOs, nodeKernelVersion, nodeArch string, err error) {
nodes := Node()
firstNode, err := nodes.List(metav1.ListOptions{Limit: 1})
if err != nil {
return "unknown",
"unknown",
"unknown",
errors.Wrapf(err, "failed to get the os kernel/arch")
}

nodeOs = firstNode.Items[0].Status.NodeInfo.OSImage
nodeKernelVersion = firstNode.Items[0].Status.NodeInfo.KernelVersion
nodeArch = firstNode.Items[0].Status.NodeInfo.Architecture

return
}

0 comments on commit ec872cc

Please sign in to comment.