英文:
Go lang / client : How to describe a node using go/ client
问题
我想使用Go客户端来描述一个节点,具体来说,我想列出节点的条件类型、状态和事件。
编辑:我已经能够描述节点并获取节点的条件,但无法获取事件或CPU/内存信息。
英文:
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.
答案1
得分: 1
我找到了以下代码来获取节点的条件和状态,但没有事件。
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)
}
}
这段代码可以列出节点的名称以及每个节点的条件和状态。
英文:
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)
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论