Skip to content

Commit e685053

Browse files
committed
Configure TLS for Alertmanager
Now that COO and telemetry-operator finally support TLS for alertmanager, we can generate the certificates and configure TLS similar to all other services. Jira: https://redhat.atlassian.net/browse/OSPRH-5177 Generated-By: Claude-Code claude-opus-4-6
1 parent b243f21 commit e685053

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

internal/openstack/telemetry.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont
272272
if instance.Spec.TLS.PodLevel.Enabled {
273273
instance.Spec.Telemetry.Template.Autoscaling.Aodh.TLS = telemetry.Spec.Autoscaling.Aodh.TLS
274274
instance.Spec.Telemetry.Template.MetricStorage.PrometheusTLS = telemetry.Spec.MetricStorage.PrometheusTLS
275+
instance.Spec.Telemetry.Template.MetricStorage.AlertmanagerTLS = telemetry.Spec.MetricStorage.AlertmanagerTLS
275276
instance.Spec.Telemetry.Template.Ceilometer.TLS = telemetry.Spec.Ceilometer.TLS
276277
instance.Spec.Telemetry.Template.Ceilometer.MysqldExporterTLS = telemetry.Spec.Ceilometer.MysqldExporterTLS
277278
instance.Spec.Telemetry.Template.Ceilometer.KSMTLS = telemetry.Spec.Ceilometer.KSMTLS
@@ -285,6 +286,7 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont
285286
instance.Spec.Telemetry.Template.Ceilometer.MysqldExporterTLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
286287
instance.Spec.Telemetry.Template.Ceilometer.KSMTLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
287288
instance.Spec.Telemetry.Template.MetricStorage.PrometheusTLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
289+
instance.Spec.Telemetry.Template.MetricStorage.AlertmanagerTLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
288290
instance.Spec.Telemetry.Template.CloudKitty.CloudKittyAPI.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
289291
instance.Spec.Telemetry.Template.CloudKitty.CloudKittyProc.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
290292
// TODO
@@ -414,7 +416,7 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont
414416
if telemetry.Status.Conditions.IsTrue(telemetryv1.MetricStorageReadyCondition) {
415417
// EnsureEndpoint for prometheus
416418
// NOTE: We don't manage the prometheus service, it's managed by COO, we just annotate it
417-
endpointDetails, ctrlResult, err := EnsureEndpointConfig(
419+
prometheusEndpointDetails, ctrlResult, err := EnsureEndpointConfig(
418420
ctx,
419421
instance,
420422
helper,
@@ -438,37 +440,35 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont
438440
return ctrlResult, nil
439441
}
440442
// update TLS settings with cert secret
441-
instance.Spec.Telemetry.Template.MetricStorage.PrometheusTLS.SecretName = endpointDetails.GetEndptCertSecret(service.EndpointInternal)
442-
443-
// TODO: rewrite this once we have TLS on alertmanager
444-
for _, alertmanagerSvc := range alertmanagerSvcs.Items {
445-
ed := EndpointDetail{
446-
Name: alertmanagerSvc.Name,
447-
Namespace: alertmanagerSvc.Namespace,
448-
Type: service.Endpoint(alertmanagerSvc.Annotations[service.AnnotationEndpointKey]),
449-
Service: ServiceDetails{
450-
Spec: &alertmanagerSvc,
443+
instance.Spec.Telemetry.Template.MetricStorage.PrometheusTLS.SecretName = prometheusEndpointDetails.GetEndptCertSecret(service.EndpointInternal)
444+
445+
// EnsureEndpoint for alertmanager
446+
// NOTE: We don't manage the alertmanager service, it's managed by COO, we just annotate it
447+
alertmanagerEndpointDetails, ctrlResult, err := EnsureEndpointConfig(
448+
ctx,
449+
instance,
450+
helper,
451+
telemetry,
452+
alertmanagerSvcs,
453+
nil,
454+
instance.Spec.Telemetry.AlertmanagerOverride,
455+
corev1beta1.OpenStackControlPlaneExposeTelemetryReadyCondition,
456+
false, // TODO (mschuppert) could be removed when all integrated service support TLS
457+
tls.API{
458+
API: tls.APIService{
459+
Public: tls.GenericService{
460+
SecretName: instance.Spec.Telemetry.Template.MetricStorage.AlertmanagerTLS.SecretName,
461+
},
451462
},
452-
}
453-
ed.Route.Create = alertmanagerSvc.Annotations[service.AnnotationIngressCreateKey] == "true"
454-
ed.Route.TLS.Enabled = false
455-
if instance.Spec.Telemetry.AlertmanagerOverride.Route != nil {
456-
ed.Route.OverrideSpec = *instance.Spec.Telemetry.AlertmanagerOverride.Route
457-
}
458-
ctrlResult, err := ed.ensureRoute(
459-
ctx,
460-
instance,
461-
helper,
462-
&alertmanagerSvc,
463-
telemetry,
464-
corev1beta1.OpenStackControlPlaneExposeTelemetryReadyCondition,
465-
)
466-
if err != nil {
467-
return ctrlResult, err
468-
} else if (ctrlResult != ctrl.Result{}) {
469-
return ctrlResult, nil
470-
}
463+
},
464+
)
465+
if err != nil {
466+
return ctrlResult, err
467+
} else if (ctrlResult != ctrl.Result{}) {
468+
return ctrlResult, nil
471469
}
470+
// update TLS settings with cert secret
471+
instance.Spec.Telemetry.Template.MetricStorage.AlertmanagerTLS.SecretName = alertmanagerEndpointDetails.GetEndptCertSecret(service.EndpointInternal)
472472
}
473473

474474
if telemetry.Status.Conditions.IsTrue(telemetryv1.CeilometerReadyCondition) {

0 commit comments

Comments
 (0)