@@ -385,9 +385,10 @@ func (this *summaryMetricsSource) getSystemContainerName(c *stats.ContainerStats
385
385
386
386
// TODO: The summaryProvider duplicates a lot of code from kubeletProvider, and should be refactored.
387
387
type summaryProvider struct {
388
- nodeLister v1listers.NodeLister
389
- reflector * cache.Reflector
390
- kubeletClient * kubelet.KubeletClient
388
+ nodeLister v1listers.NodeLister
389
+ reflector * cache.Reflector
390
+ kubeletClient * kubelet.KubeletClient
391
+ hostIDAnnotation string
391
392
}
392
393
393
394
func (this * summaryProvider ) GetMetricsSources () []MetricsSource {
@@ -418,10 +419,14 @@ func (this *summaryProvider) getNodeInfo(node *kube_api.Node) (NodeInfo, error)
418
419
if hostname == "" {
419
420
hostname = node .Name
420
421
}
422
+ hostID := node .Spec .ExternalID
423
+ if hostID == "" && this .hostIDAnnotation != "" {
424
+ hostID = node .Annotations [this .hostIDAnnotation ]
425
+ }
421
426
info := NodeInfo {
422
427
NodeName : node .Name ,
423
428
HostName : hostname ,
424
- HostID : node . Spec . ExternalID ,
429
+ HostID : hostID ,
425
430
Host : kubelet.Host {
426
431
IP : ip ,
427
432
Port : this .kubeletClient .GetPort (),
@@ -432,6 +437,12 @@ func (this *summaryProvider) getNodeInfo(node *kube_api.Node) (NodeInfo, error)
432
437
}
433
438
434
439
func NewSummaryProvider (uri * url.URL ) (MetricsSourceProvider , error ) {
440
+ opts := uri .Query ()
441
+
442
+ hostIDAnnotation := ""
443
+ if len (opts ["host_id_annotation" ]) > 0 {
444
+ hostIDAnnotation = opts ["host_id_annotation" ][0 ]
445
+ }
435
446
// create clients
436
447
kubeConfig , kubeletConfig , err := kubelet .GetKubeConfigs (uri )
437
448
if err != nil {
@@ -446,8 +457,9 @@ func NewSummaryProvider(uri *url.URL) (MetricsSourceProvider, error) {
446
457
nodeLister , reflector , _ := util .GetNodeLister (kubeClient )
447
458
448
459
return & summaryProvider {
449
- nodeLister : nodeLister ,
450
- reflector : reflector ,
451
- kubeletClient : kubeletClient ,
460
+ nodeLister : nodeLister ,
461
+ reflector : reflector ,
462
+ kubeletClient : kubeletClient ,
463
+ hostIDAnnotation : hostIDAnnotation ,
452
464
}, nil
453
465
}
0 commit comments