26
26
k8sClient * kubernetes.Clientset
27
27
28
28
prometheus struct {
29
+ nodePoolStatus * prometheus.GaugeVec
29
30
nodeApplied * prometheus.GaugeVec
30
31
}
31
32
}
@@ -38,10 +39,19 @@ func (m *KubePoolManager) Init() {
38
39
}
39
40
40
41
func (r * KubePoolManager ) initPrometheus () {
42
+ r .prometheus .nodePoolStatus = prometheus .NewGaugeVec (
43
+ prometheus.GaugeOpts {
44
+ Name : "poolmanager_node_pool_status" ,
45
+ Help : "kube-pool-manager node pool config status" ,
46
+ },
47
+ []string {"nodeName" , "pool" },
48
+ )
49
+ prometheus .MustRegister (r .prometheus .nodePoolStatus )
50
+
41
51
r .prometheus .nodeApplied = prometheus .NewGaugeVec (
42
52
prometheus.GaugeOpts {
43
53
Name : "poolmanager_node_applied" ,
44
- Help : "kube-pool-manager node status " ,
54
+ Help : "kube-pool-manager node applied time " ,
45
55
},
46
56
[]string {"nodeName" },
47
57
)
@@ -97,9 +107,9 @@ func (m *KubePoolManager) startWatch() {
97
107
func (m * KubePoolManager ) applyNode (node * corev1.Node ) {
98
108
contextLogger := log .WithField ("node" , node .Name )
99
109
100
- m .prometheus .nodeApplied .WithLabelValues (node .Name ).Set (0 )
101
110
102
111
for _ , poolConfig := range m .Config .Pools {
112
+ m .prometheus .nodePoolStatus .WithLabelValues (node .Name , poolConfig .Name ).Set (0 )
103
113
poolLogger := contextLogger .WithField ("pool" , poolConfig .Name )
104
114
matching , err := poolConfig .IsMatchingNode (node )
105
115
if err != nil {
@@ -128,7 +138,8 @@ func (m *KubePoolManager) applyNode(node *corev1.Node) {
128
138
poolLogger .Infof ("Not applying pool config, dry-run active" )
129
139
}
130
140
131
- m .prometheus .nodeApplied .WithLabelValues (node .Name ).Set (1 )
141
+ m .prometheus .nodePoolStatus .WithLabelValues (node .Name , poolConfig .Name ).Set (1 )
142
+ m .prometheus .nodeApplied .WithLabelValues (node .Name ).SetToCurrentTime ()
132
143
133
144
// check if this more pool configurations should be applied
134
145
if ! poolConfig .Continue {
0 commit comments