@@ -43,6 +43,30 @@ type Prometheus struct {
4343 // ServiceMonitor defines ServiceMonitor configuration for KAI services
4444 // +kubebuilder:validation:Optional
4545 ServiceMonitor * ServiceMonitor `json:"serviceMonitor,omitempty"`
46+
47+ // ExternalPrometheusUrl defines the URL of an external Prometheus instance to use
48+ // When set, KAI will not deploy its own Prometheus but will configure ServiceMonitors
49+ // for the external instance and validate connectivity
50+ // +kubebuilder:validation:Optional
51+ ExternalPrometheusUrl * string `json:"externalPrometheusUrl,omitempty"`
52+
53+ // ExternalPrometheusPingConfig defines the configuration for external Prometheus connectivity validation, with defaults.
54+ // +kubebuilder:validation:Optional
55+ ExternalPrometheusHealthProbe * ExternalPrometheusHealthProbe `json:"externalPrometheusHealthProbe,omitempty"`
56+ }
57+
58+ type ExternalPrometheusHealthProbe struct {
59+ // Interval defines the interval for external Prometheus connectivity validation (in seconds)
60+ // +kubebuilder:validation:Optional
61+ Interval * int `json:"interval,omitempty"`
62+
63+ // PingsTimeout defines the timeout for external Prometheus connectivity validation (in seconds)
64+ // +kubebuilder:validation:Optional
65+ Timeout * int `json:"timeout,omitempty"`
66+
67+ // PingsMaxRetries defines the maximum number of retries for external Prometheus connectivity validation
68+ // +kubebuilder:validation:Optional
69+ MaxRetries * int `json:"maxRetries,omitempty"`
4670}
4771
4872func (p * Prometheus ) SetDefaultsWhereNeeded () {
@@ -53,7 +77,9 @@ func (p *Prometheus) SetDefaultsWhereNeeded() {
5377 p .RetentionPeriod = common .SetDefault (p .RetentionPeriod , ptr .To ("2w" ))
5478 p .SampleInterval = common .SetDefault (p .SampleInterval , ptr .To ("1m" ))
5579 p .StorageClassName = common .SetDefault (p .StorageClassName , ptr .To ("standard" ))
56-
80+ p .ExternalPrometheusUrl = common .SetDefault (p .ExternalPrometheusUrl , nil )
81+ p .ExternalPrometheusHealthProbe = common .SetDefault (p .ExternalPrometheusHealthProbe , & ExternalPrometheusHealthProbe {})
82+ p .ExternalPrometheusHealthProbe .SetDefaultsWhereNeeded ()
5783 p .ServiceMonitor = common .SetDefault (p .ServiceMonitor , & ServiceMonitor {})
5884 p .ServiceMonitor .SetDefaultsWhereNeeded ()
5985}
@@ -253,3 +279,12 @@ func (s *ServiceMonitor) SetDefaultsWhereNeeded() {
253279 s .ScrapeTimeout = common .SetDefault (s .ScrapeTimeout , ptr .To ("10s" ))
254280 s .BearerTokenFile = common .SetDefault (s .BearerTokenFile , ptr .To ("/var/run/secrets/kubernetes.io/serviceaccount/token" ))
255281}
282+
283+ func (p * ExternalPrometheusHealthProbe ) SetDefaultsWhereNeeded () {
284+ if p == nil {
285+ return
286+ }
287+ p .Interval = common .SetDefault (p .Interval , ptr .To (30 ))
288+ p .Timeout = common .SetDefault (p .Timeout , ptr .To (10 ))
289+ p .MaxRetries = common .SetDefault (p .MaxRetries , ptr .To (5 ))
290+ }
0 commit comments