1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-15 08:46:44 +00:00

feat: add PrometheusTopologySharding feature gate (#7233)

Signed-off-by: dongjiang <dongjiang1989@126.com>
This commit is contained in:
dongjiang 2024-12-25 00:13:09 +08:00 committed by GitHub
parent 64b32541cd
commit 4e3e6b1477
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 8 deletions

View file

@ -57,6 +57,7 @@ Usage of ./operator:
Feature gates are a set of key=value pairs that describe Prometheus-Operator features.
Available feature gates:
PrometheusAgentDaemonSet: Enables the DaemonSet mode for PrometheusAgent (enabled: false)
PrometheusTopologySharding: Enables the zone aware sharding for Prometheus (enabled: false)
-key-file string
- NOT RECOMMENDED FOR PRODUCTION - Path to private TLS certificate file.
-kubelet-endpoints

View file

@ -95,6 +95,10 @@ func DefaultConfig(cpu, memory string) Config {
description: "Enables the DaemonSet mode for PrometheusAgent",
enabled: false,
},
PrometheusTopologyShardingFeature: FeatureGate{
description: "Enables the zone aware sharding for Prometheus",
enabled: false,
},
},
}
}

View file

@ -25,6 +25,9 @@ import (
const (
// PrometheusAgentDaemonSetFeature enables the DaemonSet mode for PrometheusAgent.
PrometheusAgentDaemonSetFeature FeatureGateName = "PrometheusAgentDaemonSet"
// PrometheusTopologySharding enables the zone aware sharding for Prometheus.
PrometheusTopologyShardingFeature FeatureGateName = "PrometheusTopologySharding"
)
type FeatureGateName string

View file

@ -65,14 +65,15 @@ func sanitizeLabelName(name string) string {
// ConfigGenerator knows how to generate a Prometheus configuration which is
// compatible with a given Prometheus version.
type ConfigGenerator struct {
logger *slog.Logger
version semver.Version
notCompatible bool
prom monitoringv1.PrometheusInterface
useEndpointSlice bool // Whether to use EndpointSlice for service discovery from `ServiceMonitor` objects.
scrapeClasses map[string]monitoringv1.ScrapeClass
defaultScrapeClassName string
daemonSet bool
logger *slog.Logger
version semver.Version
notCompatible bool
prom monitoringv1.PrometheusInterface
useEndpointSlice bool // Whether to use EndpointSlice for service discovery from `ServiceMonitor` objects.
scrapeClasses map[string]monitoringv1.ScrapeClass
defaultScrapeClassName string
daemonSet bool
prometheusTopologySharding bool
}
type ConfigGeneratorOption func(*ConfigGenerator)
@ -90,6 +91,12 @@ func WithDaemonSet() ConfigGeneratorOption {
}
}
func WithPrometheusTopologySharding() ConfigGeneratorOption {
return func(cg *ConfigGenerator) {
cg.prometheusTopologySharding = true
}
}
// NewConfigGenerator creates a ConfigGenerator for the provided Prometheus resource.
func NewConfigGenerator(
logger *slog.Logger,