Skip to content

Commit 8f9673e

Browse files
committed
Add mysqld_exporter
This adds mysqld_exporter to the Ceilometer resource. What I'd really appreciate some feedback: - Where exactly to put the status of mysqld_exporter in the CRD Whats missing: - ScrapeConfig - followup PR - API, TLS and openstackversion support in openstack-operator - PR when this is merged
1 parent f2c8dd9 commit 8f9673e

File tree

19 files changed

+1376
-25
lines changed

19 files changed

+1376
-25
lines changed

api/bases/telemetry.openstack.org_ceilometers.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,31 @@ spec:
147147
description: SecretName - holding the cert, key for the service
148148
type: string
149149
type: object
150+
mysqldExporterDatabaseAccountPrefix:
151+
default: mysqld-exporter
152+
description: MysqldExporterDatabaseAccountPrefix - Database account
153+
prefix for the mysqld-exporter. A mariadbaccount CR named "<mysqldExporterDatabaseAccountPrefix>-<galera
154+
CR name>" for each galera instance needs to be either created by
155+
the user or if it's missing, it'll be created by the telemetry-operator
156+
automatically.
157+
type: string
158+
mysqldExporterEnabled:
159+
description: Whether mysqld_exporter should be deployed
160+
type: boolean
161+
mysqldExporterImage:
162+
type: string
163+
mysqldExporterTLS:
164+
description: MysqldExporterTLS - Parameters related to the TLS for
165+
mysqld_exporter
166+
properties:
167+
caBundleSecretName:
168+
description: CaBundleSecretName - holding the CA certs in a pre-created
169+
bundle file
170+
type: string
171+
secretName:
172+
description: SecretName - holding the cert, key for the service
173+
type: string
174+
type: object
150175
networkAttachmentDefinitions:
151176
description: NetworkAttachmentDefinitions list of network attachment
152177
definitions the service pod gets attached to
@@ -268,6 +293,70 @@ spec:
268293
type: string
269294
description: Map of hashes to track e.g. job status
270295
type: object
296+
mysqldExporterStatus:
297+
description: MysqldExporterStatus defines the observed state of mysqld_exporter
298+
properties:
299+
conditions:
300+
description: Conditions
301+
items:
302+
description: Condition defines an observation of a API resource
303+
operational state.
304+
properties:
305+
lastTransitionTime:
306+
description: Last time the condition transitioned from one
307+
status to another. This should be when the underlying
308+
condition changed. If that is not known, then using the
309+
time when the API field changed is acceptable.
310+
format: date-time
311+
type: string
312+
message:
313+
description: A human readable message indicating details
314+
about the transition.
315+
type: string
316+
reason:
317+
description: The reason for the condition's last transition
318+
in CamelCase.
319+
type: string
320+
severity:
321+
description: Severity provides a classification of Reason
322+
code, so the current situation is immediately understandable
323+
and could act accordingly. It is meant for situations
324+
where Status=False and it should be indicated if it is
325+
just informational, warning (next reconciliation might
326+
fix it) or an error (e.g. DB create issue and no actions
327+
to automatically resolve the issue can/should be done).
328+
For conditions where Status=Unknown or Status=True the
329+
Severity should be SeverityNone.
330+
type: string
331+
status:
332+
description: Status of the condition, one of True, False,
333+
Unknown.
334+
type: string
335+
type:
336+
description: Type of condition in CamelCase.
337+
type: string
338+
required:
339+
- lastTransitionTime
340+
- status
341+
- type
342+
type: object
343+
type: array
344+
exportedGaleras:
345+
description: List of galera CRs, which are being exported with
346+
mysqld_exporter
347+
items:
348+
type: string
349+
type: array
350+
hash:
351+
additionalProperties:
352+
type: string
353+
description: Map of hashes to track e.g. job status
354+
type: object
355+
readyCount:
356+
description: ReadyCount of mysqld_exporter instances
357+
format: int32
358+
type: integer
359+
type: object
271360
networks:
272361
description: Networks in addtion to the cluster network, the service
273362
is attached to

api/bases/telemetry.openstack.org_telemetries.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,31 @@ spec:
474474
description: SecretName - holding the cert, key for the service
475475
type: string
476476
type: object
477+
mysqldExporterDatabaseAccountPrefix:
478+
default: mysqld-exporter
479+
description: MysqldExporterDatabaseAccountPrefix - Database account
480+
prefix for the mysqld-exporter. A mariadbaccount CR named "<mysqldExporterDatabaseAccountPrefix>-<galera
481+
CR name>" for each galera instance needs to be either created
482+
by the user or if it's missing, it'll be created by the telemetry-operator
483+
automatically.
484+
type: string
485+
mysqldExporterEnabled:
486+
description: Whether mysqld_exporter should be deployed
487+
type: boolean
488+
mysqldExporterImage:
489+
type: string
490+
mysqldExporterTLS:
491+
description: MysqldExporterTLS - Parameters related to the TLS
492+
for mysqld_exporter
493+
properties:
494+
caBundleSecretName:
495+
description: CaBundleSecretName - holding the CA certs in
496+
a pre-created bundle file
497+
type: string
498+
secretName:
499+
description: SecretName - holding the cert, key for the service
500+
type: string
501+
type: object
477502
networkAttachmentDefinitions:
478503
description: NetworkAttachmentDefinitions list of network attachment
479504
definitions the service pod gets attached to

api/v1beta1/ceilometer_types.go

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const (
4040
CeilometerProxyContainerImage = "quay.io/podified-antelope-centos9/openstack-aodh-api:current-podified"
4141
// KubeStateMetricsImage - default fall-back image for KSM
4242
KubeStateMetricsImage = "registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.0"
43+
// MysqldExporterImage - default fall-back image for mysqld_exporter
44+
MysqldExporterContainerImage = "quay.io/prometheus/mysqld-exporter:v0.16.0"
4345
)
4446

4547
// CeilometerSpec defines the desired state of Ceilometer
@@ -66,6 +68,9 @@ type CeilometerSpec struct {
6668

6769
// +kubebuilder:validation:Optional
6870
KSMImage string `json:"ksmImage"`
71+
72+
// +kubebuilder:validation:Optional
73+
MysqldExporterImage string `json:"mysqldExporterImage"`
6974
}
7075

7176
// CeilometerSpecCore defines the desired state of Ceilometer. This version is used by the OpenStackControlplane (no image parameters)
@@ -108,6 +113,18 @@ type CeilometerSpecCore struct {
108113
// NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to
109114
NetworkAttachmentDefinitions []string `json:"networkAttachmentDefinitions,omitempty"`
110115

116+
// Whether mysqld_exporter should be deployed
117+
// +kubebuilder:validation:optional
118+
MysqldExporterEnabled *bool `json:"mysqldExporterEnabled,omitempty"`
119+
120+
// MysqldExporterDatabaseAccountPrefix - Database account prefix for the mysqld-exporter.
121+
// A mariadbaccount CR named "<mysqldExporterDatabaseAccountPrefix>-<galera CR name>" for each
122+
// galera instance needs to be either created by the user or if it's missing, it'll be
123+
// created by the telemetry-operator automatically.
124+
// +kubebuilder:validation:optional
125+
// +kubebuilder:default=mysqld-exporter
126+
MysqldExporterDatabaseAccountPrefix string `json:"mysqldExporterDatabaseAccountPrefix,omitempty"`
127+
111128
// +kubebuilder:validation:Optional
112129
// +operator-sdk:csv:customresourcedefinitions:type=spec
113130
// TLS - Parameters related to the TLS
@@ -118,6 +135,11 @@ type CeilometerSpecCore struct {
118135
// KSMTLS - Parameters related to the TLS for kube-state-metrics
119136
KSMTLS tls.SimpleService `json:"ksmTls,omitempty"`
120137

138+
// +kubebuilder:validation:Optional
139+
// +operator-sdk:csv:customresourcedefinitions:type=spec
140+
// MysqldExporterTLS - Parameters related to the TLS for mysqld_exporter
141+
MysqldExporterTLS tls.SimpleService `json:"mysqldExporterTLS,omitempty"`
142+
121143
// +kubebuilder:validation:Optional
122144
// NodeSelector to target subset of worker nodes running this service
123145
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`
@@ -145,6 +167,8 @@ type CeilometerStatus struct {
145167
// then the controller has not processed the latest changes injected by
146168
// the openstack-operator in the top-level CR (e.g. the ContainerImage)
147169
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
170+
171+
MysqldExporterStatus MysqldExporterStatus `json:"mysqldExporterStatus,omitempty"`
148172
}
149173

150174
// KSMStatus defines the observed state of kube-state-metrics
@@ -165,6 +189,21 @@ type KSMStatus struct {
165189
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
166190
}
167191

192+
// MysqldExporterStatus defines the observed state of mysqld_exporter
193+
type MysqldExporterStatus struct {
194+
// ReadyCount of mysqld_exporter instances
195+
ReadyCount int32 `json:"readyCount,omitempty"`
196+
197+
// Map of hashes to track e.g. job status
198+
Hash map[string]string `json:"hash,omitempty"`
199+
200+
// Conditions
201+
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`
202+
203+
// List of galera CRs, which are being exported with mysqld_exporter
204+
ExportedGaleras []string `json:"exportedGaleras,omitempty"`
205+
}
206+
168207
//+kubebuilder:object:root=true
169208
//+kubebuilder:subresource:status
170209
//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[0].status",description="Status"
@@ -218,13 +257,14 @@ func (instance Ceilometer) RbacResourceName() string {
218257
func SetupDefaultsCeilometer() {
219258
// Acquire environmental defaults and initialize Telemetry defaults with them
220259
ceilometerDefaults := CeilometerDefaults{
221-
CentralContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_CENTRAL_IMAGE_URL_DEFAULT", CeilometerCentralContainerImage),
222-
SgCoreContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_SGCORE_IMAGE_URL_DEFAULT", CeilometerSgCoreContainerImage),
223-
NotificationContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_NOTIFICATION_IMAGE_URL_DEFAULT", CeilometerNotificationContainerImage),
224-
ComputeContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_COMPUTE_IMAGE_URL_DEFAULT", CeilometerComputeContainerImage),
225-
IpmiContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_IPMI_IMAGE_URL_DEFAULT", CeilometerIpmiContainerImage),
226-
ProxyContainerImageURL: util.GetEnvVar("RELATED_IMAGE_APACHE_IMAGE_URL_DEFAULT", CeilometerProxyContainerImage),
227-
KSMContainerImageURL: util.GetEnvVar("RELATED_IMAGE_KSM_IMAGE_URL_DEFAULT", KubeStateMetricsImage),
260+
CentralContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_CENTRAL_IMAGE_URL_DEFAULT", CeilometerCentralContainerImage),
261+
SgCoreContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_SGCORE_IMAGE_URL_DEFAULT", CeilometerSgCoreContainerImage),
262+
NotificationContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_NOTIFICATION_IMAGE_URL_DEFAULT", CeilometerNotificationContainerImage),
263+
ComputeContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_COMPUTE_IMAGE_URL_DEFAULT", CeilometerComputeContainerImage),
264+
IpmiContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_IPMI_IMAGE_URL_DEFAULT", CeilometerIpmiContainerImage),
265+
ProxyContainerImageURL: util.GetEnvVar("RELATED_IMAGE_APACHE_IMAGE_URL_DEFAULT", CeilometerProxyContainerImage),
266+
KSMContainerImageURL: util.GetEnvVar("RELATED_IMAGE_KSM_IMAGE_URL_DEFAULT", KubeStateMetricsImage),
267+
MysqldExporterContainerImageURL: util.GetEnvVar("RELATED_IMAGE_MYSQLD_EXPORTER_IMAGE_URL_DEFAULT", MysqldExporterContainerImage),
228268
}
229269

230270
SetupCeilometerDefaults(ceilometerDefaults)

api/v1beta1/ceilometer_webhook.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ import (
2626

2727
// CeilometerDefaults -
2828
type CeilometerDefaults struct {
29-
CentralContainerImageURL string
30-
NotificationContainerImageURL string
31-
SgCoreContainerImageURL string
32-
ComputeContainerImageURL string
33-
IpmiContainerImageURL string
34-
ProxyContainerImageURL string
35-
KSMContainerImageURL string
29+
CentralContainerImageURL string
30+
NotificationContainerImageURL string
31+
SgCoreContainerImageURL string
32+
ComputeContainerImageURL string
33+
IpmiContainerImageURL string
34+
ProxyContainerImageURL string
35+
KSMContainerImageURL string
36+
MysqldExporterContainerImageURL string
3637
}
3738

3839
var ceilometerDefaults CeilometerDefaults
@@ -89,6 +90,9 @@ func (spec *CeilometerSpec) Default() {
8990
if spec.KSMImage == "" {
9091
spec.KSMImage = ceilometerDefaults.KSMContainerImageURL
9192
}
93+
if spec.MysqldExporterImage == "" {
94+
spec.MysqldExporterImage = ceilometerDefaults.MysqldExporterContainerImageURL
95+
}
9296
}
9397

9498
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.

api/v1beta1/conditions.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,10 @@ const (
207207

208208
// KSMReadyRunningMessage
209209
KSMReadyRunningMessage = "KSM in progress"
210+
211+
//
212+
// mysqld_exporter condition messages
213+
//
214+
// MysqldExporterDisabledMessage
215+
MysqldExporterDisabledMessage = "mysqld_exporter is disabled"
210216
)

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)