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:
parent
64b32541cd
commit
4e3e6b1477
4 changed files with 23 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue