Sam
Sam

Reputation: 415

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.

Upvotes: 1

Views: 684

Answers (1)

Sam
Sam

Reputation: 415

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)
    }
}

Upvotes: 1

Related Questions