Skip to content

Commit 404a2e8

Browse files
committed
[ovn][metrics] Pass cert secrets
Resolves: https://issues.redhat.com/browse/OSPRH-20823 Signed-off-by: Yatin Karel <ykarel@redhat.com>
1 parent 76eccee commit 404a2e8

8 files changed

Lines changed: 83 additions & 16 deletions

File tree

apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12116,6 +12116,13 @@ spec:
1211612116
metricsEnabled:
1211712117
default: true
1211812118
type: boolean
12119+
metricsTLS:
12120+
properties:
12121+
caBundleSecretName:
12122+
type: string
12123+
secretName:
12124+
type: string
12125+
type: object
1211912126
networkAttachment:
1212012127
type: string
1212112128
nicMappings:
@@ -12195,6 +12202,13 @@ spec:
1219512202
metricsEnabled:
1219612203
default: true
1219712204
type: boolean
12205+
metricsTLS:
12206+
properties:
12207+
caBundleSecretName:
12208+
type: string
12209+
secretName:
12210+
type: string
12211+
type: object
1219812212
networkAttachment:
1219912213
type: string
1220012214
nodeSelector:
@@ -12323,6 +12337,13 @@ spec:
1232312337
metricsEnabled:
1232412338
default: true
1232512339
type: boolean
12340+
metricsTLS:
12341+
properties:
12342+
caBundleSecretName:
12343+
type: string
12344+
secretName:
12345+
type: string
12346+
type: object
1232612347
nThreads:
1232712348
default: 1
1232812349
format: int32

apis/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,5 @@ replace k8s.io/code-generator => k8s.io/code-generator v0.31.13 //allow-merging
144144
replace k8s.io/component-base => k8s.io/component-base v0.31.13 //allow-merging
145145

146146
replace github.com/cert-manager/cmctl/v2 => github.com/cert-manager/cmctl/v2 v2.1.2-0.20241127223932-88edb96860cf //allow-merging
147+
148+
replace github.com/openstack-k8s-operators/ovn-operator/api => github.com/karelyatin/ovn-operator/api v0.0.0-20251016110332-fa590079ed53

apis/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE
7878
github.com/joshdk/go-junit v1.0.0/go.mod h1:TiiV0PqkaNfFXjEiyjWM3XXrhVyCa1K4Zfga6W52ung=
7979
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
8080
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
81+
github.com/karelyatin/ovn-operator/api v0.0.0-20251016110332-fa590079ed53 h1:Ph5lDvRqiA5xHf35myJp51txhyADB8OY9jPqgA3oFlk=
82+
github.com/karelyatin/ovn-operator/api v0.0.0-20251016110332-fa590079ed53/go.mod h1:RTW7SRp+Fn8JmIjdOgLl3GB3tTAhnI0q2XgauR1eEUM=
8183
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
8284
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
8385
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
@@ -150,8 +152,6 @@ github.com/openstack-k8s-operators/octavia-operator/api v0.6.1-0.20251007102453-
150152
github.com/openstack-k8s-operators/octavia-operator/api v0.6.1-0.20251007102453-ebfa5abc85f9/go.mod h1:9hVb6W4F+QOsScCF69O+y0DREQOYZNRHB3pAWNgdr9M=
151153
github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.6.1-0.20251007160653-73411ba26222 h1:6njT8VlvIBKuii7AEQumhqnI8u0dgoYkX8Rf7jcPySw=
152154
github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.6.1-0.20251007160653-73411ba26222/go.mod h1:StWvPTGwPxvaC5T+6qCEFVGlU1/en80J1pYijplyKZE=
153-
github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20251009064229-83a344ba9732 h1:n8VE9b+geiFr6z3j6Ys6stT2ntSWDGeB8Pp2odf82fA=
154-
github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20251009064229-83a344ba9732/go.mod h1:9A4u8gHLl+PeEfcqweyyIdUGRap3j95oTlkRhw6FDa0=
155155
github.com/openstack-k8s-operators/placement-operator/api v0.6.1-0.20251006102217-a0180c9d1d51 h1:+uy6b+pzHzib8OtjXex+mYsWMZc41P327Lima/TtAOM=
156156
github.com/openstack-k8s-operators/placement-operator/api v0.6.1-0.20251006102217-a0180c9d1d51/go.mod h1:tT7pLlledNe6qxzJPmgG4Vt3y8C8hjlUli0rPBeAiz0=
157157
github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec h1:saovr368HPAKHN0aRPh8h8n9s9dn3d8Frmfua0UYRlc=

config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12116,6 +12116,13 @@ spec:
1211612116
metricsEnabled:
1211712117
default: true
1211812118
type: boolean
12119+
metricsTLS:
12120+
properties:
12121+
caBundleSecretName:
12122+
type: string
12123+
secretName:
12124+
type: string
12125+
type: object
1211912126
networkAttachment:
1212012127
type: string
1212112128
nicMappings:
@@ -12195,6 +12202,13 @@ spec:
1219512202
metricsEnabled:
1219612203
default: true
1219712204
type: boolean
12205+
metricsTLS:
12206+
properties:
12207+
caBundleSecretName:
12208+
type: string
12209+
secretName:
12210+
type: string
12211+
type: object
1219812212
networkAttachment:
1219912213
type: string
1220012214
nodeSelector:
@@ -12323,6 +12337,13 @@ spec:
1232312337
metricsEnabled:
1232412338
default: true
1232512339
type: boolean
12340+
metricsTLS:
12341+
properties:
12342+
caBundleSecretName:
12343+
type: string
12344+
secretName:
12345+
type: string
12346+
type: object
1232612347
nThreads:
1232712348
default: 1
1232812349
format: int32

controllers/core/openstackcontrolplane_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func (r *OpenStackControlPlaneReconciler) Reconcile(ctx context.Context, req ctr
370370
}
371371

372372
func (r *OpenStackControlPlaneReconciler) reconcileOVNControllers(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *common_helper.Helper) (ctrl.Result, error) {
373-
OVNControllerReady, OVNControllerConditions, err := openstack.ReconcileOVNController(ctx, instance, version, helper)
373+
OVNControllerReady, OVNControllerConditions, err := openstack.ReconcileOVNController(ctx, instance, version, helper, "")
374374
if err != nil {
375375
return ctrl.Result{}, err
376376
} else if !OVNControllerReady {

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,5 @@ replace k8s.io/code-generator => k8s.io/code-generator v0.31.13 //allow-merging
154154
replace k8s.io/component-base => k8s.io/component-base v0.31.13 //allow-merging
155155

156156
replace github.com/cert-manager/cmctl/v2 => github.com/cert-manager/cmctl/v2 v2.1.2-0.20241127223932-88edb96860cf //allow-merging
157+
158+
replace github.com/openstack-k8s-operators/ovn-operator/api => github.com/karelyatin/ovn-operator/api v0.0.0-20251016110332-fa590079ed53

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
8282
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
8383
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.7.7 h1:z4P744DR+PIpkjwXSEc6TvN3L6LVzmUquFgmNm8wSUc=
8484
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.7.7/go.mod h1:CM7HAH5PNuIsqjMN0fGc1ydM74Uj+0VZFhob620nklw=
85+
github.com/karelyatin/ovn-operator/api v0.0.0-20251016110332-fa590079ed53 h1:Ph5lDvRqiA5xHf35myJp51txhyADB8OY9jPqgA3oFlk=
86+
github.com/karelyatin/ovn-operator/api v0.0.0-20251016110332-fa590079ed53/go.mod h1:RTW7SRp+Fn8JmIjdOgLl3GB3tTAhnI0q2XgauR1eEUM=
8587
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
8688
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
8789
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
@@ -160,8 +162,6 @@ github.com/openstack-k8s-operators/octavia-operator/api v0.6.1-0.20251007102453-
160162
github.com/openstack-k8s-operators/octavia-operator/api v0.6.1-0.20251007102453-ebfa5abc85f9/go.mod h1:9hVb6W4F+QOsScCF69O+y0DREQOYZNRHB3pAWNgdr9M=
161163
github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.6.1-0.20251007160653-73411ba26222 h1:6njT8VlvIBKuii7AEQumhqnI8u0dgoYkX8Rf7jcPySw=
162164
github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.6.1-0.20251007160653-73411ba26222/go.mod h1:StWvPTGwPxvaC5T+6qCEFVGlU1/en80J1pYijplyKZE=
163-
github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20251009064229-83a344ba9732 h1:n8VE9b+geiFr6z3j6Ys6stT2ntSWDGeB8Pp2odf82fA=
164-
github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20251009064229-83a344ba9732/go.mod h1:9A4u8gHLl+PeEfcqweyyIdUGRap3j95oTlkRhw6FDa0=
165165
github.com/openstack-k8s-operators/placement-operator/api v0.6.1-0.20251006102217-a0180c9d1d51 h1:+uy6b+pzHzib8OtjXex+mYsWMZc41P327Lima/TtAOM=
166166
github.com/openstack-k8s-operators/placement-operator/api v0.6.1-0.20251006102217-a0180c9d1d51/go.mod h1:tT7pLlledNe6qxzJPmgG4Vt3y8C8hjlUli0rPBeAiz0=
167167
github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec h1:saovr368HPAKHN0aRPh8h8n9s9dn3d8Frmfua0UYRlc=

pkg/openstack/ovn.go

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,30 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla
3838
}
3939

4040
// Create TLS certificate for OVN metrics services when TLS is enabled
41+
var ovnMetricsCertName string
4142
if instance.Spec.Ovn.Enabled && instance.Spec.TLS.PodLevel.Enabled {
42-
if err := EnsureOVNMetricsCert(ctx, instance, helper); err != nil {
43+
var err error
44+
ovnMetricsCertName, err = EnsureOVNMetricsCert(ctx, instance, helper)
45+
if err != nil {
4346
Log.Error(err, "Failed to ensure OVN metrics certificate")
4447
setOVNReadyError(instance, err)
4548
return ctrl.Result{}, err
4649
}
4750
}
4851

49-
OVNDBClustersReady, OVNDBClustersConditions, err := ReconcileOVNDbClusters(ctx, instance, version, helper)
52+
OVNDBClustersReady, OVNDBClustersConditions, err := ReconcileOVNDbClusters(ctx, instance, version, helper, ovnMetricsCertName)
5053
if err != nil {
5154
Log.Error(err, "Failed to reconcile OVNDBClusters")
5255
setOVNReadyError(instance, err)
5356
}
5457

55-
OVNNorthdReady, OVNNorthdConditions, err := ReconcileOVNNorthd(ctx, instance, version, helper)
58+
OVNNorthdReady, OVNNorthdConditions, err := ReconcileOVNNorthd(ctx, instance, version, helper, ovnMetricsCertName)
5659
if err != nil {
5760
Log.Error(err, "Failed to reconcile OVNNorthd")
5861
setOVNReadyError(instance, err)
5962
}
6063

61-
OVNControllerReady, OVNControllerConditions, err := ReconcileOVNController(ctx, instance, version, helper)
64+
OVNControllerReady, OVNControllerConditions, err := ReconcileOVNController(ctx, instance, version, helper, ovnMetricsCertName)
6265
if err != nil {
6366
Log.Error(err, "Failed to reconcile OVNController")
6467
setOVNReadyError(instance, err)
@@ -120,7 +123,7 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla
120123
}
121124

122125
// ReconcileOVNDbClusters reconciles the OVN database clusters for the OpenStack control plane
123-
func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper) (bool, condition.Conditions, error) {
126+
func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper, ovnMetricsCertName string) (bool, condition.Conditions, error) {
124127
Log := GetLogger(ctx)
125128
dnsSuffix := clusterdns.GetDNSClusterDomain()
126129
conditions := condition.Conditions{}
@@ -199,6 +202,12 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
199202
dbcluster.TLS.SecretName = &certSecret.Name
200203
}
201204

205+
// Set MetricsTLS configuration if TLS is enabled and metrics cert is available
206+
if instance.Spec.TLS.PodLevel.Enabled && ovnMetricsCertName != "" {
207+
dbcluster.MetricsTLS.SecretName = &ovnMetricsCertName
208+
dbcluster.MetricsTLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
209+
}
210+
202211
if dbcluster.NodeSelector == nil {
203212
dbcluster.NodeSelector = &instance.Spec.NodeSelector
204213
}
@@ -259,7 +268,7 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
259268
}
260269

261270
// ReconcileOVNNorthd reconciles the OVN Northd service for the OpenStack control plane
262-
func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper) (bool, condition.Conditions, error) {
271+
func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper, ovnMetricsCertName string) (bool, condition.Conditions, error) {
263272
Log := GetLogger(ctx)
264273
conditions := condition.Conditions{}
265274

@@ -334,6 +343,12 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
334343
}
335344
ovnNorthdSpec.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
336345

346+
// Set MetricsTLS configuration if TLS is enabled and metrics cert is available
347+
if instance.Spec.TLS.PodLevel.Enabled && ovnMetricsCertName != "" {
348+
ovnNorthdSpec.MetricsTLS.SecretName = &ovnMetricsCertName
349+
ovnNorthdSpec.MetricsTLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
350+
}
351+
337352
if ovnNorthdSpec.NodeSelector == nil {
338353
ovnNorthdSpec.NodeSelector = &instance.Spec.NodeSelector
339354
}
@@ -386,7 +401,7 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
386401
}
387402

388403
// ReconcileOVNController reconciles the OVN Controller service for the OpenStack control plane
389-
func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper) (bool, condition.Conditions, error) {
404+
func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper, ovnMetricsCertName string) (bool, condition.Conditions, error) {
390405
Log := GetLogger(ctx)
391406
conditions := condition.Conditions{}
392407

@@ -473,6 +488,12 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack
473488
}
474489
ovnControllerSpec.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
475490

491+
// Set MetricsTLS configuration if TLS is enabled and metrics cert is available
492+
if instance.Spec.TLS.PodLevel.Enabled && ovnMetricsCertName != "" {
493+
ovnControllerSpec.MetricsTLS.SecretName = &ovnMetricsCertName
494+
ovnControllerSpec.MetricsTLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
495+
}
496+
476497
if ovnControllerSpec.NodeSelector == nil {
477498
ovnControllerSpec.NodeSelector = &instance.Spec.NodeSelector
478499
}
@@ -568,7 +589,7 @@ func OVNNorthImageMatch(ctx context.Context, controlPlane *corev1beta1.OpenStack
568589
}
569590

570591
// EnsureOVNMetricsCert creates TLS certificate for OVN metrics services
571-
func EnsureOVNMetricsCert(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, helper *helper.Helper) error {
592+
func EnsureOVNMetricsCert(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, helper *helper.Helper) (string, error) {
572593
Log := GetLogger(ctx)
573594

574595
dnsSuffix := clusterdns.GetDNSClusterDomain()
@@ -606,12 +627,12 @@ func EnsureOVNMetricsCert(ctx context.Context, instance *corev1beta1.OpenStackCo
606627
certRequest,
607628
nil)
608629
if err != nil {
609-
return err
630+
return "", err
610631
} else if (ctrlResult != ctrl.Result{}) {
611632
Log.Info("OVN metrics certificate creation in progress", "certificate", certRequest.CertName)
612-
return fmt.Errorf("OVN metrics certificate creation in progress")
633+
return "", fmt.Errorf("OVN metrics certificate creation in progress")
613634
}
614635

615636
Log.Info("OVN metrics certificate ensured", "secret", certSecret.Name, "certificate", certRequest.CertName)
616-
return nil
637+
return certSecret.Name, nil
617638
}

0 commit comments

Comments
 (0)