Skip to content

Commit

Permalink
Merge pull request #728 from olliewalsh/tls_custom_ca_fixes
Browse files Browse the repository at this point in the history
Fix TLS custom CA for rabbitmq and nova
  • Loading branch information
openshift-merge-bot[bot] authored Apr 3, 2024
2 parents f3e2f3a + bf479b9 commit d31f580
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
19 changes: 19 additions & 0 deletions pkg/openstack/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,3 +685,22 @@ func SetupServiceOperatorDefaults() {
// Barbican
barbicanv1.SetupDefaults()
}

func GetIssuerCertSecret(
ctx context.Context,
helper *helper.Helper,
name string,
namespace string,
) (string, error) {
// get issuer
issuer, err := certmanager.GetIssuerByName(
ctx,
helper,
name,
namespace,
)
if err != nil {
return "", err
}
return issuer.Spec.CA.SecretName, nil
}
4 changes: 2 additions & 2 deletions pkg/openstack/nova.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl
helper,
nova.Namespace,
instance.Spec.Nova.Template.MetadataServiceTemplate.Override.Service.Labels,
tls.DefaultCAPrefix+string(service.EndpointInternal),
instance.GetInternalIssuer(),
nil)
if err != nil && !k8s_errors.IsNotFound(err) {
return ctrlResult, err
Expand All @@ -196,7 +196,7 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl
helper,
nova.Namespace,
cellTemplate.MetadataServiceTemplate.Override.Service.Labels,
tls.DefaultCAPrefix+string(service.EndpointInternal),
instance.GetInternalIssuer(),
nil)
if err != nil && !k8s_errors.IsNotFound(err) {
return ctrlResult, err
Expand Down
10 changes: 7 additions & 3 deletions pkg/openstack/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
"github.com/openstack-k8s-operators/lib-common/modules/common/ocp"
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
rabbitmqv2 "github.com/rabbitmq/cluster-operator/v2/api/v1beta1"

Expand Down Expand Up @@ -195,6 +193,7 @@ func reconcileRabbitMQ(

hostname := fmt.Sprintf("%s.%s.svc", name, instance.Namespace)
tlsCert := ""
tlsCaCert := ""

if instance.Spec.TLS.PodLevel.Enabled {
certRequest := certmanager.CertificateRequest{
Expand All @@ -220,6 +219,11 @@ func reconcileRabbitMQ(
}

tlsCert = certSecret.Name

tlsCaCert, err = GetIssuerCertSecret(ctx, helper, instance.GetInternalIssuer(), instance.Namespace)
if err != nil {
return mqFailed, ctrlResult, err
}
}

op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), rabbitmq, func() error {
Expand Down Expand Up @@ -258,7 +262,7 @@ func reconcileRabbitMQ(
}

if tlsCert != "" {
rabbitmq.Spec.TLS.CaSecretName = tls.DefaultCAPrefix + string(service.EndpointInternal)
rabbitmq.Spec.TLS.CaSecretName = tlsCaCert
rabbitmq.Spec.TLS.SecretName = tlsCert
// disable non tls listeners
rabbitmq.Spec.TLS.DisableNonTLSListeners = true
Expand Down

0 comments on commit d31f580

Please sign in to comment.