Skip to content

Commit 4b7b3a6

Browse files
committed
add prometheusK8sConfig API
Signed-off-by: Mario Fernandez <[email protected]>
1 parent bf4740f commit 4b7b3a6

12 files changed

+8131
-1
lines changed

config/v1alpha1/types_cluster_monitoring.go

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ type ClusterMonitoringSpec struct {
8989
// The current default value is `DefaultConfig`.
9090
// +optional
9191
AlertmanagerConfig AlertmanagerConfig `json:"alertmanagerConfig,omitempty,omitzero"`
92+
// prometheusK8sConfig provides configuration options for the Prometheus instance
93+
// Prometheus deployment, pod scheduling, resource allocation, retention policies, and external integrations.
94+
// prometheusK8sConfig is optional.
95+
// When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time.
96+
// +optional
97+
PrometheusK8sConfig PrometheusK8sConfig `json:"prometheusK8sConfig,omitempty,omitzero"`
9298
// metricsServerConfig is an optional field that can be used to configure the Kubernetes Metrics Server that runs in the openshift-monitoring namespace.
9399
// Specifically, it can configure how the Metrics Server instance is deployed, pod scheduling, its audit policy and log verbosity.
94100
// When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time.
@@ -424,6 +430,209 @@ type MetricsServerConfig struct {
424430
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
425431
}
426432

433+
// PrometheusK8sConfig provides configuration options for the Prometheus instance
434+
// Use this configuration to control
435+
// Prometheus deployment, pod scheduling, resource allocation, retention policies, and external integrations.
436+
// +kubebuilder:validation:MinProperties=1
437+
type PrometheusK8sConfig struct {
438+
// additionalAlertmanagerConfigs configures additional Alertmanager instances that receive alerts from
439+
// the Prometheus component. By default, no additional Alertmanager instances are configured.
440+
// +optional
441+
AdditionalAlertmanagerConfigs []AdditionalAlertmanagerConfig `json:"additionalAlertmanagerConfigs,omitempty"`
442+
// enforcedBodySizeLimit enforces a body size limit for Prometheus scraped metrics. If a scraped
443+
// target's body response is larger than the limit, the scrape will fail.
444+
// The following values are valid:
445+
// an empty value to specify no limit,
446+
// a numeric value in Prometheus size format (such as `64MB`), or
447+
// the string `automatic`, which indicates that the limit will be
448+
// automatically calculated based on cluster capacity.
449+
// The default value is empty, which indicates no limit.
450+
// +optional
451+
EnforcedBodySizeLimit string `json:"enforcedBodySizeLimit,omitempty"`
452+
// externalLabels defines labels to be added to any time series or alerts when
453+
// communicating with external systems such as federation, remote storage,
454+
// and Alertmanager. By default, no labels are added.
455+
// +optional
456+
ExternalLabels ExternalLabels `json:"externalLabels,omitempty"`
457+
// logLevel defines the log level setting for Prometheus.
458+
// The possible values are: `error`, `warn`, `info`, and `debug`.
459+
// The default value is `info`.
460+
// +optional
461+
LogLevel string `json:"logLevel,omitempty"`
462+
// nodeSelector defines the nodes on which the Pods are scheduled.
463+
// +optional
464+
// +kubebuilder:validation:MinProperties=1
465+
// +kubebuilder:validation:MaxProperties=10
466+
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
467+
// queryLogFile specifies the file to which PromQL queries are logged.
468+
// This setting can be either a filename, in which
469+
// case the queries are saved to an `emptyDir` volume
470+
// at `/var/log/prometheus`, or a full path to a location where
471+
// an `emptyDir` volume will be mounted and the queries saved.
472+
// Writing to `/dev/stderr`, `/dev/stdout` or `/dev/null` is supported, but
473+
// writing to any other `/dev/` path is not supported. Relative paths are
474+
// also not supported.
475+
// By default, PromQL queries are not logged.
476+
// +optional
477+
QueryLogFile string `json:"queryLogFile,omitempty"`
478+
// remoteWrite defines the remote write configuration, including URL, authentication,
479+
// and relabeling settings.
480+
// +optional
481+
RemoteWrite []RemoteWriteSpec `json:"remoteWrite,omitempty"`
482+
// resources defines resource requests and limits for the Prometheus container.
483+
// +optional
484+
Resources []ContainerResource `json:"resources,omitempty"`
485+
// retention defines the duration for which Prometheus retains data.
486+
// This definition must be specified using the following regular
487+
// expression pattern: `[0-9]+(ms|s|m|h|d|w|y)` (ms = milliseconds,
488+
// s= seconds,m = minutes, h = hours, d = days, w = weeks, y = years).
489+
// The default value is `15d`.
490+
// +optional
491+
Retention string `json:"retention,omitempty"`
492+
// retentionSize defines the maximum amount of disk space used by data blocks plus the
493+
// write-ahead log (WAL).
494+
// Supported values are `B`, `KB`, `KiB`, `MB`, `MiB`, `GB`, `GiB`, `TB`,
495+
// `TiB`, `PB`, `PiB`, `EB`, and `EiB`.
496+
// By default, no limit is defined.
497+
// +optional
498+
RetentionSize string `json:"retentionSize,omitempty"`
499+
// tolerations defines tolerations for the pods.
500+
// +optional
501+
// +kubebuilder:validation:MaxItems=10
502+
// +kubebuilder:validation:MinItems=1
503+
// +listType=atomic
504+
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
505+
// topologySpreadConstraints defines the pod's topology spread constraints.
506+
// +optional
507+
// +kubebuilder:validation:MaxItems=10
508+
// +kubebuilder:validation:MinItems=1
509+
// +listType=map
510+
// +listMapKey=topologyKey
511+
// +listMapKey=whenUnsatisfiable
512+
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
513+
// collectionProfile defines the metrics collection profile that Prometheus uses to collect
514+
// metrics from the platform components. Supported values are `full` or
515+
// `minimal`. In the `full` profile (default), Prometheus collects all
516+
// metrics that are exposed by the platform components. In the `minimal`
517+
// profile, Prometheus only collects metrics necessary for the default
518+
// platform alerts, recording rules, telemetry and console dashboards.
519+
// +optional
520+
CollectionProfile CollectionProfile `json:"collectionProfile,omitempty"`
521+
// volumeClaimTemplate defines persistent storage for Prometheus. Use this setting to
522+
// configure the persistent volume claim, including storage class,
523+
// volume size and name.
524+
// +optional
525+
VolumeClaimTemplate *v1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
526+
}
527+
528+
// AdditionalAlertmanagerConfig represents configuration for additional Alertmanager instances.
529+
// The `AdditionalAlertmanagerConfig` resource defines settings for how a
530+
// component communicates with additional Alertmanager instances.
531+
type AdditionalAlertmanagerConfig struct {
532+
// apiVersion defines the API version of Alertmanager.
533+
// `v1` is no longer supported, `v2` is set as the default value.
534+
// +required
535+
APIVersion string `json:"apiVersion"`
536+
// bearerToken defines the secret key reference containing the bearer token
537+
// to use when authenticating to Alertmanager.
538+
// +optional
539+
BearerToken *v1.SecretKeySelector `json:"bearerToken,omitempty"`
540+
// pathPrefix defines the path prefix to add in front of the push endpoint path.
541+
// +optional
542+
PathPrefix string `json:"pathPrefix,omitempty"`
543+
// scheme defines the URL scheme to use when communicating with Alertmanager
544+
// instances.
545+
// Possible values are `http` or `https`. The default value is `http`.
546+
// +optional
547+
Scheme string `json:"scheme,omitempty"`
548+
// staticConfigs is a list of statically configured Alertmanager endpoints in the form
549+
// of `<hosts>:<port>`.
550+
// +optional
551+
StaticConfigs []string `json:"staticConfigs,omitempty"`
552+
// timeout defines the timeout value used when sending alerts.
553+
// +optional
554+
Timeout *string `json:"timeout,omitempty"`
555+
// tlsConfig defines the TLS settings to use for Alertmanager connections.
556+
// +optional
557+
TLSConfig TLSConfig `json:"tlsConfig,omitempty"`
558+
}
559+
560+
// ExternalLabels represents labels to be added to time series and alerts.
561+
type ExternalLabels struct {
562+
// labels is a map of label names to label values.
563+
// +required
564+
Labels map[string]string `json:"labels"`
565+
}
566+
567+
// RemoteWriteSpec represents configuration for remote write endpoints.
568+
type RemoteWriteSpec struct {
569+
// url is the URL of the remote write endpoint.
570+
// +required
571+
URL string `json:"url"`
572+
// name is the name of the remote write configuration.
573+
// +optional
574+
Name string `json:"name,omitempty"`
575+
// remoteTimeout is the timeout for requests to the remote write endpoint.
576+
// +optional
577+
RemoteTimeout string `json:"remoteTimeout,omitempty"`
578+
// writeRelabelConfigs is a list of relabeling rules to apply before sending data to the remote endpoint.
579+
// +optional
580+
WriteRelabelConfigs []RelabelConfig `json:"writeRelabelConfigs,omitempty"`
581+
}
582+
583+
// RelabelConfig represents a relabeling rule.
584+
type RelabelConfig struct {
585+
// sourceLabels is a list of source label names.
586+
// +optional
587+
SourceLabels []string `json:"sourceLabels,omitempty"`
588+
// separator is the separator used to join source label values.
589+
// +optional
590+
Separator string `json:"separator,omitempty"`
591+
// regex is the regular expression to match against the concatenated source label values.
592+
// +optional
593+
Regex string `json:"regex,omitempty"`
594+
// targetLabel is the target label name.
595+
// +optional
596+
TargetLabel string `json:"targetLabel,omitempty"`
597+
// replacement is the replacement value for the target label.
598+
// +optional
599+
Replacement string `json:"replacement,omitempty"`
600+
// action is the action to perform.
601+
// +optional
602+
Action string `json:"action,omitempty"`
603+
}
604+
605+
// TLSConfig represents TLS configuration for Alertmanager connections.
606+
type TLSConfig struct {
607+
// ca is the CA certificate to use for TLS connections.
608+
// +optional
609+
CA *v1.SecretKeySelector `json:"ca,omitempty"`
610+
// cert is the client certificate to use for TLS connections.
611+
// +optional
612+
Cert *v1.SecretKeySelector `json:"cert,omitempty"`
613+
// key is the client key to use for TLS connections.
614+
// +optional
615+
Key *v1.SecretKeySelector `json:"key,omitempty"`
616+
// serverName is the server name to use for TLS connections.
617+
// +optional
618+
ServerName string `json:"serverName,omitempty"`
619+
// insecureSkipVerify determines whether to skip TLS certificate verification.
620+
// +optional
621+
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
622+
}
623+
624+
// CollectionProfile defines the metrics collection profile for Prometheus.
625+
// +kubebuilder:validation:Enum=full;minimal
626+
type CollectionProfile string
627+
628+
const (
629+
// CollectionProfileFull means Prometheus collects all metrics that are exposed by the platform components.
630+
CollectionProfileFull CollectionProfile = "full"
631+
// CollectionProfileMinimal means Prometheus only collects metrics necessary for the default
632+
// platform alerts, recording rules, telemetry and console dashboards.
633+
CollectionProfileMinimal CollectionProfile = "minimal"
634+
)
635+
427636
// AuditProfile defines the audit log level for the Metrics Server.
428637
// +kubebuilder:validation:Enum=None;Metadata;Request;RequestResponse
429638
type AuditProfile string

0 commit comments

Comments
 (0)