Remove BPA from Makefile
[icn.git] / cmd / bpa-operator / vendor / github.com / coreos / prometheus-operator / pkg / apis / monitoring / v1 / types.go
1 // Copyright 2018 The prometheus-operator Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package v1
16
17 import (
18         "k8s.io/api/core/v1"
19         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20         "k8s.io/apimachinery/pkg/runtime"
21         "k8s.io/apimachinery/pkg/util/intstr"
22 )
23
24 const (
25         Version = "v1"
26
27         PrometheusesKind  = "Prometheus"
28         PrometheusName    = "prometheuses"
29         PrometheusKindKey = "prometheus"
30
31         AlertmanagersKind   = "Alertmanager"
32         AlertmanagerName    = "alertmanagers"
33         AlertManagerKindKey = "alertmanager"
34
35         ServiceMonitorsKind   = "ServiceMonitor"
36         ServiceMonitorName    = "servicemonitors"
37         ServiceMonitorKindKey = "servicemonitor"
38
39         PrometheusRuleKind    = "PrometheusRule"
40         PrometheusRuleName    = "prometheusrules"
41         PrometheusRuleKindKey = "prometheusrule"
42 )
43
44 // Prometheus defines a Prometheus deployment.
45 // +genclient
46 // +k8s:openapi-gen=true
47 type Prometheus struct {
48         metav1.TypeMeta `json:",inline"`
49         // Standard object’s metadata. More info:
50         // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
51         // +k8s:openapi-gen=false
52         metav1.ObjectMeta `json:"metadata,omitempty"`
53         // Specification of the desired behavior of the Prometheus cluster. More info:
54         // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
55         Spec PrometheusSpec `json:"spec"`
56         // Most recent observed status of the Prometheus cluster. Read-only. Not
57         // included when requesting from the apiserver, only from the Prometheus
58         // Operator API itself. More info:
59         // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
60         Status *PrometheusStatus `json:"status,omitempty"`
61 }
62
63 // PrometheusList is a list of Prometheuses.
64 // +k8s:openapi-gen=true
65 type PrometheusList struct {
66         metav1.TypeMeta `json:",inline"`
67         // Standard list metadata
68         // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
69         metav1.ListMeta `json:"metadata,omitempty"`
70         // List of Prometheuses
71         Items []*Prometheus `json:"items"`
72 }
73
74 // PrometheusSpec is a specification of the desired behavior of the Prometheus cluster. More info:
75 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
76 // +k8s:openapi-gen=true
77 type PrometheusSpec struct {
78         // Standard object’s metadata. More info:
79         // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
80         // Metadata Labels and Annotations gets propagated to the prometheus pods.
81         PodMetadata *metav1.ObjectMeta `json:"podMetadata,omitempty"`
82         // ServiceMonitors to be selected for target discovery.
83         ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"`
84         // Namespaces to be selected for ServiceMonitor discovery. If nil, only
85         // check own namespace.
86         ServiceMonitorNamespaceSelector *metav1.LabelSelector `json:"serviceMonitorNamespaceSelector,omitempty"`
87         // Version of Prometheus to be deployed.
88         Version string `json:"version,omitempty"`
89         // Tag of Prometheus container image to be deployed. Defaults to the value of `version`.
90         // Version is ignored if Tag is set.
91         Tag string `json:"tag,omitempty"`
92         // SHA of Prometheus container image to be deployed. Defaults to the value of `version`.
93         // Similar to a tag, but the SHA explicitly deploys an immutable container image.
94         // Version and Tag are ignored if SHA is set.
95         SHA string `json:"sha,omitempty"`
96         // When a Prometheus deployment is paused, no actions except for deletion
97         // will be performed on the underlying objects.
98         Paused bool `json:"paused,omitempty"`
99         // Image if specified has precedence over baseImage, tag and sha
100         // combinations. Specifying the version is still necessary to ensure the
101         // Prometheus Operator knows what version of Prometheus is being
102         // configured.
103         Image *string `json:"image,omitempty"`
104         // Base image to use for a Prometheus deployment.
105         BaseImage string `json:"baseImage,omitempty"`
106         // An optional list of references to secrets in the same namespace
107         // to use for pulling prometheus and alertmanager images from registries
108         // see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
109         ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
110         // Number of instances to deploy for a Prometheus deployment.
111         Replicas *int32 `json:"replicas,omitempty"`
112         // Name of Prometheus external label used to denote replica name.
113         // Defaults to the value of `prometheus_replica`.
114         ReplicaExternalLabelName string `json:"replicaExternalLabelName,omitempty"`
115         // Time duration Prometheus shall retain data for. Default is '24h',
116         // and must match the regular expression `[0-9]+(ms|s|m|h|d|w|y)` (milliseconds seconds minutes hours days weeks years).
117         Retention string `json:"retention,omitempty"`
118         // Log level for Prometheus to be configured with.
119         LogLevel string `json:"logLevel,omitempty"`
120         // Log format for Prometheus to be configured with.
121         LogFormat string `json:"logFormat,omitempty"`
122         // Interval between consecutive scrapes.
123         ScrapeInterval string `json:"scrapeInterval,omitempty"`
124         // Interval between consecutive evaluations.
125         EvaluationInterval string `json:"evaluationInterval,omitempty"`
126         // /--rules.*/ command-line arguments.
127         Rules Rules `json:"rules,omitempty"`
128         // The labels to add to any time series or alerts when communicating with
129         // external systems (federation, remote storage, Alertmanager).
130         ExternalLabels map[string]string `json:"externalLabels,omitempty"`
131         // Enable access to prometheus web admin API. Defaults to the value of `false`.
132         // WARNING: Enabling the admin APIs enables mutating endpoints, to delete data,
133         // shutdown Prometheus, and more. Enabling this should be done with care and the
134         // user is advised to add additional authentication authorization via a proxy to
135         // ensure only clients authorized to perform these actions can do so.
136         // For more information see https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-admin-apis
137         EnableAdminAPI bool `json:"enableAdminAPI,omitempty"`
138         // The external URL the Prometheus instances will be available under. This is
139         // necessary to generate correct URLs. This is necessary if Prometheus is not
140         // served from root of a DNS name.
141         ExternalURL string `json:"externalUrl,omitempty"`
142         // The route prefix Prometheus registers HTTP handlers for. This is useful,
143         // if using ExternalURL and a proxy is rewriting HTTP routes of a request,
144         // and the actual ExternalURL is still true, but the server serves requests
145         // under a different route prefix. For example for use with `kubectl proxy`.
146         RoutePrefix string `json:"routePrefix,omitempty"`
147         // QuerySpec defines the query command line flags when starting Prometheus.
148         Query *QuerySpec `json:"query,omitempty"`
149         // Storage spec to specify how storage shall be used.
150         Storage *StorageSpec `json:"storage,omitempty"`
151         // A selector to select which PrometheusRules to mount for loading alerting
152         // rules from. Until (excluding) Prometheus Operator v0.24.0 Prometheus
153         // Operator will migrate any legacy rule ConfigMaps to PrometheusRule custom
154         // resources selected by RuleSelector. Make sure it does not match any config
155         // maps that you do not want to be migrated.
156         RuleSelector *metav1.LabelSelector `json:"ruleSelector,omitempty"`
157         // Namespaces to be selected for PrometheusRules discovery. If unspecified, only
158         // the same namespace as the Prometheus object is in is used.
159         RuleNamespaceSelector *metav1.LabelSelector `json:"ruleNamespaceSelector,omitempty"`
160         // Define details regarding alerting.
161         Alerting *AlertingSpec `json:"alerting,omitempty"`
162         // Define resources requests and limits for single Pods.
163         Resources v1.ResourceRequirements `json:"resources,omitempty"`
164         // Define which Nodes the Pods are scheduled on.
165         NodeSelector map[string]string `json:"nodeSelector,omitempty"`
166         // ServiceAccountName is the name of the ServiceAccount to use to run the
167         // Prometheus Pods.
168         ServiceAccountName string `json:"serviceAccountName,omitempty"`
169         // Secrets is a list of Secrets in the same namespace as the Prometheus
170         // object, which shall be mounted into the Prometheus Pods.
171         // The Secrets are mounted into /etc/prometheus/secrets/<secret-name>.
172         Secrets []string `json:"secrets,omitempty"`
173         // ConfigMaps is a list of ConfigMaps in the same namespace as the Prometheus
174         // object, which shall be mounted into the Prometheus Pods.
175         // The ConfigMaps are mounted into /etc/prometheus/configmaps/<configmap-name>.
176         ConfigMaps []string `json:"configMaps,omitempty"`
177         // If specified, the pod's scheduling constraints.
178         Affinity *v1.Affinity `json:"affinity,omitempty"`
179         // If specified, the pod's tolerations.
180         Tolerations []v1.Toleration `json:"tolerations,omitempty"`
181         // If specified, the remote_write spec. This is an experimental feature, it may change in any upcoming release in a breaking way.
182         RemoteWrite []RemoteWriteSpec `json:"remoteWrite,omitempty"`
183         // If specified, the remote_read spec. This is an experimental feature, it may change in any upcoming release in a breaking way.
184         RemoteRead []RemoteReadSpec `json:"remoteRead,omitempty"`
185         // SecurityContext holds pod-level security attributes and common container settings.
186         // This defaults to non root user with uid 1000 and gid 2000 for Prometheus >v2.0 and
187         // default PodSecurityContext for other versions.
188         SecurityContext *v1.PodSecurityContext `json:"securityContext,omitempty"`
189         // ListenLocal makes the Prometheus server listen on loopback, so that it
190         // does not bind against the Pod IP.
191         ListenLocal bool `json:"listenLocal,omitempty"`
192         // Containers allows injecting additional containers. This is meant to
193         // allow adding an authentication proxy to a Prometheus pod.
194         Containers []v1.Container `json:"containers,omitempty"`
195         // AdditionalScrapeConfigs allows specifying a key of a Secret containing
196         // additional Prometheus scrape configurations. Scrape configurations
197         // specified are appended to the configurations generated by the Prometheus
198         // Operator. Job configurations specified must have the form as specified
199         // in the official Prometheus documentation:
200         // https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config.
201         // As scrape configs are appended, the user is responsible to make sure it
202         // is valid. Note that using this feature may expose the possibility to
203         // break upgrades of Prometheus. It is advised to review Prometheus release
204         // notes to ensure that no incompatible scrape configs are going to break
205         // Prometheus after the upgrade.
206         AdditionalScrapeConfigs *v1.SecretKeySelector `json:"additionalScrapeConfigs,omitempty"`
207         // AdditionalAlertRelabelConfigs allows specifying a key of a Secret containing
208         // additional Prometheus alert relabel configurations. Alert relabel configurations
209         // specified are appended to the configurations generated by the Prometheus
210         // Operator. Alert relabel configurations specified must have the form as specified
211         // in the official Prometheus documentation:
212         // https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alert_relabel_configs.
213         // As alert relabel configs are appended, the user is responsible to make sure it
214         // is valid. Note that using this feature may expose the possibility to
215         // break upgrades of Prometheus. It is advised to review Prometheus release
216         // notes to ensure that no incompatible alert relabel configs are going to break
217         // Prometheus after the upgrade.
218         AdditionalAlertRelabelConfigs *v1.SecretKeySelector `json:"additionalAlertRelabelConfigs,omitempty"`
219         // AdditionalAlertManagerConfigs allows specifying a key of a Secret containing
220         // additional Prometheus AlertManager configurations. AlertManager configurations
221         // specified are appended to the configurations generated by the Prometheus
222         // Operator. Job configurations specified must have the form as specified
223         // in the official Prometheus documentation:
224         // https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alertmanager_config.
225         // As AlertManager configs are appended, the user is responsible to make sure it
226         // is valid. Note that using this feature may expose the possibility to
227         // break upgrades of Prometheus. It is advised to review Prometheus release
228         // notes to ensure that no incompatible AlertManager configs are going to break
229         // Prometheus after the upgrade.
230         AdditionalAlertManagerConfigs *v1.SecretKeySelector `json:"additionalAlertManagerConfigs,omitempty"`
231         // APIServerConfig allows specifying a host and auth methods to access apiserver.
232         // If left empty, Prometheus is assumed to run inside of the cluster
233         // and will discover API servers automatically and use the pod's CA certificate
234         // and bearer token file at /var/run/secrets/kubernetes.io/serviceaccount/.
235         APIServerConfig *APIServerConfig `json:"apiserverConfig,omitempty"`
236         // Thanos configuration allows configuring various aspects of a Prometheus
237         // server in a Thanos environment.
238         //
239         // This section is experimental, it may change significantly without
240         // deprecation notice in any release.
241         //
242         // This is experimental and may change significantly without backward
243         // compatibility in any release.
244         Thanos *ThanosSpec `json:"thanos,omitempty"`
245         // Priority class assigned to the Pods
246         PriorityClassName string `json:"priorityClassName,omitempty"`
247 }
248
249 // PrometheusStatus is the most recent observed status of the Prometheus cluster. Read-only. Not
250 // included when requesting from the apiserver, only from the Prometheus
251 // Operator API itself. More info:
252 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
253 // +k8s:openapi-gen=true
254 type PrometheusStatus struct {
255         // Represents whether any actions on the underlaying managed objects are
256         // being performed. Only delete actions will be performed.
257         Paused bool `json:"paused"`
258         // Total number of non-terminated pods targeted by this Prometheus deployment
259         // (their labels match the selector).
260         Replicas int32 `json:"replicas"`
261         // Total number of non-terminated pods targeted by this Prometheus deployment
262         // that have the desired version spec.
263         UpdatedReplicas int32 `json:"updatedReplicas"`
264         // Total number of available pods (ready for at least minReadySeconds)
265         // targeted by this Prometheus deployment.
266         AvailableReplicas int32 `json:"availableReplicas"`
267         // Total number of unavailable pods targeted by this Prometheus deployment.
268         UnavailableReplicas int32 `json:"unavailableReplicas"`
269 }
270
271 // AlertingSpec defines parameters for alerting configuration of Prometheus servers.
272 // +k8s:openapi-gen=true
273 type AlertingSpec struct {
274         // AlertmanagerEndpoints Prometheus should fire alerts against.
275         Alertmanagers []AlertmanagerEndpoints `json:"alertmanagers"`
276 }
277
278 // StorageSpec defines the configured storage for a group Prometheus servers.
279 // If neither `emptyDir` nor `volumeClaimTemplate` is specified, then by default an [EmptyDir](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) will be used.
280 // +k8s:openapi-gen=true
281 type StorageSpec struct {
282         // EmptyDirVolumeSource to be used by the Prometheus StatefulSets. If specified, used in place of any volumeClaimTemplate. More
283         // info: https://kubernetes.io/docs/concepts/storage/volumes/#emptydir
284         EmptyDir *v1.EmptyDirVolumeSource `json:"emptyDir,omitempty"`
285         // A PVC spec to be used by the Prometheus StatefulSets.
286         VolumeClaimTemplate v1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
287 }
288
289 // QuerySpec defines the query command line flags when starting Prometheus.
290 // +k8s:openapi-gen=true
291 type QuerySpec struct {
292         // The delta difference allowed for retrieving metrics during expression evaluations.
293         LookbackDelta *string `json:"lookbackDelta,omitempty"`
294         // Number of concurrent queries that can be run at once.
295         MaxConcurrency *int32 `json:"maxConcurrency,omitempty"`
296         // Maximum time a query may take before being aborted.
297         Timeout *string `json:"timeout,omitempty"`
298 }
299
300 // ThanosSpec defines parameters for a Prometheus server within a Thanos deployment.
301 // +k8s:openapi-gen=true
302 type ThanosSpec struct {
303         // Peers is a DNS name for Thanos to discover peers through.
304         Peers *string `json:"peers,omitempty"`
305         // Image if specified has precedence over baseImage, tag and sha
306         // combinations. Specifying the version is still necessary to ensure the
307         // Prometheus Operator knows what version of Thanos is being
308         // configured.
309         Image *string `json:"image,omitempty"`
310         // Version describes the version of Thanos to use.
311         Version *string `json:"version,omitempty"`
312         // Tag of Thanos sidecar container image to be deployed. Defaults to the value of `version`.
313         // Version is ignored if Tag is set.
314         Tag *string `json:"tag,omitempty"`
315         // SHA of Thanos container image to be deployed. Defaults to the value of `version`.
316         // Similar to a tag, but the SHA explicitly deploys an immutable container image.
317         // Version and Tag are ignored if SHA is set.
318         SHA *string `json:"sha,omitempty"`
319         // Thanos base image if other than default.
320         BaseImage *string `json:"baseImage,omitempty"`
321         // Resources defines the resource requirements for the Thanos sidecar.
322         // If not provided, no requests/limits will be set
323         Resources v1.ResourceRequirements `json:"resources,omitempty"`
324         // Deprecated: GCS should be configured with an ObjectStorageConfig secret
325         // starting with Thanos v0.2.0. This field will be removed.
326         GCS *ThanosGCSSpec `json:"gcs,omitempty"`
327         // Deprecated: S3 should be configured with an ObjectStorageConfig secret
328         // starting with Thanos v0.2.0. This field will be removed.
329         S3 *ThanosS3Spec `json:"s3,omitempty"`
330         // ObjectStorageConfig configures object storage in Thanos.
331         ObjectStorageConfig *v1.SecretKeySelector `json:"objectStorageConfig,omitempty"`
332         // Explicit (external) host:port address to advertise for gRPC StoreAPI in gossip cluster.
333         // If empty, 'grpc-address' will be used.
334         GrpcAdvertiseAddress *string `json:"grpcAdvertiseAddress,omitempty"`
335         // Explicit (external) ip:port address to advertise for gossip in gossip cluster.
336         // Used internally for membership only.
337         ClusterAdvertiseAddress *string `json:"clusterAdvertiseAddress,omitempty"`
338 }
339
340 // Deprecated: ThanosGCSSpec should be configured with an ObjectStorageConfig
341 // secret starting with Thanos v0.2.0. ThanosGCSSpec will be removed.
342 //
343 // +k8s:openapi-gen=true
344 type ThanosGCSSpec struct {
345         // Google Cloud Storage bucket name for stored blocks. If empty it won't
346         // store any block inside Google Cloud Storage.
347         Bucket *string `json:"bucket,omitempty"`
348         // Secret to access our Bucket.
349         SecretKey *v1.SecretKeySelector `json:"credentials,omitempty"`
350 }
351
352 // Deprecated: ThanosS3Spec should be configured with an ObjectStorageConfig
353 // secret starting with Thanos v0.2.0. ThanosS3Spec will be removed.
354 //
355 // +k8s:openapi-gen=true
356 type ThanosS3Spec struct {
357         // S3-Compatible API bucket name for stored blocks.
358         Bucket *string `json:"bucket,omitempty"`
359         // S3-Compatible API endpoint for stored blocks.
360         Endpoint *string `json:"endpoint,omitempty"`
361         // AccessKey for an S3-Compatible API.
362         AccessKey *v1.SecretKeySelector `json:"accessKey,omitempty"`
363         // SecretKey for an S3-Compatible API.
364         SecretKey *v1.SecretKeySelector `json:"secretKey,omitempty"`
365         // Whether to use an insecure connection with an S3-Compatible API.
366         Insecure *bool `json:"insecure,omitempty"`
367         // Whether to use S3 Signature Version 2; otherwise Signature Version 4 will be used.
368         SignatureVersion2 *bool `json:"signatureVersion2,omitempty"`
369         // Whether to use Server Side Encryption
370         EncryptSSE *bool `json:"encryptsse,omitempty"`
371 }
372
373 // RemoteWriteSpec defines the remote_write configuration for prometheus.
374 // +k8s:openapi-gen=true
375 type RemoteWriteSpec struct {
376         //The URL of the endpoint to send samples to.
377         URL string `json:"url"`
378         //Timeout for requests to the remote write endpoint.
379         RemoteTimeout string `json:"remoteTimeout,omitempty"`
380         //The list of remote write relabel configurations.
381         WriteRelabelConfigs []RelabelConfig `json:"writeRelabelConfigs,omitempty"`
382         //BasicAuth for the URL.
383         BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
384         // File to read bearer token for remote write.
385         BearerToken string `json:"bearerToken,omitempty"`
386         // File to read bearer token for remote write.
387         BearerTokenFile string `json:"bearerTokenFile,omitempty"`
388         // TLS Config to use for remote write.
389         TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
390         //Optional ProxyURL
391         ProxyURL string `json:"proxyUrl,omitempty"`
392         // QueueConfig allows tuning of the remote write queue parameters.
393         QueueConfig *QueueConfig `json:"queueConfig,omitempty"`
394 }
395
396 // QueueConfig allows the tuning of remote_write queue_config parameters. This object
397 // is referenced in the RemoteWriteSpec object.
398 // +k8s:openapi-gen=true
399 type QueueConfig struct {
400         // Capacity is the number of samples to buffer per shard before we start dropping them.
401         Capacity int `json:"capacity,omitempty"`
402         // MinShards is the minimum number of shards, i.e. amount of concurrency.
403         MinShards int `json:"minShards,omitempty"`
404         // MaxShards is the maximum number of shards, i.e. amount of concurrency.
405         MaxShards int `json:"maxShards,omitempty"`
406         // MaxSamplesPerSend is the maximum number of samples per send.
407         MaxSamplesPerSend int `json:"maxSamplesPerSend,omitempty"`
408         // BatchSendDeadline is the maximum time a sample will wait in buffer.
409         BatchSendDeadline string `json:"batchSendDeadline,omitempty"`
410         // MaxRetries is the maximum number of times to retry a batch on recoverable errors.
411         MaxRetries int `json:"maxRetries,omitempty"`
412         // MinBackoff is the initial retry delay. Gets doubled for every retry.
413         MinBackoff string `json:"minBackoff,omitempty"`
414         // MaxBackoff is the maximum retry delay.
415         MaxBackoff string `json:"maxBackoff,omitempty"`
416 }
417
418 // RemoteReadSpec defines the remote_read configuration for prometheus.
419 // +k8s:openapi-gen=true
420 type RemoteReadSpec struct {
421         //The URL of the endpoint to send samples to.
422         URL string `json:"url"`
423         //An optional list of equality matchers which have to be present
424         // in a selector to query the remote read endpoint.
425         RequiredMatchers map[string]string `json:"requiredMatchers,omitempty"`
426         //Timeout for requests to the remote read endpoint.
427         RemoteTimeout string `json:"remoteTimeout,omitempty"`
428         //Whether reads should be made for queries for time ranges that
429         // the local storage should have complete data for.
430         ReadRecent bool `json:"readRecent,omitempty"`
431         //BasicAuth for the URL.
432         BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
433         // bearer token for remote read.
434         BearerToken string `json:"bearerToken,omitempty"`
435         // File to read bearer token for remote read.
436         BearerTokenFile string `json:"bearerTokenFile,omitempty"`
437         // TLS Config to use for remote read.
438         TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
439         //Optional ProxyURL
440         ProxyURL string `json:"proxyUrl,omitempty"`
441 }
442
443 // RelabelConfig allows dynamic rewriting of the label set, being applied to samples before ingestion.
444 // It defines `<metric_relabel_configs>`-section of Prometheus configuration.
445 // More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs
446 // +k8s:openapi-gen=true
447 type RelabelConfig struct {
448         //The source labels select values from existing labels. Their content is concatenated
449         //using the configured separator and matched against the configured regular expression
450         //for the replace, keep, and drop actions.
451         SourceLabels []string `json:"sourceLabels,omitempty"`
452         //Separator placed between concatenated source label values. default is ';'.
453         Separator string `json:"separator,omitempty"`
454         //Label to which the resulting value is written in a replace action.
455         //It is mandatory for replace actions. Regex capture groups are available.
456         TargetLabel string `json:"targetLabel,omitempty"`
457         //Regular expression against which the extracted value is matched. defailt is '(.*)'
458         Regex string `json:"regex,omitempty"`
459         // Modulus to take of the hash of the source label values.
460         Modulus uint64 `json:"modulus,omitempty"`
461         //Replacement value against which a regex replace is performed if the
462         //regular expression matches. Regex capture groups are available. Default is '$1'
463         Replacement string `json:"replacement,omitempty"`
464         // Action to perform based on regex matching. Default is 'replace'
465         Action string `json:"action,omitempty"`
466 }
467
468 // APIServerConfig defines a host and auth methods to access apiserver.
469 // More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config
470 // +k8s:openapi-gen=true
471 type APIServerConfig struct {
472         // Host of apiserver.
473         // A valid string consisting of a hostname or IP followed by an optional port number
474         Host string `json:"host"`
475         // BasicAuth allow an endpoint to authenticate over basic authentication
476         BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
477         // Bearer token for accessing apiserver.
478         BearerToken string `json:"bearerToken,omitempty"`
479         // File to read bearer token for accessing apiserver.
480         BearerTokenFile string `json:"bearerTokenFile,omitempty"`
481         // TLS Config to use for accessing apiserver.
482         TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
483 }
484
485 // AlertmanagerEndpoints defines a selection of a single Endpoints object
486 // containing alertmanager IPs to fire alerts against.
487 // +k8s:openapi-gen=true
488 type AlertmanagerEndpoints struct {
489         // Namespace of Endpoints object.
490         Namespace string `json:"namespace"`
491         // Name of Endpoints object in Namespace.
492         Name string `json:"name"`
493         // Port the Alertmanager API is exposed on.
494         Port intstr.IntOrString `json:"port"`
495         // Scheme to use when firing alerts.
496         Scheme string `json:"scheme,omitempty"`
497         // Prefix for the HTTP path alerts are pushed to.
498         PathPrefix string `json:"pathPrefix,omitempty"`
499         // TLS Config to use for alertmanager connection.
500         TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
501         // BearerTokenFile to read from filesystem to use when authenticating to
502         // Alertmanager.
503         BearerTokenFile string `json:"bearerTokenFile,omitempty"`
504 }
505
506 // ServiceMonitor defines monitoring for a set of services.
507 // +genclient
508 // +k8s:openapi-gen=true
509 type ServiceMonitor struct {
510         metav1.TypeMeta `json:",inline"`
511         // Standard object’s metadata. More info:
512         // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
513         // +k8s:openapi-gen=false
514         metav1.ObjectMeta `json:"metadata,omitempty"`
515         // Specification of desired Service selection for target discrovery by
516         // Prometheus.
517         Spec ServiceMonitorSpec `json:"spec"`
518 }
519
520 // ServiceMonitorSpec contains specification parameters for a ServiceMonitor.
521 // +k8s:openapi-gen=true
522 type ServiceMonitorSpec struct {
523         // The label to use to retrieve the job name from.
524         JobLabel string `json:"jobLabel,omitempty"`
525         // TargetLabels transfers labels on the Kubernetes Service onto the target.
526         TargetLabels []string `json:"targetLabels,omitempty"`
527         // PodTargetLabels transfers labels on the Kubernetes Pod onto the target.
528         PodTargetLabels []string `json:"podTargetLabels,omitempty"`
529         // A list of endpoints allowed as part of this ServiceMonitor.
530         Endpoints []Endpoint `json:"endpoints"`
531         // Selector to select Endpoints objects.
532         Selector metav1.LabelSelector `json:"selector"`
533         // Selector to select which namespaces the Endpoints objects are discovered from.
534         NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"`
535         // SampleLimit defines per-scrape limit on number of scraped samples that will be accepted.
536         SampleLimit uint64 `json:"sampleLimit,omitempty"`
537 }
538
539 // Endpoint defines a scrapeable endpoint serving Prometheus metrics.
540 // +k8s:openapi-gen=true
541 type Endpoint struct {
542         // Name of the service port this endpoint refers to. Mutually exclusive with targetPort.
543         Port string `json:"port,omitempty"`
544         // Name or number of the target port of the endpoint. Mutually exclusive with port.
545         TargetPort *intstr.IntOrString `json:"targetPort,omitempty"`
546         // HTTP path to scrape for metrics.
547         Path string `json:"path,omitempty"`
548         // HTTP scheme to use for scraping.
549         Scheme string `json:"scheme,omitempty"`
550         // Optional HTTP URL parameters
551         Params map[string][]string `json:"params,omitempty"`
552         // Interval at which metrics should be scraped
553         Interval string `json:"interval,omitempty"`
554         // Timeout after which the scrape is ended
555         ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
556         // TLS configuration to use when scraping the endpoint
557         TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
558         // File to read bearer token for scraping targets.
559         BearerTokenFile string `json:"bearerTokenFile,omitempty"`
560         // HonorLabels chooses the metric's labels on collisions with target labels.
561         HonorLabels bool `json:"honorLabels,omitempty"`
562         // BasicAuth allow an endpoint to authenticate over basic authentication
563         // More info: https://prometheus.io/docs/operating/configuration/#endpoints
564         BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
565         // MetricRelabelConfigs to apply to samples before ingestion.
566         MetricRelabelConfigs []*RelabelConfig `json:"metricRelabelings,omitempty"`
567         // RelabelConfigs to apply to samples before ingestion.
568         // More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
569         RelabelConfigs []*RelabelConfig `json:"relabelings,omitempty"`
570         // ProxyURL eg http://proxyserver:2195 Directs scrapes to proxy through this endpoint.
571         ProxyURL *string `json:"proxyUrl,omitempty"`
572 }
573
574 // BasicAuth allow an endpoint to authenticate over basic authentication
575 // More info: https://prometheus.io/docs/operating/configuration/#endpoints
576 // +k8s:openapi-gen=true
577 type BasicAuth struct {
578         // The secret that contains the username for authenticate
579         Username v1.SecretKeySelector `json:"username,omitempty"`
580         // The secret that contains the password for authenticate
581         Password v1.SecretKeySelector `json:"password,omitempty"`
582 }
583
584 // TLSConfig specifies TLS configuration parameters.
585 // +k8s:openapi-gen=true
586 type TLSConfig struct {
587         // The CA cert to use for the targets.
588         CAFile string `json:"caFile,omitempty"`
589         // The client cert file for the targets.
590         CertFile string `json:"certFile,omitempty"`
591         // The client key file for the targets.
592         KeyFile string `json:"keyFile,omitempty"`
593         // Used to verify the hostname for the targets.
594         ServerName string `json:"serverName,omitempty"`
595         // Disable target certificate validation.
596         InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
597 }
598
599 // ServiceMonitorList is a list of ServiceMonitors.
600 // +k8s:openapi-gen=true
601 type ServiceMonitorList struct {
602         metav1.TypeMeta `json:",inline"`
603         // Standard list metadata
604         // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
605         metav1.ListMeta `json:"metadata,omitempty"`
606         // List of ServiceMonitors
607         Items []*ServiceMonitor `json:"items"`
608 }
609
610 // PrometheusRuleList is a list of PrometheusRules.
611 // +k8s:openapi-gen=true
612 type PrometheusRuleList struct {
613         metav1.TypeMeta `json:",inline"`
614         // Standard list metadata
615         // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
616         metav1.ListMeta `json:"metadata,omitempty"`
617         // List of Rules
618         Items []*PrometheusRule `json:"items"`
619 }
620
621 // PrometheusRule defines alerting rules for a Prometheus instance
622 // +genclient
623 // +k8s:openapi-gen=true
624 type PrometheusRule struct {
625         metav1.TypeMeta `json:",inline"`
626         // Standard object’s metadata. More info:
627         // http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
628         metav1.ObjectMeta `json:"metadata,omitempty"`
629         // Specification of desired alerting rule definitions for Prometheus.
630         Spec PrometheusRuleSpec `json:"spec"`
631 }
632
633 // PrometheusRuleSpec contains specification parameters for a Rule.
634 // +k8s:openapi-gen=true
635 type PrometheusRuleSpec struct {
636         // Content of Prometheus rule file
637         Groups []RuleGroup `json:"groups,omitempty"`
638 }
639
640 // RuleGroup and Rule are copied instead of vendored because the
641 // upstream Prometheus struct definitions don't have json struct tags.
642
643 // RuleGroup is a list of sequentially evaluated recording and alerting rules.
644 // +k8s:openapi-gen=true
645 type RuleGroup struct {
646         Name     string `json:"name"`
647         Interval string `json:"interval,omitempty"`
648         Rules    []Rule `json:"rules"`
649 }
650
651 // Rule describes an alerting or recording rule.
652 // +k8s:openapi-gen=true
653 type Rule struct {
654         Record      string             `json:"record,omitempty"`
655         Alert       string             `json:"alert,omitempty"`
656         Expr        intstr.IntOrString `json:"expr"`
657         For         string             `json:"for,omitempty"`
658         Labels      map[string]string  `json:"labels,omitempty"`
659         Annotations map[string]string  `json:"annotations,omitempty"`
660 }
661
662 // Alertmanager describes an Alertmanager cluster.
663 // +genclient
664 // +k8s:openapi-gen=true
665 type Alertmanager struct {
666         metav1.TypeMeta `json:",inline"`
667         // Standard object’s metadata. More info:
668         // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
669         // +k8s:openapi-gen=false
670         metav1.ObjectMeta `json:"metadata,omitempty"`
671         // Specification of the desired behavior of the Alertmanager cluster. More info:
672         // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
673         Spec AlertmanagerSpec `json:"spec"`
674         // Most recent observed status of the Alertmanager cluster. Read-only. Not
675         // included when requesting from the apiserver, only from the Prometheus
676         // Operator API itself. More info:
677         // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
678         Status *AlertmanagerStatus `json:"status,omitempty"`
679 }
680
681 // AlertmanagerSpec is a specification of the desired behavior of the Alertmanager cluster. More info:
682 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
683 // +k8s:openapi-gen=true
684 type AlertmanagerSpec struct {
685         // Standard object’s metadata. More info:
686         // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
687         // Metadata Labels and Annotations gets propagated to the prometheus pods.
688         PodMetadata *metav1.ObjectMeta `json:"podMetadata,omitempty"`
689         // Image if specified has precedence over baseImage, tag and sha
690         // combinations. Specifying the version is still necessary to ensure the
691         // Prometheus Operator knows what version of Alertmanager is being
692         // configured.
693         Image *string `json:"image,omitempty"`
694         // Version the cluster should be on.
695         Version string `json:"version,omitempty"`
696         // Tag of Alertmanager container image to be deployed. Defaults to the value of `version`.
697         // Version is ignored if Tag is set.
698         Tag string `json:"tag,omitempty"`
699         // SHA of Alertmanager container image to be deployed. Defaults to the value of `version`.
700         // Similar to a tag, but the SHA explicitly deploys an immutable container image.
701         // Version and Tag are ignored if SHA is set.
702         SHA string `json:"sha,omitempty"`
703         // Base image that is used to deploy pods, without tag.
704         BaseImage string `json:"baseImage,omitempty"`
705         // An optional list of references to secrets in the same namespace
706         // to use for pulling prometheus and alertmanager images from registries
707         // see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
708         ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
709         // Secrets is a list of Secrets in the same namespace as the Alertmanager
710         // object, which shall be mounted into the Alertmanager Pods.
711         // The Secrets are mounted into /etc/alertmanager/secrets/<secret-name>.
712         Secrets []string `json:"secrets,omitempty"`
713         // ConfigMaps is a list of ConfigMaps in the same namespace as the Alertmanager
714         // object, which shall be mounted into the Alertmanager Pods.
715         // The ConfigMaps are mounted into /etc/alertmanager/configmaps/<configmap-name>.
716         ConfigMaps []string `json:"configMaps,omitempty"`
717         // Log level for Alertmanager to be configured with.
718         LogLevel string `json:"logLevel,omitempty"`
719         // Size is the expected size of the alertmanager cluster. The controller will
720         // eventually make the size of the running cluster equal to the expected
721         // size.
722         Replicas *int32 `json:"replicas,omitempty"`
723         // Time duration Alertmanager shall retain data for. Default is '120h',
724         // and must match the regular expression `[0-9]+(ms|s|m|h)` (milliseconds seconds minutes hours).
725         Retention string `json:"retention,omitempty"`
726         // Storage is the definition of how storage will be used by the Alertmanager
727         // instances.
728         Storage *StorageSpec `json:"storage,omitempty"`
729         // The external URL the Alertmanager instances will be available under. This is
730         // necessary to generate correct URLs. This is necessary if Alertmanager is not
731         // served from root of a DNS name.
732         ExternalURL string `json:"externalUrl,omitempty"`
733         // The route prefix Alertmanager registers HTTP handlers for. This is useful,
734         // if using ExternalURL and a proxy is rewriting HTTP routes of a request,
735         // and the actual ExternalURL is still true, but the server serves requests
736         // under a different route prefix. For example for use with `kubectl proxy`.
737         RoutePrefix string `json:"routePrefix,omitempty"`
738         // If set to true all actions on the underlaying managed objects are not
739         // goint to be performed, except for delete actions.
740         Paused bool `json:"paused,omitempty"`
741         // Define which Nodes the Pods are scheduled on.
742         NodeSelector map[string]string `json:"nodeSelector,omitempty"`
743         // Define resources requests and limits for single Pods.
744         Resources v1.ResourceRequirements `json:"resources,omitempty"`
745         // If specified, the pod's scheduling constraints.
746         Affinity *v1.Affinity `json:"affinity,omitempty"`
747         // If specified, the pod's tolerations.
748         Tolerations []v1.Toleration `json:"tolerations,omitempty"`
749         // SecurityContext holds pod-level security attributes and common container settings.
750         // This defaults to non root user with uid 1000 and gid 2000.
751         SecurityContext *v1.PodSecurityContext `json:"securityContext,omitempty"`
752         // ServiceAccountName is the name of the ServiceAccount to use to run the
753         // Prometheus Pods.
754         ServiceAccountName string `json:"serviceAccountName,omitempty"`
755         // ListenLocal makes the Alertmanager server listen on loopback, so that it
756         // does not bind against the Pod IP. Note this is only for the Alertmanager
757         // UI, not the gossip communication.
758         ListenLocal bool `json:"listenLocal,omitempty"`
759         // Containers allows injecting additional containers. This is meant to
760         // allow adding an authentication proxy to an Alertmanager pod.
761         Containers []v1.Container `json:"containers,omitempty"`
762         // Priority class assigned to the Pods
763         PriorityClassName string `json:"priorityClassName,omitempty"`
764         // AdditionalPeers allows injecting a set of additional Alertmanagers to peer with to form a highly available cluster.
765         AdditionalPeers []string `json:"additionalPeers,omitempty"`
766 }
767
768 // AlertmanagerList is a list of Alertmanagers.
769 // +k8s:openapi-gen=true
770 type AlertmanagerList struct {
771         metav1.TypeMeta `json:",inline"`
772         // Standard list metadata
773         // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
774         metav1.ListMeta `json:"metadata,omitempty"`
775         // List of Alertmanagers
776         Items []Alertmanager `json:"items"`
777 }
778
779 // AlertmanagerStatus is the most recent observed status of the Alertmanager cluster. Read-only. Not
780 // included when requesting from the apiserver, only from the Prometheus
781 // Operator API itself. More info:
782 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
783 // +k8s:openapi-gen=true
784 type AlertmanagerStatus struct {
785         // Represents whether any actions on the underlaying managed objects are
786         // being performed. Only delete actions will be performed.
787         Paused bool `json:"paused"`
788         // Total number of non-terminated pods targeted by this Alertmanager
789         // cluster (their labels match the selector).
790         Replicas int32 `json:"replicas"`
791         // Total number of non-terminated pods targeted by this Alertmanager
792         // cluster that have the desired version spec.
793         UpdatedReplicas int32 `json:"updatedReplicas"`
794         // Total number of available pods (ready for at least minReadySeconds)
795         // targeted by this Alertmanager cluster.
796         AvailableReplicas int32 `json:"availableReplicas"`
797         // Total number of unavailable pods targeted by this Alertmanager cluster.
798         UnavailableReplicas int32 `json:"unavailableReplicas"`
799 }
800
801 // NamespaceSelector is a selector for selecting either all namespaces or a
802 // list of namespaces.
803 // +k8s:openapi-gen=true
804 type NamespaceSelector struct {
805         // Boolean describing whether all namespaces are selected in contrast to a
806         // list restricting them.
807         Any bool `json:"any,omitempty"`
808         // List of namespace names.
809         MatchNames []string `json:"matchNames,omitempty"`
810
811         // TODO(fabxc): this should embed metav1.LabelSelector eventually.
812         // Currently the selector is only used for namespaces which require more complex
813         // implementation to support label selections.
814 }
815
816 // /--rules.*/ command-line arguments
817 // +k8s:openapi-gen=true
818 type Rules struct {
819         Alert RulesAlert `json:"alert,omitempty"`
820 }
821
822 // /--rules.alert.*/ command-line arguments
823 // +k8s:openapi-gen=true
824 type RulesAlert struct {
825         // Max time to tolerate prometheus outage for restoring 'for' state of alert.
826         ForOutageTolerance string `json:"forOutageTolerance,omitempty"`
827         // Minimum duration between alert and restored 'for' state.
828         // This is maintained only for alerts with configured 'for' time greater than grace period.
829         ForGracePeriod string `json:"forGracePeriod,omitempty"`
830         // Minimum amount of time to wait before resending an alert to Alertmanager.
831         ResendDelay string `json:"resendDelay,omitempty"`
832 }
833
834 // DeepCopyObject implements the runtime.Object interface.
835 func (l *Alertmanager) DeepCopyObject() runtime.Object {
836         return l.DeepCopy()
837 }
838
839 // DeepCopyObject implements the runtime.Object interface.
840 func (l *AlertmanagerList) DeepCopyObject() runtime.Object {
841         return l.DeepCopy()
842 }
843
844 // DeepCopyObject implements the runtime.Object interface.
845 func (l *Prometheus) DeepCopyObject() runtime.Object {
846         return l.DeepCopy()
847 }
848
849 // DeepCopyObject implements the runtime.Object interface.
850 func (l *PrometheusList) DeepCopyObject() runtime.Object {
851         return l.DeepCopy()
852 }
853
854 // DeepCopyObject implements the runtime.Object interface.
855 func (l *ServiceMonitor) DeepCopyObject() runtime.Object {
856         return l.DeepCopy()
857 }
858
859 // DeepCopyObject implements the runtime.Object interface.
860 func (l *ServiceMonitorList) DeepCopyObject() runtime.Object {
861         return l.DeepCopy()
862 }
863
864 // DeepCopyObject implements the runtime.Object interface.
865 func (f *PrometheusRule) DeepCopyObject() runtime.Object {
866         return f.DeepCopy()
867 }
868
869 // DeepCopyObject implements the runtime.Object interface.
870 func (l *PrometheusRuleList) DeepCopyObject() runtime.Object {
871         return l.DeepCopy()
872 }