From 0186ec69c1fb9c5f5eff466b36c3e6ab5cafe7d6 Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Thu, 27 Nov 2025 00:57:17 +0100 Subject: [PATCH 1/4] fix(fluentd): align metrics service names and reuse object metadata Signed-off-by: Zadkiel AHARONIAN --- pkg/resources/fluentd/service.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/resources/fluentd/service.go b/pkg/resources/fluentd/service.go index e725b8075..3dea70a7e 100644 --- a/pkg/resources/fluentd/service.go +++ b/pkg/resources/fluentd/service.go @@ -101,13 +101,13 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { var SampleLimit uint64 = 0 + objectMetadata := r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd) if r.fluentdSpec.Metrics.ServiceMonitorConfig.Scheme == "" { r.fluentdSpec.Metrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() } if r.fluentdSpec.Metrics != nil && r.fluentdSpec.Metrics.IsEnabled() && r.fluentdSpec.Metrics.ServiceMonitor { - objectMetadata := r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd) if r.fluentdSpec.Metrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.fluentdSpec.Metrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v @@ -138,12 +138,14 @@ func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.Desired }, reconciler.StatePresent, nil } return &v1.ServiceMonitor{ - ObjectMeta: r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd), + ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{}, }, reconciler.StateAbsent, nil } func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredState, error) { + objectMetadata := r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd) + if r.fluentdSpec.BufferVolumeMetrics != nil && r.fluentdSpec.BufferVolumeMetrics.IsEnabled() { port := int32(defaultBufferVolumeMetricsPort) if r.fluentdSpec.BufferVolumeMetrics.Port != 0 { @@ -174,7 +176,7 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS return desired, reconciler.StatePresent, nil } return &corev1.Service{ - ObjectMeta: r.FluentdObjectMeta(ServiceName+"-buffer-monitor", ComponentFluentd), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil } From 86c7d79fc85c2432daf2406562b2fa101c78c867 Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Thu, 27 Nov 2025 01:00:59 +0100 Subject: [PATCH 2/4] fix(fluentbit): align metrics service names and reuse object metadata Signed-off-by: Zadkiel AHARONIAN --- pkg/resources/fluentbit/service.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pkg/resources/fluentbit/service.go b/pkg/resources/fluentbit/service.go index a37ea877f..5633866f6 100644 --- a/pkg/resources/fluentbit/service.go +++ b/pkg/resources/fluentbit/service.go @@ -26,9 +26,11 @@ import ( ) func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, error) { + objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-metrics") + if r.fluentbitSpec.Metrics != nil && r.fluentbitSpec.Metrics.IsEnabled() { return &corev1.Service{ - ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-metrics"), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ { @@ -45,19 +47,19 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, }, reconciler.StatePresent, nil } return &corev1.Service{ - ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-monitor"), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil } func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { var SampleLimit uint64 = 0 + objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-metrics") if r.fluentbitSpec.Metrics.ServiceMonitorConfig.Scheme == "" { r.fluentbitSpec.Metrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() } if r.fluentbitSpec.Metrics != nil && r.fluentbitSpec.Metrics.IsEnabled() && r.fluentbitSpec.Metrics.ServiceMonitor { - objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-metrics") if r.fluentbitSpec.Metrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.fluentbitSpec.Metrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v @@ -89,12 +91,14 @@ func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.Desired }, reconciler.StatePresent, nil } return &v1.ServiceMonitor{ - ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-metrics"), + ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{}, }, reconciler.StateAbsent, nil } func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredState, error) { + objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics") + if r.fluentbitSpec.BufferVolumeMetrics != nil && r.fluentbitSpec.BufferVolumeMetrics.IsEnabled() { port := int32(defaultBufferVolumeMetricsPort) if r.fluentbitSpec.BufferVolumeMetrics.Port != 0 { @@ -102,8 +106,7 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS } return &corev1.Service{ - ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics"), - + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ { @@ -120,20 +123,19 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS }, reconciler.StatePresent, nil } return &corev1.Service{ - ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-monitor"), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil } func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { var SampleLimit uint64 = 0 + objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics") if r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme == "" { r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() } if r.fluentbitSpec.BufferVolumeMetrics != nil && r.fluentbitSpec.BufferVolumeMetrics.IsEnabled() && r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitor { - objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics") - objectMetadata.Labels = util.MergeLabels(objectMetadata.Labels, r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels) return &v1.ServiceMonitor{ ObjectMeta: objectMetadata, @@ -159,7 +161,7 @@ func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.D }, reconciler.StatePresent, nil } return &v1.ServiceMonitor{ - ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics"), + ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{}, }, reconciler.StateAbsent, nil } From 70a5ba4350067082ac159643d08283c541c3058d Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Thu, 27 Nov 2025 01:03:37 +0100 Subject: [PATCH 3/4] fix(syslogng): align metrics service names and reuse object metadata Signed-off-by: Zadkiel AHARONIAN --- pkg/resources/syslogng/service.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/resources/syslogng/service.go b/pkg/resources/syslogng/service.go index bfa8813b2..695628fed 100644 --- a/pkg/resources/syslogng/service.go +++ b/pkg/resources/syslogng/service.go @@ -70,9 +70,11 @@ func (r *Reconciler) service() (runtime.Object, reconciler.DesiredState, error) } func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, error) { + objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG) + if r.syslogNGSpec.Metrics != nil && r.syslogNGSpec.Metrics.IsEnabled() { desired := &corev1.Service{ - ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ { @@ -95,19 +97,19 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, return desired, reconciler.StatePresent, nil } return &corev1.Service{ - ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-monitor", ComponentSyslogNG), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil } func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { var SampleLimit uint64 = 0 + objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG) if r.syslogNGSpec.Metrics.ServiceMonitorConfig.Scheme == "" { r.syslogNGSpec.Metrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() } if r.syslogNGSpec.Metrics != nil && r.syslogNGSpec.Metrics.IsEnabled() && r.syslogNGSpec.Metrics.ServiceMonitor { - objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG) if r.syslogNGSpec.Metrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.syslogNGSpec.Metrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v @@ -138,12 +140,14 @@ func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.Desired }, reconciler.StatePresent, nil } return &v1.ServiceMonitor{ - ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG), + ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{}, }, reconciler.StateAbsent, nil } func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredState, error) { + objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG) + if r.syslogNGSpec.BufferVolumeMetrics != nil && r.syslogNGSpec.BufferVolumeMetrics.IsEnabled() { port := int32(defaultBufferVolumeMetricsPort) if r.syslogNGSpec.BufferVolumeMetrics.Port != 0 { @@ -151,7 +155,7 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS } desired := &corev1.Service{ - ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ { @@ -174,19 +178,19 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS return desired, reconciler.StatePresent, nil } return &corev1.Service{ - ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-buffer-monitor", ComponentSyslogNG), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil } func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { var SampleLimit uint64 = 0 + objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG) if r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme == "" { r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() } if r.syslogNGSpec.BufferVolumeMetrics != nil && r.syslogNGSpec.BufferVolumeMetrics.IsEnabled() && r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitor { - objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG) if r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v @@ -216,7 +220,7 @@ func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.D }, reconciler.StatePresent, nil } return &v1.ServiceMonitor{ - ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG), + ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{}, }, reconciler.StateAbsent, nil } From 45b3a370c29f1238abaf1be9db83371d07440571 Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Thu, 27 Nov 2025 01:05:43 +0100 Subject: [PATCH 4/4] fix(fluentd): align additional metrics service names and reuse object metadata Signed-off-by: Zadkiel AHARONIAN --- pkg/resources/fluentd/service.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/resources/fluentd/service.go b/pkg/resources/fluentd/service.go index 3dea70a7e..5428ed265 100644 --- a/pkg/resources/fluentd/service.go +++ b/pkg/resources/fluentd/service.go @@ -70,9 +70,11 @@ func (r *Reconciler) service() (runtime.Object, reconciler.DesiredState, error) } func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, error) { + objectMetadata := r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd) + if r.fluentdSpec.Metrics != nil && r.fluentdSpec.Metrics.IsEnabled() { desired := &corev1.Service{ - ObjectMeta: r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ { @@ -95,7 +97,7 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, return desired, reconciler.StatePresent, nil } return &corev1.Service{ - ObjectMeta: r.FluentdObjectMeta(ServiceName+"-monitor", ComponentFluentd), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil } @@ -153,7 +155,7 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS } desired := &corev1.Service{ - ObjectMeta: r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd), + ObjectMeta: objectMetadata, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ { @@ -182,13 +184,13 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { var SampleLimit uint64 = 0 + objectMetadata := r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd) if r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme == "" { r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() } if r.fluentdSpec.BufferVolumeMetrics != nil && r.fluentdSpec.BufferVolumeMetrics.IsEnabled() && r.fluentdSpec.BufferVolumeMetrics.ServiceMonitor { - objectMetadata := r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd) if r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v @@ -218,7 +220,7 @@ func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.D }, reconciler.StatePresent, nil } return &v1.ServiceMonitor{ - ObjectMeta: r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd), + ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{}, }, reconciler.StateAbsent, nil }