Documentation
¶
Index ¶
- func NewStartCommand() *cobra.Command
- type ComponentConfig
- type ComponentFileConfig
- type ComponentProvider
- type ConfigFileReader
- type EndpointResolverClient
- type EndpointResolverFileConfig
- type FileConfig
- type Filter
- type Labeler
- type ProxyHandler
- type ScrapeResult
- type ScrapeTarget
- type Scraper
- type TargetDiscoverer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStartCommand ¶
Types ¶
type ComponentConfig ¶
type ComponentConfig struct {
Selector map[string]string
MetricsPort int32
MetricsPath string
MetricsScheme string
TLSServerName string
TLSConfig *tls.Config
// Label overrides from SM/PM annotations for standalone OCP compatibility.
MetricsJob string
MetricsNamespace string
MetricsService string
MetricsEndpoint string
}
ComponentConfig describes how to scrape a single control plane component, including the per-component TLS configuration derived from its ServiceMonitor.
type ComponentFileConfig ¶
type ComponentFileConfig struct {
// Name is the unique identifier for this component (e.g. the ServiceMonitor
// or PodMonitor name). Components are sorted by this field for deterministic
// serialization.
Name string `json:"name"`
// Selector is the pod label selector used by the endpoint-resolver to find
// matching pods. For ServiceMonitor components this comes from the Service's
// Spec.Selector; for PodMonitor components from the PodMonitor's
// Spec.Selector.MatchLabels.
Selector map[string]string `json:"selector,omitempty"`
MetricsPort int32 `json:"metricsPort"`
MetricsPath string `json:"metricsPath"`
MetricsScheme string `json:"metricsScheme"`
TLSServerName string `json:"tlsServerName"`
CAFile string `json:"caFile,omitempty"`
CertFile string `json:"certFile,omitempty"`
KeyFile string `json:"keyFile,omitempty"`
// Label overrides from SM/PM annotations for standalone OCP compatibility.
MetricsJob string `json:"metricsJob,omitempty"`
MetricsNamespace string `json:"metricsNamespace,omitempty"`
MetricsService string `json:"metricsService,omitempty"`
MetricsEndpoint string `json:"metricsEndpoint,omitempty"`
}
ComponentFileConfig holds the per-component scrape configuration.
type ComponentProvider ¶
type ComponentProvider interface {
GetComponent(name string) (ComponentConfig, bool)
GetComponentNames() []string
}
ComponentProvider provides component configurations for metrics scraping.
type ConfigFileReader ¶
type ConfigFileReader struct {
// contains filtered or unexported fields
}
ConfigFileReader reads component configuration from a YAML file on disk and builds ComponentConfig entries with TLS configurations from mounted certificate files. The CPOv2 framework rolls out the deployment when any mounted ConfigMap or Secret changes, so the config is loaded once at startup.
func NewConfigFileReader ¶
func NewConfigFileReader(path string, log logr.Logger) *ConfigFileReader
func (*ConfigFileReader) EndpointResolverCAFile ¶
func (r *ConfigFileReader) EndpointResolverCAFile() string
EndpointResolverCAFile returns the endpoint-resolver CA file path from the config.
func (*ConfigFileReader) EndpointResolverURL ¶
func (r *ConfigFileReader) EndpointResolverURL() string
EndpointResolverURL returns the endpoint-resolver URL from the config.
func (*ConfigFileReader) GetComponent ¶
func (r *ConfigFileReader) GetComponent(name string) (ComponentConfig, bool)
GetComponent returns the config for a named component.
func (*ConfigFileReader) GetComponentNames ¶
func (r *ConfigFileReader) GetComponentNames() []string
GetComponentNames returns all loaded component names.
func (*ConfigFileReader) Load ¶
func (r *ConfigFileReader) Load() error
Load reads the config file and builds ComponentConfig entries.
type EndpointResolverClient ¶
type EndpointResolverClient struct {
// contains filtered or unexported fields
}
EndpointResolverClient discovers scrape targets by querying the endpoint-resolver service instead of directly accessing the Kubernetes API.
func NewEndpointResolverClient ¶
func NewEndpointResolverClient(baseURL, caFile string) (*EndpointResolverClient, error)
NewEndpointResolverClient creates a new client for the endpoint-resolver service. If the CA file cannot be read (e.g. volume not yet mounted), the client is created without CA verification. Requests will fail with TLS errors until the CA is available, but the process won't crash — the config reader will reload periodically.
func (*EndpointResolverClient) Discover ¶
func (c *EndpointResolverClient) Discover(ctx context.Context, selector map[string]string, port int32) ([]ScrapeTarget, error)
Discover queries the endpoint-resolver for pod endpoints matching the given label selector. The endpoint-resolver expects a POST to /resolve with a JSON body containing the selector map.
type EndpointResolverFileConfig ¶
EndpointResolverFileConfig holds the endpoint-resolver connection details.
type FileConfig ¶
type FileConfig struct {
EndpointResolver EndpointResolverFileConfig `json:"endpointResolver"`
Components []ComponentFileConfig `json:"components"`
}
FileConfig is the YAML structure shared between the CPO (writer) and the metrics-proxy binary (reader) for the scrape-config ConfigMap.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
func NewFilter ¶
func NewFilter(metricsSet metrics.MetricsSet) *Filter
func (*Filter) Apply ¶
func (f *Filter) Apply(componentName string, families map[string]*dto.MetricFamily) map[string]*dto.MetricFamily
type Labeler ¶
type Labeler struct {
// contains filtered or unexported fields
}
func NewLabeler ¶
func (*Labeler) Inject ¶
func (l *Labeler) Inject(families map[string]*dto.MetricFamily, target ScrapeTarget, componentName string, cfg ComponentConfig) map[string]*dto.MetricFamily
type ProxyHandler ¶
type ProxyHandler struct {
// contains filtered or unexported fields
}
func NewProxyHandler ¶
func NewProxyHandler(log logr.Logger, componentProvider ComponentProvider, targetDiscoverer TargetDiscoverer, scraper *Scraper, filter *Filter, labeler *Labeler) *ProxyHandler
func (*ProxyHandler) ServeHTTP ¶
func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ScrapeResult ¶
type ScrapeResult struct {
Families map[string]*dto.MetricFamily
Err error
}
type ScrapeTarget ¶
ScrapeTarget represents a single pod endpoint to scrape.
type Scraper ¶
type Scraper struct{}
func NewScraper ¶
func NewScraper() *Scraper
func (*Scraper) ScrapeAll ¶
func (s *Scraper) ScrapeAll(ctx context.Context, targets []ScrapeTarget, metricsPath, scheme, tlsServerName string, tlsConfig *tls.Config) []ScrapeResult
ScrapeAll scrapes all targets in parallel using the per-component TLS config. The tlsConfig is discovered from the component's ServiceMonitor and contains the correct CA, client cert, and client key for that specific component.
type TargetDiscoverer ¶
type TargetDiscoverer interface {
Discover(ctx context.Context, selector map[string]string, port int32) ([]ScrapeTarget, error)
}
TargetDiscoverer discovers scrape targets (pod endpoints) for a given service.