Skip to content

Commit

Permalink
Merge pull request #776 from stuggi/fix_duration
Browse files Browse the repository at this point in the history
[tls] fix neutron, octavia and ovn default cert duration, renwebefore
  • Loading branch information
openshift-merge-bot[bot] authored Apr 25, 2024
2 parents c71f738 + f46bff9 commit b4b4aad
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
7 changes: 6 additions & 1 deletion pkg/openstack/neutron.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro
certRequest := certmanager.CertificateRequest{
IssuerName: instance.GetOvnIssuer(),
CertName: fmt.Sprintf("%s-ovndbs", serviceName),
Duration: nil,
Hostnames: []string{
fmt.Sprintf("%s.%s.svc", serviceName, instance.Namespace),
fmt.Sprintf("%s.%s.svc.%s", serviceName, instance.Namespace, "cluster.local"),
Expand All @@ -79,6 +78,12 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro
certmgrv1.UsageClientAuth,
},
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore != nil {
certRequest.RenewBefore = &instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore.Duration
}
certSecret, ctrlResult, err := certmanager.EnsureCert(
ctx,
helper,
Expand Down
7 changes: 6 additions & 1 deletion pkg/openstack/octavia.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func ReconcileOctavia(ctx context.Context, instance *corev1beta1.OpenStackContro
certRequest := certmanager.CertificateRequest{
IssuerName: instance.GetOvnIssuer(),
CertName: fmt.Sprintf("%s-ovndbs", serviceName),
Duration: nil,
Hostnames: []string{
fmt.Sprintf("%s.%s.svc", serviceName, instance.Namespace),
fmt.Sprintf("%s.%s.svc.%s", serviceName, instance.Namespace, ClusterInternalDomain),
Expand All @@ -87,6 +86,12 @@ func ReconcileOctavia(ctx context.Context, instance *corev1beta1.OpenStackContro
certmgrv1.UsageClientAuth,
},
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore != nil {
certRequest.RenewBefore = &instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore.Duration
}
certSecret, ctrlResult, err := certmanager.EnsureCert(
ctx,
helper,
Expand Down
21 changes: 18 additions & 3 deletions pkg/openstack/ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
certRequest := certmanager.CertificateRequest{
IssuerName: instance.GetOvnIssuer(),
CertName: fmt.Sprintf("%s-ovndbs", name),
Duration: nil,
// Cert needs to be valid for the individual pods in the statefulset so make this a wildcard cert
Hostnames: []string{
fmt.Sprintf("*.%s.svc", instance.Namespace),
Expand All @@ -115,6 +114,12 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
certmgrv1.UsageClientAuth,
},
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore != nil {
certRequest.RenewBefore = &instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore.Duration
}
certSecret, ctrlResult, err := certmanager.EnsureCert(
ctx,
helper,
Expand Down Expand Up @@ -210,7 +215,6 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
certRequest := certmanager.CertificateRequest{
IssuerName: instance.GetOvnIssuer(),
CertName: fmt.Sprintf("%s-ovndbs", "ovnnorthd"),
Duration: nil,
Hostnames: []string{
fmt.Sprintf("%s.%s.svc", serviceName, instance.Namespace),
fmt.Sprintf("%s.%s.svc.%s", serviceName, instance.Namespace, ovnv1.DNSSuffix),
Expand All @@ -223,6 +227,12 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
certmgrv1.UsageClientAuth,
},
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore != nil {
certRequest.RenewBefore = &instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore.Duration
}
certSecret, ctrlResult, err := certmanager.EnsureCert(
ctx,
helper,
Expand Down Expand Up @@ -312,7 +322,6 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack
certRequest := certmanager.CertificateRequest{
IssuerName: instance.GetOvnIssuer(),
CertName: fmt.Sprintf("%s-ovndbs", "ovncontroller"),
Duration: nil,
Hostnames: []string{
fmt.Sprintf("%s.%s.svc", serviceName, instance.Namespace),
fmt.Sprintf("%s.%s.svc.%s", serviceName, instance.Namespace, ovnv1.DNSSuffix),
Expand All @@ -325,6 +334,12 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack
certmgrv1.UsageClientAuth,
},
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration
}
if instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore != nil {
certRequest.RenewBefore = &instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore.Duration
}
certSecret, ctrlResult, err := certmanager.EnsureCert(
ctx,
helper,
Expand Down

0 comments on commit b4b4aad

Please sign in to comment.