mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
fix: node failed to get role (#1535)
Co-authored-by: 曲源成 <quyc@goodrain.com>
This commit is contained in:
parent
3c83770c82
commit
cd4faba222
@ -28,6 +28,8 @@ import (
|
||||
const (
|
||||
// NodeRolesLabelPrefix -
|
||||
NodeRolesLabelPrefix = "node-role.kubernetes.io"
|
||||
// NodeRolesLabel -
|
||||
NodeRolesLabel = "kubernetes.io/role"
|
||||
// NodeInternalIP -
|
||||
NodeInternalIP = "InternalIP"
|
||||
// NodeExternalIP -
|
||||
@ -151,12 +153,16 @@ func (n *nodesHandle) HandleNodeInfo(node v1.Node) (nodeinfo model.NodeInfo, err
|
||||
}
|
||||
// get node roles
|
||||
var roles []string
|
||||
for k := range node.Labels {
|
||||
for k, v := range node.Labels {
|
||||
if strings.HasPrefix(k, NodeRolesLabelPrefix) {
|
||||
// string handle : node-role.kubernetes.io/worker: "true"
|
||||
role := strings.Split(k, "/")[1]
|
||||
roles = append(roles, role)
|
||||
}
|
||||
if strings.HasPrefix(k, NodeRolesLabel) {
|
||||
// string handle : kubernetes.io/role: master
|
||||
roles = append(roles, v)
|
||||
}
|
||||
continue
|
||||
}
|
||||
// req resource from Prometheus
|
||||
|
Loading…
Reference in New Issue
Block a user