From bb1bbc49fe6fd4bb8162694d43cc1931db3b74d8 Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Wed, 18 Dec 2024 17:40:25 -0500 Subject: [PATCH] Add mysqld exporter --- ....openstack.org_openstackcontrolplanes.yaml | 2 + .../core.openstack.org_openstackversions.yaml | 6 +++ apis/core/v1beta1/openstackversion_types.go | 1 + apis/core/v1beta1/zz_generated.deepcopy.go | 5 +++ ....openstack.org_openstackcontrolplanes.yaml | 2 + .../core.openstack.org_openstackversions.yaml | 6 +++ config/default/manager_default_images.yaml | 2 + hack/export_related_images.sh | 1 + pkg/openstack/telemetry.go | 45 +++++++++++++++++++ pkg/openstack/version.go | 1 + .../openstackversion_controller_test.go | 1 + 11 files changed, 72 insertions(+) diff --git a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml index bc353af7e..307041f89 100644 --- a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -16739,6 +16739,8 @@ spec: type: string ceilometerIpmiImage: type: string + ceilometerMysqldExporterImage: + type: string ceilometerNotificationImage: type: string ceilometerProxyImage: diff --git a/apis/bases/core.openstack.org_openstackversions.yaml b/apis/bases/core.openstack.org_openstackversions.yaml index a4b7becfc..c8b301bcf 100644 --- a/apis/bases/core.openstack.org_openstackversions.yaml +++ b/apis/bases/core.openstack.org_openstackversions.yaml @@ -65,6 +65,8 @@ spec: type: string ceilometerIpmiImage: type: string + ceilometerMysqldExporterImage: + type: string ceilometerNotificationImage: type: string ceilometerSgcoreImage: @@ -272,6 +274,8 @@ spec: type: string ceilometerIpmiImage: type: string + ceilometerMysqldExporterImage: + type: string ceilometerNotificationImage: type: string ceilometerSgcoreImage: @@ -444,6 +448,8 @@ spec: type: string ceilometerIpmiImage: type: string + ceilometerMysqldExporterImage: + type: string ceilometerNotificationImage: type: string ceilometerProxyImage: diff --git a/apis/core/v1beta1/openstackversion_types.go b/apis/core/v1beta1/openstackversion_types.go index 4df40f5c6..dbe8ede40 100644 --- a/apis/core/v1beta1/openstackversion_types.go +++ b/apis/core/v1beta1/openstackversion_types.go @@ -89,6 +89,7 @@ type ContainerTemplate struct { CeilometerIpmiImage *string `json:"ceilometerIpmiImage,omitempty"` CeilometerNotificationImage *string `json:"ceilometerNotificationImage,omitempty"` CeilometerSgcoreImage *string `json:"ceilometerSgcoreImage,omitempty"` + CeilometerMysqldExporterImage *string `json:"ceilometerMysqldExporterImage,omitempty"` CinderAPIImage *string `json:"cinderAPIImage,omitempty"` CinderBackupImage *string `json:"cinderBackupImage,omitempty"` CinderSchedulerImage *string `json:"cinderSchedulerImage,omitempty"` diff --git a/apis/core/v1beta1/zz_generated.deepcopy.go b/apis/core/v1beta1/zz_generated.deepcopy.go index 9e3ebff7c..b5fdaa63e 100644 --- a/apis/core/v1beta1/zz_generated.deepcopy.go +++ b/apis/core/v1beta1/zz_generated.deepcopy.go @@ -323,6 +323,11 @@ func (in *ContainerTemplate) DeepCopyInto(out *ContainerTemplate) { *out = new(string) **out = **in } + if in.CeilometerMysqldExporterImage != nil { + in, out := &in.CeilometerMysqldExporterImage, &out.CeilometerMysqldExporterImage + *out = new(string) + **out = **in + } if in.CinderAPIImage != nil { in, out := &in.CinderAPIImage, &out.CinderAPIImage *out = new(string) diff --git a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml index bc353af7e..307041f89 100644 --- a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -16739,6 +16739,8 @@ spec: type: string ceilometerIpmiImage: type: string + ceilometerMysqldExporterImage: + type: string ceilometerNotificationImage: type: string ceilometerProxyImage: diff --git a/config/crd/bases/core.openstack.org_openstackversions.yaml b/config/crd/bases/core.openstack.org_openstackversions.yaml index a4b7becfc..c8b301bcf 100644 --- a/config/crd/bases/core.openstack.org_openstackversions.yaml +++ b/config/crd/bases/core.openstack.org_openstackversions.yaml @@ -65,6 +65,8 @@ spec: type: string ceilometerIpmiImage: type: string + ceilometerMysqldExporterImage: + type: string ceilometerNotificationImage: type: string ceilometerSgcoreImage: @@ -272,6 +274,8 @@ spec: type: string ceilometerIpmiImage: type: string + ceilometerMysqldExporterImage: + type: string ceilometerNotificationImage: type: string ceilometerSgcoreImage: @@ -444,6 +448,8 @@ spec: type: string ceilometerIpmiImage: type: string + ceilometerMysqldExporterImage: + type: string ceilometerNotificationImage: type: string ceilometerProxyImage: diff --git a/config/default/manager_default_images.yaml b/config/default/manager_default_images.yaml index 93a3eda01..d2706326e 100644 --- a/config/default/manager_default_images.yaml +++ b/config/default/manager_default_images.yaml @@ -39,6 +39,8 @@ spec: value: quay.io/podified-antelope-centos9/openstack-ceilometer-ipmi:current-podified - name: RELATED_IMAGE_CEILOMETER_NOTIFICATION_IMAGE_URL_DEFAULT value: quay.io/podified-antelope-centos9/openstack-ceilometer-notification:current-podified + - name: RELATED_IMAGE_CEILOMETER_MYSQLD_EXPORTER_IMAGE_URL_DEFAULT + value: quay.io/prometheus/mysqld-exporter:v0.16.0 - name: RELATED_IMAGE_CEILOMETER_SGCORE_IMAGE_URL_DEFAULT value: quay.io/openstack-k8s-operators/sg-core:v6.0.0 - name: RELATED_IMAGE_CINDER_API_IMAGE_URL_DEFAULT diff --git a/hack/export_related_images.sh b/hack/export_related_images.sh index d59f6e719..87f900ba2 100755 --- a/hack/export_related_images.sh +++ b/hack/export_related_images.sh @@ -34,6 +34,7 @@ export RELATED_IMAGE_CEILOMETER_COMPUTE_IMAGE_URL_DEFAULT=quay.io/podified-antel export RELATED_IMAGE_CEILOMETER_NOTIFICATION_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ceilometer-notification:current-podified export RELATED_IMAGE_CEILOMETER_IPMI_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-ceilometer-ipmi:current-podified export RELATED_IMAGE_CEILOMETER_SGCORE_IMAGE_URL_DEFAULT=quay.io/openstack-k8s-operators/sg-core:v6.0.0 +export RELATED_IMAGE_CEILOMETER_MYSQLD_EXPORTER_IMAGE_URL_DEFAULT=quay.io/prometheus/mysqld-exporter:v0.16.0 export RELATED_IMAGE_AODH_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-aodh-api:current-podified export RELATED_IMAGE_AODH_EVALUATOR_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-aodh-evaluator:current-podified export RELATED_IMAGE_AODH_NOTIFIER_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-aodh-notifier:current-podified diff --git a/pkg/openstack/telemetry.go b/pkg/openstack/telemetry.go index 9c72e91dc..fbc2a470d 100644 --- a/pkg/openstack/telemetry.go +++ b/pkg/openstack/telemetry.go @@ -47,6 +47,7 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont instance.Status.ContainerImages.CeilometerNotificationImage = nil instance.Status.ContainerImages.CeilometerSgcoreImage = nil instance.Status.ContainerImages.CeilometerProxyImage = nil + instance.Status.ContainerImages.CeilometerMysqldExporterImage = nil instance.Status.ContainerImages.AodhAPIImage = nil instance.Status.ContainerImages.AodhEvaluatorImage = nil instance.Status.ContainerImages.AodhNotifierImage = nil @@ -84,9 +85,11 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont instance.Spec.Telemetry.Template.Autoscaling.Aodh.TLS = telemetry.Spec.Autoscaling.Aodh.TLS instance.Spec.Telemetry.Template.MetricStorage.PrometheusTLS = telemetry.Spec.MetricStorage.PrometheusTLS instance.Spec.Telemetry.Template.Ceilometer.TLS = telemetry.Spec.Ceilometer.TLS + instance.Spec.Telemetry.Template.Ceilometer.MysqldExporterTLS = telemetry.Spec.Ceilometer.MysqldExporterTLS } instance.Spec.Telemetry.Template.Autoscaling.Aodh.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName instance.Spec.Telemetry.Template.Ceilometer.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName + instance.Spec.Telemetry.Template.Ceilometer.MysqldExporterTLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName instance.Spec.Telemetry.Template.MetricStorage.PrometheusTLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName aodhSvcs, err := service.GetServicesListWithLabel( @@ -128,6 +131,16 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont return ctrl.Result{}, err } + mysqldExporterSvcs, err := service.GetServicesListWithLabel( + ctx, + helper, + instance.Namespace, + map[string]string{common.AppSelector: "mysqld-exporter"}, + ) + if err != nil { + return ctrl.Result{}, err + } + // make sure to get to EndpointConfig when all service got created if len(aodhSvcs.Items) == len(instance.Spec.Telemetry.Template.Autoscaling.Aodh.Override.Service) { endpointDetails, ctrlResult, err := EnsureEndpointConfig( @@ -216,6 +229,7 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont if telemetry.Status.Conditions.IsTrue(telemetryv1.CeilometerReadyCondition) { // NOTE: We don't have svc overrides for ceilometer objects. + // Ceilometer endpointDetails, ctrlResult, err := EnsureEndpointConfig( ctx, instance, @@ -235,6 +249,29 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont } // update TLS settings with cert secret instance.Spec.Telemetry.Template.Ceilometer.TLS.SecretName = endpointDetails.GetEndptCertSecret(service.EndpointInternal) + + // MysqldExporter + if telemetry.Spec.Ceilometer.MysqldExporterEnabled != nil && *telemetry.Spec.Ceilometer.MysqldExporterEnabled { + endpointDetails, ctrlResult, err := EnsureEndpointConfig( + ctx, + instance, + helper, + telemetry, + mysqldExporterSvcs, + nil, + corev1beta1.Override{}, + corev1beta1.OpenStackControlPlaneExposeTelemetryReadyCondition, + false, // TODO (mschuppert) could be removed when all integrated service support TLS + tls.API{}, + ) + if err != nil { + return ctrlResult, err + } else if (ctrlResult != ctrl.Result{}) { + return ctrlResult, nil + } + // update TLS settings with cert secret + instance.Spec.Telemetry.Template.Ceilometer.MysqldExporterTLS.SecretName = endpointDetails.GetEndptCertSecret(service.EndpointInternal) + } } helper.GetLogger().Info("Reconciling Telemetry", telemetryNamespaceLabel, instance.Namespace, telemetryNameLabel, telemetryName) @@ -260,6 +297,12 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont telemetry.Spec.Autoscaling.AutoscalingSpec.Aodh.NotifierImage = *version.Status.ContainerImages.AodhNotifierImage telemetry.Spec.Autoscaling.AutoscalingSpec.Aodh.ListenerImage = *version.Status.ContainerImages.AodhListenerImage + if version.Status.ContainerImages.CeilometerMysqldExporterImage != nil { + telemetry.Spec.Ceilometer.MysqldExporterImage = *version.Status.ContainerImages.CeilometerMysqldExporterImage + } else { + telemetry.Spec.Ceilometer.MysqldExporterImage = "" + } + if telemetry.Spec.Ceilometer.Secret == "" { telemetry.Spec.Ceilometer.Secret = instance.Spec.Secret } @@ -302,6 +345,7 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont instance.Status.ContainerImages.CeilometerNotificationImage = version.Status.ContainerImages.CeilometerNotificationImage instance.Status.ContainerImages.CeilometerSgcoreImage = version.Status.ContainerImages.CeilometerSgcoreImage instance.Status.ContainerImages.CeilometerProxyImage = version.Status.ContainerImages.CeilometerProxyImage + instance.Status.ContainerImages.CeilometerMysqldExporterImage = version.Status.ContainerImages.CeilometerMysqldExporterImage instance.Status.ContainerImages.AodhAPIImage = version.Status.ContainerImages.AodhAPIImage instance.Status.ContainerImages.AodhEvaluatorImage = version.Status.ContainerImages.AodhEvaluatorImage instance.Status.ContainerImages.AodhNotifierImage = version.Status.ContainerImages.AodhNotifierImage @@ -328,6 +372,7 @@ func TelemetryImageMatch(ctx context.Context, controlPlane *corev1beta1.OpenStac !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerNotificationImage, version.Status.ContainerImages.CeilometerNotificationImage) || !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerSgcoreImage, version.Status.ContainerImages.CeilometerSgcoreImage) || !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerProxyImage, version.Status.ContainerImages.CeilometerProxyImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerMysqldExporterImage, version.Status.ContainerImages.CeilometerMysqldExporterImage) || !stringPointersEqual(controlPlane.Status.ContainerImages.AodhAPIImage, version.Status.ContainerImages.AodhAPIImage) || !stringPointersEqual(controlPlane.Status.ContainerImages.AodhEvaluatorImage, version.Status.ContainerImages.AodhEvaluatorImage) || !stringPointersEqual(controlPlane.Status.ContainerImages.AodhNotifierImage, version.Status.ContainerImages.AodhNotifierImage) || diff --git a/pkg/openstack/version.go b/pkg/openstack/version.go index e28505750..927a9757b 100644 --- a/pkg/openstack/version.go +++ b/pkg/openstack/version.go @@ -98,6 +98,7 @@ func GetContainerImages(defaults *corev1beta1.ContainerDefaults, instance corev1 CeilometerIpmiImage: getImg(instance.Spec.CustomContainerImages.CeilometerIpmiImage, defaults.CeilometerIpmiImage), CeilometerNotificationImage: getImg(instance.Spec.CustomContainerImages.CeilometerNotificationImage, defaults.CeilometerNotificationImage), CeilometerSgcoreImage: getImg(instance.Spec.CustomContainerImages.CeilometerSgcoreImage, defaults.CeilometerSgcoreImage), + CeilometerMysqldExporterImage: getImg(instance.Spec.CustomContainerImages.CeilometerMysqldExporterImage, defaults.CeilometerMysqldExporterImage), CinderAPIImage: getImg(instance.Spec.CustomContainerImages.CinderAPIImage, defaults.CinderAPIImage), CinderBackupImage: getImg(instance.Spec.CustomContainerImages.CinderBackupImage, defaults.CinderBackupImage), CinderSchedulerImage: getImg(instance.Spec.CustomContainerImages.CinderSchedulerImage, defaults.CinderSchedulerImage), diff --git a/tests/functional/ctlplane/openstackversion_controller_test.go b/tests/functional/ctlplane/openstackversion_controller_test.go index 0dd6ec90a..f679602a2 100644 --- a/tests/functional/ctlplane/openstackversion_controller_test.go +++ b/tests/functional/ctlplane/openstackversion_controller_test.go @@ -117,6 +117,7 @@ var _ = Describe("OpenStackOperator controller", func() { g.Expect(version.Status.ContainerImages.CeilometerNotificationImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.CeilometerSgcoreImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.CeilometerProxyImage).ShouldNot(BeNil()) + g.Expect(version.Status.ContainerImages.CeilometerMysqldExporterImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.CinderAPIImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.CinderBackupImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.CinderSchedulerImage).ShouldNot(BeNil())