@@ -123,23 +123,53 @@ func newPrometheus(
123
123
},
124
124
125
125
Spec : monv1.PrometheusSpec {
126
- Replicas : config .Replicas ,
126
+ CommonPrometheusFields : monv1.CommonPrometheusFields {
127
+ Replicas : config .Replicas ,
127
128
128
- PodMetadata : & monv1.EmbeddedObjectMetadata {
129
- Labels : podLabels ("prometheus" , ms .Name ),
130
- },
131
-
132
- // Prometheus does not use an Enum for LogLevel, so need to convert to string
133
- LogLevel : string (ms .Spec .LogLevel ),
134
-
135
- Retention : ms .Spec .Retention ,
136
- Resources : ms .Spec .Resources ,
129
+ PodMetadata : & monv1.EmbeddedObjectMetadata {
130
+ Labels : podLabels ("prometheus" , ms .Name ),
131
+ },
137
132
138
- ServiceAccountName : rbacResourceName ,
133
+ // Prometheus does not use an Enum for LogLevel, so need to convert to string
134
+ LogLevel : string (ms .Spec .LogLevel ),
135
+
136
+ Resources : ms .Spec .Resources ,
137
+
138
+ ServiceAccountName : rbacResourceName ,
139
+
140
+ ServiceMonitorSelector : prometheusSelector ,
141
+ ServiceMonitorNamespaceSelector : nil ,
142
+ PodMonitorSelector : prometheusSelector ,
143
+ PodMonitorNamespaceSelector : nil ,
144
+ Affinity : & corev1.Affinity {
145
+ PodAntiAffinity : & corev1.PodAntiAffinity {
146
+ RequiredDuringSchedulingIgnoredDuringExecution : []corev1.PodAffinityTerm {
147
+ {
148
+ TopologyKey : "kubernetes.io/hostname" ,
149
+ LabelSelector : & metav1.LabelSelector {
150
+ MatchLabels : podLabels ("prometheus" , ms .Name ),
151
+ },
152
+ },
153
+ },
154
+ },
155
+ },
139
156
140
- ServiceMonitorSelector : prometheusSelector ,
141
- PodMonitorSelector : prometheusSelector ,
142
- RuleSelector : prometheusSelector ,
157
+ // Prometheus should be configured for self-scraping through a static job.
158
+ // It avoids the need to synthesize a ServiceMonitor with labels that will match
159
+ // what the user defines in the monitoring stacks's resourceSelector field.
160
+ AdditionalScrapeConfigs : & corev1.SecretKeySelector {
161
+ LocalObjectReference : corev1.LocalObjectReference {
162
+ Name : additionalScrapeConfigsSecretName ,
163
+ },
164
+ Key : AdditionalScrapeConfigsSelfScrapeKey ,
165
+ },
166
+ Storage : storageForPVC (config .PersistentVolumeClaim ),
167
+ RemoteWrite : config .RemoteWrite ,
168
+ ExternalLabels : config .ExternalLabels ,
169
+ },
170
+ Retention : ms .Spec .Retention ,
171
+ RuleSelector : prometheusSelector ,
172
+ RuleNamespaceSelector : nil ,
143
173
144
174
Alerting : & monv1.AlertingSpec {
145
175
Alertmanagers : []monv1.AlertmanagerEndpoints {
@@ -152,35 +182,10 @@ func newPrometheus(
152
182
},
153
183
},
154
184
},
155
- Affinity : & corev1.Affinity {
156
- PodAntiAffinity : & corev1.PodAntiAffinity {
157
- RequiredDuringSchedulingIgnoredDuringExecution : []corev1.PodAffinityTerm {
158
- {
159
- TopologyKey : "kubernetes.io/hostname" ,
160
- LabelSelector : & metav1.LabelSelector {
161
- MatchLabels : podLabels ("prometheus" , ms .Name ),
162
- },
163
- },
164
- },
165
- },
166
- },
167
-
168
- // Prometheus should be configured for self-scraping through a static job.
169
- // It avoids the need to synthesize a ServiceMonitor with labels that will match
170
- // what the user defines in the monitoring stacks's resourceSelector field.
171
- AdditionalScrapeConfigs : & corev1.SecretKeySelector {
172
- LocalObjectReference : corev1.LocalObjectReference {
173
- Name : additionalScrapeConfigsSecretName ,
174
- },
175
- Key : AdditionalScrapeConfigsSelfScrapeKey ,
176
- },
177
185
Thanos : & monv1.ThanosSpec {
178
186
BaseImage : stringPtr ("quay.io/thanos/thanos" ),
179
187
Version : stringPtr ("v0.24.0" ),
180
188
},
181
- Storage : storageForPVC (config .PersistentVolumeClaim ),
182
- RemoteWrite : config .RemoteWrite ,
183
- ExternalLabels : config .ExternalLabels ,
184
189
},
185
190
}
186
191
0 commit comments