'Go lang / client : How to describe a node using go/ client

I want to use go client to describe a node, to be specific I want to list the node condition types and it's status and also events.

Edit: I was able to describe the node and get node condition but not events or cpu/memory.



Solution 1:[1]

I found below to get node conditions and status but not events.

nodes, _ := clientset.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})

for _, node := range nodes.Items {
fmt.Printf("%s\n", node.Name)
    
        for _, condition := range node.Status.Conditions {
        fmt.Printf("\t%s: %s\n", condition.Type, condition.Status)
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sam