Parcourir la source

intermediary ksm 2 migration step

Ajay Tripathy il y a 4 ans
Parent
commit
571838ed5f
3 fichiers modifiés avec 21 ajouts et 15 suppressions
  1. 1 1
      pkg/costmodel/metrics.go
  2. 3 3
      pkg/env/costmodelenv.go
  3. 17 11
      pkg/metrics/kubemetrics.go

+ 1 - 1
pkg/costmodel/metrics.go

@@ -268,7 +268,7 @@ func NewCostModelMetricsEmitter(promClient promclient.Client, clusterCache clust
 		EmitNamespaceAnnotations:      env.IsEmitNamespaceAnnotationsMetric(),
 		EmitPodAnnotations:            env.IsEmitPodAnnotationsMetric(),
 		EmitKubeStateMetrics:          env.IsEmitKsmV1Metrics(),
-		EmitNodeKubeStateMetrisOnly:   env.IsEmitNodeKubeStateMetrisOnly(),
+		EmitNodeKubeStateMetrisOnly:   env.IsEmitKsmV1MetricsOnly(),
 	})
 
 	return &CostModelMetricsEmitter{

+ 3 - 3
pkg/env/costmodelenv.go

@@ -39,7 +39,7 @@ const (
 	EmitNamespaceAnnotationsMetricEnvVar = "EMIT_NAMESPACE_ANNOTATIONS_METRIC"
 
 	EmitKsmV1MetricsEnvVar = "EMIT_KSM_V1_METRICS"
-	EmitKsmNodeMetricsOnly = "EMIT_KSM_NODE_METRICS_ONLY"
+	EmitKsmV1MetricsOnly   = "EMIT_KSM_V1_METRICS_ONLY"
 
 	ThanosEnabledEnvVar      = "THANOS_ENABLED"
 	ThanosQueryUrlEnvVar     = "THANOS_QUERY_URL"
@@ -105,8 +105,8 @@ func IsEmitKsmV1Metrics() bool {
 	return GetBool(EmitKsmV1MetricsEnvVar, true)
 }
 
-func IsEmitNodeKubeStateMetrisOnly() bool {
-	return GetBool(EmitKsmNodeMetricsOnly, true)
+func IsEmitKsmV1MetricsOnly() bool {
+	return GetBool(EmitKsmV1MetricsOnly, true)
 }
 
 // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents

+ 17 - 11
pkg/metrics/kubemetrics.go

@@ -24,21 +24,21 @@ var kubeMetricInit sync.Once
 
 // KubeMetricsOpts represents our Kubernetes metrics emission options.
 type KubeMetricsOpts struct {
-	EmitKubecostControllerMetrics bool
-	EmitNamespaceAnnotations      bool
-	EmitPodAnnotations            bool
-	EmitKubeStateMetrics          bool
-	EmitNodeKubeStateMetrisOnly   bool
+	EmitKubecostControllerMetrics  bool
+	EmitNamespaceAnnotations       bool
+	EmitPodAnnotations             bool
+	EmitKubeStateMetrics           bool
+	EmitV1NodeKubeStateMetricsOnly bool
 }
 
 // DefaultKubeMetricsOpts returns KubeMetricsOpts with default values set
 func DefaultKubeMetricsOpts() *KubeMetricsOpts {
 	return &KubeMetricsOpts{
-		EmitKubecostControllerMetrics: true,
-		EmitNamespaceAnnotations:      false,
-		EmitPodAnnotations:            false,
-		EmitKubeStateMetrics:          true,
-		EmitNodeKubeStateMetrisOnly:   false,
+		EmitKubecostControllerMetrics:  true,
+		EmitNamespaceAnnotations:       false,
+		EmitPodAnnotations:             false,
+		EmitKubeStateMetrics:           true,
+		EmitV1NodeKubeStateMetricsOnly: false,
 	}
 }
 
@@ -95,10 +95,16 @@ func InitKubeMetrics(clusterCache clustercache.ClusterCache, opts *KubeMetricsOp
 			prometheus.MustRegister(KubeJobCollector{
 				KubeClusterCache: clusterCache,
 			})
-		} else if opts.EmitNodeKubeStateMetrisOnly {
+		} else if opts.EmitV1NodeKubeStateMetricsOnly {
 			prometheus.MustRegister(KubeNodeCollector{
 				KubeClusterCache: clusterCache,
 			})
+			prometheus.MustRegister(KubeNamespaceCollector{
+				KubeClusterCache: clusterCache,
+			})
+			prometheus.MustRegister(KubePodLabelsCollector{
+				KubeClusterCache: clusterCache,
+			})
 		}
 	})
 }