@@ -65,9 +65,10 @@ var _ ksmtypes.BuilderInterface = &Builder{}
65
65
// Builder helps to build store. It follows the builder pattern
66
66
// (https://en.wikipedia.org/wiki/Builder_pattern).
67
67
type Builder struct {
68
- kubeClient clientset.Interface
69
- customResourceClients map [string ]interface {}
70
- namespaces options.NamespaceList
68
+ kubeClient clientset.Interface
69
+ metadataOnlyKubeClient clientset.Interface
70
+ customResourceClients map [string ]interface {}
71
+ namespaces options.NamespaceList
71
72
// namespaceFilter is inside fieldSelectorFilter
72
73
fieldSelectorFilter string
73
74
ctx context.Context
@@ -157,6 +158,11 @@ func (b *Builder) WithKubeClient(c clientset.Interface) {
157
158
b .kubeClient = c
158
159
}
159
160
161
+ // WithMetadataOnlyKubeClient sets the metadataOnlyKubeClient property of a Builder.
162
+ func (b * Builder ) WithMetadataOnlyKubeClient (c clientset.Interface ) {
163
+ b .metadataOnlyKubeClient = c
164
+ }
165
+
160
166
// WithCustomResourceClients sets the customResourceClients property of a Builder.
161
167
func (b * Builder ) WithCustomResourceClients (cs map [string ]interface {}) {
162
168
b .customResourceClients = cs
@@ -362,150 +368,151 @@ func availableResources() []string {
362
368
}
363
369
364
370
func (b * Builder ) buildConfigMapStores () []cache.Store {
365
- return b .buildStoresFunc (configMapMetricFamilies (b .allowAnnotationsList ["configmaps" ], b .allowLabelsList ["configmaps" ]), & v1.ConfigMap {}, createConfigMapListWatch , b .useAPIServerCache )
371
+ return b .buildStoresFunc (configMapMetricFamilies (b .allowAnnotationsList ["configmaps" ], b .allowLabelsList ["configmaps" ]), & v1.ConfigMap {}, createConfigMapListWatch , b .useAPIServerCache , true )
366
372
}
367
373
368
374
func (b * Builder ) buildCronJobStores () []cache.Store {
369
- return b .buildStoresFunc (cronJobMetricFamilies (b .allowAnnotationsList ["cronjobs" ], b .allowLabelsList ["cronjobs" ]), & batchv1.CronJob {}, createCronJobListWatch , b .useAPIServerCache )
375
+ return b .buildStoresFunc (cronJobMetricFamilies (b .allowAnnotationsList ["cronjobs" ], b .allowLabelsList ["cronjobs" ]), & batchv1.CronJob {}, createCronJobListWatch , b .useAPIServerCache , false )
370
376
}
371
377
372
378
func (b * Builder ) buildDaemonSetStores () []cache.Store {
373
- return b .buildStoresFunc (daemonSetMetricFamilies (b .allowAnnotationsList ["daemonsets" ], b .allowLabelsList ["daemonsets" ]), & appsv1.DaemonSet {}, createDaemonSetListWatch , b .useAPIServerCache )
379
+ return b .buildStoresFunc (daemonSetMetricFamilies (b .allowAnnotationsList ["daemonsets" ], b .allowLabelsList ["daemonsets" ]), & appsv1.DaemonSet {}, createDaemonSetListWatch , b .useAPIServerCache , false )
374
380
}
375
381
376
382
func (b * Builder ) buildDeploymentStores () []cache.Store {
377
- return b .buildStoresFunc (deploymentMetricFamilies (b .allowAnnotationsList ["deployments" ], b .allowLabelsList ["deployments" ]), & appsv1.Deployment {}, createDeploymentListWatch , b .useAPIServerCache )
383
+ return b .buildStoresFunc (deploymentMetricFamilies (b .allowAnnotationsList ["deployments" ], b .allowLabelsList ["deployments" ]), & appsv1.Deployment {}, createDeploymentListWatch , b .useAPIServerCache , false )
378
384
}
379
385
380
386
func (b * Builder ) buildEndpointsStores () []cache.Store {
381
- return b .buildStoresFunc (endpointMetricFamilies (b .allowAnnotationsList ["endpoints" ], b .allowLabelsList ["endpoints" ]), & v1.Endpoints {}, createEndpointsListWatch , b .useAPIServerCache )
387
+ return b .buildStoresFunc (endpointMetricFamilies (b .allowAnnotationsList ["endpoints" ], b .allowLabelsList ["endpoints" ]), & v1.Endpoints {}, createEndpointsListWatch , b .useAPIServerCache , false )
382
388
}
383
389
384
390
func (b * Builder ) buildEndpointSlicesStores () []cache.Store {
385
- return b .buildStoresFunc (endpointSliceMetricFamilies (b .allowAnnotationsList ["endpointslices" ], b .allowLabelsList ["endpointslices" ]), & discoveryv1.EndpointSlice {}, createEndpointSliceListWatch , b .useAPIServerCache )
391
+ return b .buildStoresFunc (endpointSliceMetricFamilies (b .allowAnnotationsList ["endpointslices" ], b .allowLabelsList ["endpointslices" ]), & discoveryv1.EndpointSlice {}, createEndpointSliceListWatch , b .useAPIServerCache , false )
386
392
}
387
393
388
394
func (b * Builder ) buildHPAStores () []cache.Store {
389
- return b .buildStoresFunc (hpaMetricFamilies (b .allowAnnotationsList ["horizontalpodautoscalers" ], b .allowLabelsList ["horizontalpodautoscalers" ]), & autoscaling.HorizontalPodAutoscaler {}, createHPAListWatch , b .useAPIServerCache )
395
+ return b .buildStoresFunc (hpaMetricFamilies (b .allowAnnotationsList ["horizontalpodautoscalers" ], b .allowLabelsList ["horizontalpodautoscalers" ]), & autoscaling.HorizontalPodAutoscaler {}, createHPAListWatch , b .useAPIServerCache , false )
390
396
}
391
397
392
398
func (b * Builder ) buildIngressStores () []cache.Store {
393
- return b .buildStoresFunc (ingressMetricFamilies (b .allowAnnotationsList ["ingresses" ], b .allowLabelsList ["ingresses" ]), & networkingv1.Ingress {}, createIngressListWatch , b .useAPIServerCache )
399
+ return b .buildStoresFunc (ingressMetricFamilies (b .allowAnnotationsList ["ingresses" ], b .allowLabelsList ["ingresses" ]), & networkingv1.Ingress {}, createIngressListWatch , b .useAPIServerCache , false )
394
400
}
395
401
396
402
func (b * Builder ) buildJobStores () []cache.Store {
397
- return b .buildStoresFunc (jobMetricFamilies (b .allowAnnotationsList ["jobs" ], b .allowLabelsList ["jobs" ]), & batchv1.Job {}, createJobListWatch , b .useAPIServerCache )
403
+ return b .buildStoresFunc (jobMetricFamilies (b .allowAnnotationsList ["jobs" ], b .allowLabelsList ["jobs" ]), & batchv1.Job {}, createJobListWatch , b .useAPIServerCache , false )
398
404
}
399
405
400
406
func (b * Builder ) buildLimitRangeStores () []cache.Store {
401
- return b .buildStoresFunc (limitRangeMetricFamilies , & v1.LimitRange {}, createLimitRangeListWatch , b .useAPIServerCache )
407
+ return b .buildStoresFunc (limitRangeMetricFamilies , & v1.LimitRange {}, createLimitRangeListWatch , b .useAPIServerCache , false )
402
408
}
403
409
404
410
func (b * Builder ) buildMutatingWebhookConfigurationStores () []cache.Store {
405
- return b .buildStoresFunc (mutatingWebhookConfigurationMetricFamilies , & admissionregistrationv1.MutatingWebhookConfiguration {}, createMutatingWebhookConfigurationListWatch , b .useAPIServerCache )
411
+ return b .buildStoresFunc (mutatingWebhookConfigurationMetricFamilies , & admissionregistrationv1.MutatingWebhookConfiguration {}, createMutatingWebhookConfigurationListWatch , b .useAPIServerCache , false )
406
412
}
407
413
408
414
func (b * Builder ) buildNamespaceStores () []cache.Store {
409
- return b .buildStoresFunc (namespaceMetricFamilies (b .allowAnnotationsList ["namespaces" ], b .allowLabelsList ["namespaces" ]), & v1.Namespace {}, createNamespaceListWatch , b .useAPIServerCache )
415
+ return b .buildStoresFunc (namespaceMetricFamilies (b .allowAnnotationsList ["namespaces" ], b .allowLabelsList ["namespaces" ]), & v1.Namespace {}, createNamespaceListWatch , b .useAPIServerCache , false )
410
416
}
411
417
412
418
func (b * Builder ) buildNetworkPolicyStores () []cache.Store {
413
- return b .buildStoresFunc (networkPolicyMetricFamilies (b .allowAnnotationsList ["networkpolicies" ], b .allowLabelsList ["networkpolicies" ]), & networkingv1.NetworkPolicy {}, createNetworkPolicyListWatch , b .useAPIServerCache )
419
+ return b .buildStoresFunc (networkPolicyMetricFamilies (b .allowAnnotationsList ["networkpolicies" ], b .allowLabelsList ["networkpolicies" ]), & networkingv1.NetworkPolicy {}, createNetworkPolicyListWatch , b .useAPIServerCache , false )
414
420
}
415
421
416
422
func (b * Builder ) buildNodeStores () []cache.Store {
417
- return b .buildStoresFunc (nodeMetricFamilies (b .allowAnnotationsList ["nodes" ], b .allowLabelsList ["nodes" ]), & v1.Node {}, createNodeListWatch , b .useAPIServerCache )
423
+ return b .buildStoresFunc (nodeMetricFamilies (b .allowAnnotationsList ["nodes" ], b .allowLabelsList ["nodes" ]), & v1.Node {}, createNodeListWatch , b .useAPIServerCache , false )
418
424
}
419
425
420
426
func (b * Builder ) buildPersistentVolumeClaimStores () []cache.Store {
421
- return b .buildStoresFunc (persistentVolumeClaimMetricFamilies (b .allowAnnotationsList ["persistentvolumeclaims" ], b .allowLabelsList ["persistentvolumeclaims" ]), & v1.PersistentVolumeClaim {}, createPersistentVolumeClaimListWatch , b .useAPIServerCache )
427
+ return b .buildStoresFunc (persistentVolumeClaimMetricFamilies (b .allowAnnotationsList ["persistentvolumeclaims" ], b .allowLabelsList ["persistentvolumeclaims" ]), & v1.PersistentVolumeClaim {}, createPersistentVolumeClaimListWatch , b .useAPIServerCache , false )
422
428
}
423
429
424
430
func (b * Builder ) buildPersistentVolumeStores () []cache.Store {
425
- return b .buildStoresFunc (persistentVolumeMetricFamilies (b .allowAnnotationsList ["persistentvolumes" ], b .allowLabelsList ["persistentvolumes" ]), & v1.PersistentVolume {}, createPersistentVolumeListWatch , b .useAPIServerCache )
431
+ return b .buildStoresFunc (persistentVolumeMetricFamilies (b .allowAnnotationsList ["persistentvolumes" ], b .allowLabelsList ["persistentvolumes" ]), & v1.PersistentVolume {}, createPersistentVolumeListWatch , b .useAPIServerCache , false )
426
432
}
427
433
428
434
func (b * Builder ) buildPodDisruptionBudgetStores () []cache.Store {
429
- return b .buildStoresFunc (podDisruptionBudgetMetricFamilies (b .allowAnnotationsList ["poddisruptionbudgets" ], b .allowLabelsList ["poddisruptionbudgets" ]), & policyv1.PodDisruptionBudget {}, createPodDisruptionBudgetListWatch , b .useAPIServerCache )
435
+ return b .buildStoresFunc (podDisruptionBudgetMetricFamilies (b .allowAnnotationsList ["poddisruptionbudgets" ], b .allowLabelsList ["poddisruptionbudgets" ]), & policyv1.PodDisruptionBudget {}, createPodDisruptionBudgetListWatch , b .useAPIServerCache , false )
430
436
}
431
437
432
438
func (b * Builder ) buildReplicaSetStores () []cache.Store {
433
- return b .buildStoresFunc (replicaSetMetricFamilies (b .allowAnnotationsList ["replicasets" ], b .allowLabelsList ["replicasets" ]), & appsv1.ReplicaSet {}, createReplicaSetListWatch , b .useAPIServerCache )
439
+ return b .buildStoresFunc (replicaSetMetricFamilies (b .allowAnnotationsList ["replicasets" ], b .allowLabelsList ["replicasets" ]), & appsv1.ReplicaSet {}, createReplicaSetListWatch , b .useAPIServerCache , false )
434
440
}
435
441
436
442
func (b * Builder ) buildReplicationControllerStores () []cache.Store {
437
- return b .buildStoresFunc (replicationControllerMetricFamilies , & v1.ReplicationController {}, createReplicationControllerListWatch , b .useAPIServerCache )
443
+ return b .buildStoresFunc (replicationControllerMetricFamilies , & v1.ReplicationController {}, createReplicationControllerListWatch , b .useAPIServerCache , false )
438
444
}
439
445
440
446
func (b * Builder ) buildResourceQuotaStores () []cache.Store {
441
- return b .buildStoresFunc (resourceQuotaMetricFamilies (b .allowAnnotationsList ["resourcequotas" ], b .allowLabelsList ["resourcequotas" ]), & v1.ResourceQuota {}, createResourceQuotaListWatch , b .useAPIServerCache )
447
+ return b .buildStoresFunc (resourceQuotaMetricFamilies (b .allowAnnotationsList ["resourcequotas" ], b .allowLabelsList ["resourcequotas" ]), & v1.ResourceQuota {}, createResourceQuotaListWatch , b .useAPIServerCache , false )
442
448
}
443
449
444
450
func (b * Builder ) buildSecretStores () []cache.Store {
445
- return b .buildStoresFunc (secretMetricFamilies (b .allowAnnotationsList ["secrets" ], b .allowLabelsList ["secrets" ]), & v1.Secret {}, createSecretListWatch , b .useAPIServerCache )
451
+ return b .buildStoresFunc (secretMetricFamilies (b .allowAnnotationsList ["secrets" ], b .allowLabelsList ["secrets" ]), & v1.Secret {}, createSecretListWatch , b .useAPIServerCache , true )
446
452
}
447
453
448
454
func (b * Builder ) buildServiceAccountStores () []cache.Store {
449
- return b .buildStoresFunc (serviceAccountMetricFamilies (b .allowAnnotationsList ["serviceaccounts" ], b .allowLabelsList ["serviceaccounts" ]), & v1.ServiceAccount {}, createServiceAccountListWatch , b .useAPIServerCache )
455
+ return b .buildStoresFunc (serviceAccountMetricFamilies (b .allowAnnotationsList ["serviceaccounts" ], b .allowLabelsList ["serviceaccounts" ]), & v1.ServiceAccount {}, createServiceAccountListWatch , b .useAPIServerCache , false )
450
456
}
451
457
452
458
func (b * Builder ) buildServiceStores () []cache.Store {
453
- return b .buildStoresFunc (serviceMetricFamilies (b .allowAnnotationsList ["services" ], b .allowLabelsList ["services" ]), & v1.Service {}, createServiceListWatch , b .useAPIServerCache )
459
+ return b .buildStoresFunc (serviceMetricFamilies (b .allowAnnotationsList ["services" ], b .allowLabelsList ["services" ]), & v1.Service {}, createServiceListWatch , b .useAPIServerCache , false )
454
460
}
455
461
456
462
func (b * Builder ) buildStatefulSetStores () []cache.Store {
457
- return b .buildStoresFunc (statefulSetMetricFamilies (b .allowAnnotationsList ["statefulsets" ], b .allowLabelsList ["statefulsets" ]), & appsv1.StatefulSet {}, createStatefulSetListWatch , b .useAPIServerCache )
463
+ return b .buildStoresFunc (statefulSetMetricFamilies (b .allowAnnotationsList ["statefulsets" ], b .allowLabelsList ["statefulsets" ]), & appsv1.StatefulSet {}, createStatefulSetListWatch , b .useAPIServerCache , false )
458
464
}
459
465
460
466
func (b * Builder ) buildStorageClassStores () []cache.Store {
461
- return b .buildStoresFunc (storageClassMetricFamilies (b .allowAnnotationsList ["storageclasses" ], b .allowLabelsList ["storageclasses" ]), & storagev1.StorageClass {}, createStorageClassListWatch , b .useAPIServerCache )
467
+ return b .buildStoresFunc (storageClassMetricFamilies (b .allowAnnotationsList ["storageclasses" ], b .allowLabelsList ["storageclasses" ]), & storagev1.StorageClass {}, createStorageClassListWatch , b .useAPIServerCache , false )
462
468
}
463
469
464
470
func (b * Builder ) buildPodStores () []cache.Store {
465
- return b .buildStoresFunc (podMetricFamilies (b .allowAnnotationsList ["pods" ], b .allowLabelsList ["pods" ]), & v1.Pod {}, createPodListWatch , b .useAPIServerCache )
471
+ return b .buildStoresFunc (podMetricFamilies (b .allowAnnotationsList ["pods" ], b .allowLabelsList ["pods" ]), & v1.Pod {}, createPodListWatch , b .useAPIServerCache , false )
466
472
}
467
473
468
474
func (b * Builder ) buildCsrStores () []cache.Store {
469
- return b .buildStoresFunc (csrMetricFamilies (b .allowAnnotationsList ["certificatesigningrequests" ], b .allowLabelsList ["certificatesigningrequests" ]), & certv1.CertificateSigningRequest {}, createCSRListWatch , b .useAPIServerCache )
475
+ return b .buildStoresFunc (csrMetricFamilies (b .allowAnnotationsList ["certificatesigningrequests" ], b .allowLabelsList ["certificatesigningrequests" ]), & certv1.CertificateSigningRequest {}, createCSRListWatch , b .useAPIServerCache , false )
470
476
}
471
477
472
478
func (b * Builder ) buildValidatingWebhookConfigurationStores () []cache.Store {
473
- return b .buildStoresFunc (validatingWebhookConfigurationMetricFamilies , & admissionregistrationv1.ValidatingWebhookConfiguration {}, createValidatingWebhookConfigurationListWatch , b .useAPIServerCache )
479
+ return b .buildStoresFunc (validatingWebhookConfigurationMetricFamilies , & admissionregistrationv1.ValidatingWebhookConfiguration {}, createValidatingWebhookConfigurationListWatch , b .useAPIServerCache , false )
474
480
}
475
481
476
482
func (b * Builder ) buildVolumeAttachmentStores () []cache.Store {
477
- return b .buildStoresFunc (volumeAttachmentMetricFamilies , & storagev1.VolumeAttachment {}, createVolumeAttachmentListWatch , b .useAPIServerCache )
483
+ return b .buildStoresFunc (volumeAttachmentMetricFamilies , & storagev1.VolumeAttachment {}, createVolumeAttachmentListWatch , b .useAPIServerCache , false )
478
484
}
479
485
480
486
func (b * Builder ) buildLeasesStores () []cache.Store {
481
- return b .buildStoresFunc (leaseMetricFamilies , & coordinationv1.Lease {}, createLeaseListWatch , b .useAPIServerCache )
487
+ return b .buildStoresFunc (leaseMetricFamilies , & coordinationv1.Lease {}, createLeaseListWatch , b .useAPIServerCache , false )
482
488
}
483
489
484
490
func (b * Builder ) buildClusterRoleStores () []cache.Store {
485
- return b .buildStoresFunc (clusterRoleMetricFamilies (b .allowAnnotationsList ["clusterroles" ], b .allowLabelsList ["clusterroles" ]), & rbacv1.ClusterRole {}, createClusterRoleListWatch , b .useAPIServerCache )
491
+ return b .buildStoresFunc (clusterRoleMetricFamilies (b .allowAnnotationsList ["clusterroles" ], b .allowLabelsList ["clusterroles" ]), & rbacv1.ClusterRole {}, createClusterRoleListWatch , b .useAPIServerCache , false )
486
492
}
487
493
488
494
func (b * Builder ) buildRoleStores () []cache.Store {
489
- return b .buildStoresFunc (roleMetricFamilies (b .allowAnnotationsList ["roles" ], b .allowLabelsList ["roles" ]), & rbacv1.Role {}, createRoleListWatch , b .useAPIServerCache )
495
+ return b .buildStoresFunc (roleMetricFamilies (b .allowAnnotationsList ["roles" ], b .allowLabelsList ["roles" ]), & rbacv1.Role {}, createRoleListWatch , b .useAPIServerCache , false )
490
496
}
491
497
492
498
func (b * Builder ) buildClusterRoleBindingStores () []cache.Store {
493
- return b .buildStoresFunc (clusterRoleBindingMetricFamilies (b .allowAnnotationsList ["clusterrolebindings" ], b .allowLabelsList ["clusterrolebindings" ]), & rbacv1.ClusterRoleBinding {}, createClusterRoleBindingListWatch , b .useAPIServerCache )
499
+ return b .buildStoresFunc (clusterRoleBindingMetricFamilies (b .allowAnnotationsList ["clusterrolebindings" ], b .allowLabelsList ["clusterrolebindings" ]), & rbacv1.ClusterRoleBinding {}, createClusterRoleBindingListWatch , b .useAPIServerCache , false )
494
500
}
495
501
496
502
func (b * Builder ) buildRoleBindingStores () []cache.Store {
497
- return b .buildStoresFunc (roleBindingMetricFamilies (b .allowAnnotationsList ["rolebindings" ], b .allowLabelsList ["rolebindings" ]), & rbacv1.RoleBinding {}, createRoleBindingListWatch , b .useAPIServerCache )
503
+ return b .buildStoresFunc (roleBindingMetricFamilies (b .allowAnnotationsList ["rolebindings" ], b .allowLabelsList ["rolebindings" ]), & rbacv1.RoleBinding {}, createRoleBindingListWatch , b .useAPIServerCache , false )
498
504
}
499
505
500
506
func (b * Builder ) buildIngressClassStores () []cache.Store {
501
- return b .buildStoresFunc (ingressClassMetricFamilies (b .allowAnnotationsList ["ingressclasses" ], b .allowLabelsList ["ingressclasses" ]), & networkingv1.IngressClass {}, createIngressClassListWatch , b .useAPIServerCache )
507
+ return b .buildStoresFunc (ingressClassMetricFamilies (b .allowAnnotationsList ["ingressclasses" ], b .allowLabelsList ["ingressclasses" ]), & networkingv1.IngressClass {}, createIngressClassListWatch , b .useAPIServerCache , false )
502
508
}
503
509
504
510
func (b * Builder ) buildStores (
505
511
metricFamilies []generator.FamilyGenerator ,
506
512
expectedType interface {},
507
513
listWatchFunc func (kubeClient clientset.Interface , ns string , fieldSelector string ) cache.ListerWatcher ,
508
514
useAPIServerCache bool ,
515
+ metadataOnly bool ,
509
516
) []cache.Store {
510
517
metricFamilies = generator .FilterFamilyGenerators (b .familyGeneratorFilter , metricFamilies )
511
518
composedMetricGenFuncs := generator .ComposeMetricGenFuncs (metricFamilies )
@@ -519,7 +526,11 @@ func (b *Builder) buildStores(
519
526
if b .fieldSelectorFilter != "" {
520
527
klog .InfoS ("FieldSelector is used" , "fieldSelector" , b .fieldSelectorFilter )
521
528
}
522
- listWatcher := listWatchFunc (b .kubeClient , v1 .NamespaceAll , b .fieldSelectorFilter )
529
+ kubeClient := b .kubeClient
530
+ if metadataOnly {
531
+ kubeClient = b .metadataOnlyKubeClient
532
+ }
533
+ listWatcher := listWatchFunc (kubeClient , v1 .NamespaceAll , b .fieldSelectorFilter )
523
534
b .startReflector (expectedType , store , listWatcher , useAPIServerCache )
524
535
return []cache.Store {store }
525
536
}
0 commit comments