From 30d9e06e518f461190aedf91eeb6a20082dbcc05 Mon Sep 17 00:00:00 2001 From: Kaushik Surya Date: Tue, 5 Aug 2025 14:37:31 -0400 Subject: [PATCH 1/4] Ability to configure Collector's Service, Headless Service, Monitoring Service and Extension Service --- .chloggen/configure-collector-services.yaml | 19 + Makefile | 1 + apis/v1alpha1/convert.go | 32 +- apis/v1alpha1/opentelemetrycollector_types.go | 33 ++ apis/v1alpha1/zz_generated.deepcopy.go | 24 ++ apis/v1beta1/opentelemetrycollector_types.go | 33 ++ apis/v1beta1/zz_generated.deepcopy.go | 24 ++ ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 56 +++ ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 56 +++ ...ntelemetry.io_opentelemetrycollectors.yaml | 56 +++ docs/api/instrumentations.md | 6 +- docs/api/opampbridges.md | 4 +- docs/api/opentelemetrycollectors.md | 344 +++++++++++++++++- docs/api/targetallocators.md | 4 +- internal/controllers/builder_test.go | 84 ++--- internal/manifests/collector/collector.go | 23 +- .../manifests/collector/collector_test.go | 18 +- internal/manifests/collector/service.go | 22 +- internal/manifests/collector/service_test.go | 65 +++- internal/manifests/collector/statefulset.go | 5 +- 22 files changed, 839 insertions(+), 74 deletions(-) create mode 100644 .chloggen/configure-collector-services.yaml diff --git a/.chloggen/configure-collector-services.yaml b/.chloggen/configure-collector-services.yaml new file mode 100644 index 0000000000..1c67ade0f7 --- /dev/null +++ b/.chloggen/configure-collector-services.yaml @@ -0,0 +1,19 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: collector + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Add the ability to configure the Collector's Service, Headless Service, Monitoring Service and Extension Service" + +# One or more tracking issues related to the change +issues: [4205] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + Introduces additional CRD options to configure and manage all the services deployed alongside the Collector. + Each of the Service, Headless Service, Monitoring Service & Extension Service can now be individually Enabled/Disabled + and the Name can be overridden. \ No newline at end of file diff --git a/Makefile b/Makefile index baf57e85a5..ebf63c67b4 100644 --- a/Makefile +++ b/Makefile @@ -657,6 +657,7 @@ TMP_DIR=$$(mktemp -d) ;\ cd $$TMP_DIR ;\ go mod init tmp ;\ echo "Downloading $(2)" ;\ +echo "replace fybrik.io/crdoc => github.com/fybrik/crdoc v0.5.2" >> go.mod ;\ go get $(2)@$(3) ;\ GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ rm -rf $$TMP_DIR ;\ diff --git a/apis/v1alpha1/convert.go b/apis/v1alpha1/convert.go index 87a2da9f1c..76cd716e7d 100644 --- a/apis/v1alpha1/convert.go +++ b/apis/v1alpha1/convert.go @@ -103,11 +103,15 @@ func tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error StatefulSetCommonFields: v1beta1.StatefulSetCommonFields{ VolumeClaimTemplates: copy.Spec.VolumeClaimTemplates, }, - Autoscaler: tov1beta1Autoscaler(copy.Spec.Autoscaler, copy.Spec.MinReplicas, copy.Spec.MaxReplicas), - TargetAllocator: tov1beta1TA(copy.Spec.TargetAllocator), - Mode: v1beta1.Mode(copy.Spec.Mode), - UpgradeStrategy: v1beta1.UpgradeStrategy(copy.Spec.UpgradeStrategy), - Config: *cfg, + Autoscaler: tov1beta1Autoscaler(copy.Spec.Autoscaler, copy.Spec.MinReplicas, copy.Spec.MaxReplicas), + TargetAllocator: tov1beta1TA(copy.Spec.TargetAllocator), + Mode: v1beta1.Mode(copy.Spec.Mode), + UpgradeStrategy: v1beta1.UpgradeStrategy(copy.Spec.UpgradeStrategy), + Config: *cfg, + Service: tov1beta1ServiceSpec(copy.Spec.Service), + HeadlessService: tov1beta1ServiceSpec(copy.Spec.HeadlessService), + MonitoringService: tov1beta1ServiceSpec(copy.Spec.MonitoringService), + ExtensionService: tov1beta1ServiceSpec(copy.Spec.ExtensionService), Ingress: v1beta1.Ingress{ Type: v1beta1.IngressType(copy.Spec.Ingress.Type), RuleType: v1beta1.IngressRuleType(copy.Spec.Ingress.RuleType), @@ -250,6 +254,13 @@ func tov1beta1Probe(in *Probe) *v1beta1.Probe { } } +func tov1beta1ServiceSpec(in ServiceSpec) v1beta1.ServiceSpec { + return v1beta1.ServiceSpec{ + Enabled: in.Enabled, + Name: in.Name, + } +} + func tov1beta1ConfigMaps(in []ConfigMapsSpec) []v1beta1.ConfigMapsSpec { var mapsSpecs []v1beta1.ConfigMapsSpec for _, m := range in { @@ -336,6 +347,10 @@ func tov1alpha1(in v1beta1.OpenTelemetryCollector) (*OpenTelemetryCollector, err Termination: TLSRouteTerminationType(copy.Spec.Ingress.Route.Termination), }, }, + Service: tov1alpha1ServiceSpec(copy.Spec.Service), + HeadlessService: tov1alpha1ServiceSpec(copy.Spec.HeadlessService), + MonitoringService: tov1alpha1ServiceSpec(copy.Spec.MonitoringService), + ExtensionService: tov1alpha1ServiceSpec(copy.Spec.ExtensionService), HostNetwork: copy.Spec.HostNetwork, ShareProcessNamespace: copy.Spec.ShareProcessNamespace, PriorityClassName: copy.Spec.PriorityClassName, @@ -383,6 +398,13 @@ func tov1alpha1Probe(in *v1beta1.Probe) *Probe { } } +func tov1alpha1ServiceSpec(in v1beta1.ServiceSpec) ServiceSpec { + return ServiceSpec{ + Enabled: in.Enabled, + Name: in.Name, + } +} + func tov1alpha1Autoscaler(in *v1beta1.AutoscalerSpec) *AutoscalerSpec { if in == nil { return nil diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go index 5a466137a8..db95a02778 100644 --- a/apis/v1alpha1/opentelemetrycollector_types.go +++ b/apis/v1alpha1/opentelemetrycollector_types.go @@ -239,6 +239,22 @@ type OpenTelemetryCollectorSpec struct { // +optional ServiceName string `json:"serviceName,omitempty"` + // Service to override configuration of the generated Collector Service. + // +optional + Service ServiceSpec `json:"service,omitempty"` + + // HeadlessService to override configuration of the generated Collector HeadlessService. + // +optional + HeadlessService ServiceSpec `json:"headlessService,omitempty"` + + // MonitoringService to override configuration of the generated Collector MonitoringService. + // +optional + MonitoringService ServiceSpec `json:"monitoringService,omitempty"` + + // ExtensionService to override configuration of the generated Collector ExtensionService. + // +optional + ExtensionService ServiceSpec `json:"extensionService,omitempty"` + // AdditionalContainers allows injecting additional containers into the Collector's pod definition. // These sidecar containers can be used for authentication proxies, log shipping sidecars, agents for shipping // metrics to their cloud, or in general sidecars that do not support automatic injection. This option only @@ -600,3 +616,20 @@ type ConfigMapsSpec struct { func init() { SchemeBuilder.Register(&OpenTelemetryCollector{}, &OpenTelemetryCollectorList{}) } + +type ServiceSpec struct { + // Enabled indicates whether the Service should be created. + // nil means not set (defaults to enabled for backward compatibility) + // +optional + Enabled *bool `json:"enabled,omitempty"` + + // Name to override the default Service name + // +optional + Name string `json:"name,omitempty"` +} + +// IsEnabled returns true if the service should be created. +// nil (not set) defaults to true for backward compatibility. +func (s *ServiceSpec) IsEnabled() bool { + return s.Enabled == nil || *s.Enabled +} diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index d2add49fda..1616ffe0de 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -973,6 +973,10 @@ func (in *OpenTelemetryCollectorSpec) DeepCopyInto(out *OpenTelemetryCollectorSp (*in)[i].DeepCopyInto(&(*out)[i]) } } + in.Service.DeepCopyInto(&out.Service) + in.HeadlessService.DeepCopyInto(&out.HeadlessService) + in.MonitoringService.DeepCopyInto(&out.MonitoringService) + in.ExtensionService.DeepCopyInto(&out.ExtensionService) if in.AdditionalContainers != nil { in, out := &in.AdditionalContainers, &out.AdditionalContainers *out = make([]v1.Container, len(*in)) @@ -1300,6 +1304,26 @@ func (in *ScaleSubresourceStatus) DeepCopy() *ScaleSubresourceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. +func (in *ServiceSpec) DeepCopy() *ServiceSpec { + if in == nil { + return nil + } + out := new(ServiceSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TLS) DeepCopyInto(out *TLS) { *out = *in diff --git a/apis/v1beta1/opentelemetrycollector_types.go b/apis/v1beta1/opentelemetrycollector_types.go index c6c49f00f1..f89dc8f9dd 100644 --- a/apis/v1beta1/opentelemetrycollector_types.go +++ b/apis/v1beta1/opentelemetrycollector_types.go @@ -140,6 +140,22 @@ type OpenTelemetryCollectorSpec struct { // If not specified, it will default to "-headless". // +optional ServiceName string `json:"serviceName,omitempty"` + + // Service to override configuration of the generated Collector Service. + // +optional + Service ServiceSpec `json:"service,omitempty"` + + // HeadlessService to override configuration of the generated Collector HeadlessService. + // +optional + HeadlessService ServiceSpec `json:"headlessService,omitempty"` + + // MonitoringService to override configuration of the generated Collector MonitoringService. + // +optional + MonitoringService ServiceSpec `json:"monitoringService,omitempty"` + + // ExtensionService to override configuration of the generated Collector ExtensionService. + // +optional + ExtensionService ServiceSpec `json:"extensionService,omitempty"` } // TargetAllocatorEmbedded defines the configuration for the Prometheus target allocator, embedded in the @@ -324,3 +340,20 @@ type ConfigMapsSpec struct { Name string `json:"name"` MountPath string `json:"mountpath"` } + +type ServiceSpec struct { + // Enabled indicates whether the Service should be created. + // nil means not set (defaults to enabled for backward compatibility) + // +optional + Enabled *bool `json:"enabled,omitempty"` + + // Name to override the default Service name + // +optional + Name string `json:"name,omitempty"` +} + +// IsEnabled returns true if the service should be created. +// nil (not set) defaults to true for backward compatibility. +func (s *ServiceSpec) IsEnabled() bool { + return s.Enabled == nil || *s.Enabled +} diff --git a/apis/v1beta1/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go index 411e4640de..55a9916b3c 100644 --- a/apis/v1beta1/zz_generated.deepcopy.go +++ b/apis/v1beta1/zz_generated.deepcopy.go @@ -307,6 +307,10 @@ func (in *OpenTelemetryCollectorSpec) DeepCopyInto(out *OpenTelemetryCollectorSp } in.DaemonSetUpdateStrategy.DeepCopyInto(&out.DaemonSetUpdateStrategy) in.DeploymentUpdateStrategy.DeepCopyInto(&out.DeploymentUpdateStrategy) + in.Service.DeepCopyInto(&out.Service) + in.HeadlessService.DeepCopyInto(&out.HeadlessService) + in.MonitoringService.DeepCopyInto(&out.MonitoringService) + in.ExtensionService.DeepCopyInto(&out.ExtensionService) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenTelemetryCollectorSpec. @@ -652,6 +656,26 @@ func (in *Service) DeepCopy() *Service { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. +func (in *ServiceSpec) DeepCopy() *ServiceSpec { + if in == nil { + return nil + } + out := new(ServiceSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StatefulSetCommonFields) DeepCopyInto(out *StatefulSetCommonFields) { *out = *in diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index 89b68f0b09..eac4d5409d 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2025-07-30T19:32:31Z" + createdAt: "2025-08-06T20:58:08Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index ff5b59db1a..662515ea44 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -1454,6 +1454,20 @@ spec: x-kubernetes-map-type: atomic type: object type: array + extensionService: + properties: + enabled: + type: boolean + name: + type: string + type: object + headlessService: + properties: + enabled: + type: boolean + name: + type: string + type: object hostNetwork: type: boolean image: @@ -2346,6 +2360,13 @@ spec: - sidecar - statefulset type: string + monitoringService: + properties: + enabled: + type: boolean + name: + type: string + type: object nodeSelector: additionalProperties: type: string @@ -2596,6 +2617,13 @@ spec: type: string type: object type: object + service: + properties: + enabled: + type: boolean + name: + type: string + type: object serviceAccount: type: string serviceName: @@ -6063,6 +6091,20 @@ spec: x-kubernetes-map-type: atomic type: object type: array + extensionService: + properties: + enabled: + type: boolean + name: + type: string + type: object + headlessService: + properties: + enabled: + type: boolean + name: + type: string + type: object hostNetwork: type: boolean image: @@ -6956,6 +6998,13 @@ spec: - sidecar - statefulset type: string + monitoringService: + properties: + enabled: + type: boolean + name: + type: string + type: object nodeSelector: additionalProperties: type: string @@ -7261,6 +7310,13 @@ spec: type: string type: object type: object + service: + properties: + enabled: + type: boolean + name: + type: string + type: object serviceAccount: type: string serviceName: diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index 879d3a6120..cb153a2be0 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2025-07-30T19:32:32Z" + createdAt: "2025-08-06T20:58:09Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index ff5b59db1a..662515ea44 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -1454,6 +1454,20 @@ spec: x-kubernetes-map-type: atomic type: object type: array + extensionService: + properties: + enabled: + type: boolean + name: + type: string + type: object + headlessService: + properties: + enabled: + type: boolean + name: + type: string + type: object hostNetwork: type: boolean image: @@ -2346,6 +2360,13 @@ spec: - sidecar - statefulset type: string + monitoringService: + properties: + enabled: + type: boolean + name: + type: string + type: object nodeSelector: additionalProperties: type: string @@ -2596,6 +2617,13 @@ spec: type: string type: object type: object + service: + properties: + enabled: + type: boolean + name: + type: string + type: object serviceAccount: type: string serviceName: @@ -6063,6 +6091,20 @@ spec: x-kubernetes-map-type: atomic type: object type: array + extensionService: + properties: + enabled: + type: boolean + name: + type: string + type: object + headlessService: + properties: + enabled: + type: boolean + name: + type: string + type: object hostNetwork: type: boolean image: @@ -6956,6 +6998,13 @@ spec: - sidecar - statefulset type: string + monitoringService: + properties: + enabled: + type: boolean + name: + type: string + type: object nodeSelector: additionalProperties: type: string @@ -7261,6 +7310,13 @@ spec: type: string type: object type: object + service: + properties: + enabled: + type: boolean + name: + type: string + type: object serviceAccount: type: string serviceName: diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 3a6eba7bc6..7afbde0725 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -1440,6 +1440,20 @@ spec: x-kubernetes-map-type: atomic type: object type: array + extensionService: + properties: + enabled: + type: boolean + name: + type: string + type: object + headlessService: + properties: + enabled: + type: boolean + name: + type: string + type: object hostNetwork: type: boolean image: @@ -2332,6 +2346,13 @@ spec: - sidecar - statefulset type: string + monitoringService: + properties: + enabled: + type: boolean + name: + type: string + type: object nodeSelector: additionalProperties: type: string @@ -2582,6 +2603,13 @@ spec: type: string type: object type: object + service: + properties: + enabled: + type: boolean + name: + type: string + type: object serviceAccount: type: string serviceName: @@ -6049,6 +6077,20 @@ spec: x-kubernetes-map-type: atomic type: object type: array + extensionService: + properties: + enabled: + type: boolean + name: + type: string + type: object + headlessService: + properties: + enabled: + type: boolean + name: + type: string + type: object hostNetwork: type: boolean image: @@ -6942,6 +6984,13 @@ spec: - sidecar - statefulset type: string + monitoringService: + properties: + enabled: + type: boolean + name: + type: string + type: object nodeSelector: additionalProperties: type: string @@ -7247,6 +7296,13 @@ spec: type: string type: object type: object + service: + properties: + enabled: + type: boolean + name: + type: string + type: object serviceAccount: type: string serviceName: diff --git a/docs/api/instrumentations.md b/docs/api/instrumentations.md index 87ac838c16..f7819620e5 100644 --- a/docs/api/instrumentations.md +++ b/docs/api/instrumentations.md @@ -45,7 +45,7 @@ Instrumentation is the spec for OpenTelemetry instrumentation. true - metadata + metadata object Refer to the Kubernetes API documentation for the fields of the `metadata` field. true @@ -167,6 +167,8 @@ Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
Propagators defines inter-process context propagation configuration. Values in this list will be set in the OTEL_PROPAGATORS env var. Enum=tracecontext;baggage;b3;b3multi;jaeger;xray;ottrace;none
+
+ Enum: tracecontext, baggage, b3, b3multi, jaeger, xray, ottrace, none
false @@ -7468,4 +7470,4 @@ The value can be for instance parentbased_always_on, parentbased_always_off, par false - \ No newline at end of file + diff --git a/docs/api/opampbridges.md b/docs/api/opampbridges.md index 9b90bad4b5..836669204d 100644 --- a/docs/api/opampbridges.md +++ b/docs/api/opampbridges.md @@ -45,7 +45,7 @@ OpAMPBridge is the Schema for the opampbridges API. true - metadata + metadata object Refer to the Kubernetes API documentation for the fields of the `metadata` field. true @@ -7595,4 +7595,4 @@ OpAMPBridgeStatus defines the observed state of OpAMPBridge. false - \ No newline at end of file + diff --git a/docs/api/opentelemetrycollectors.md b/docs/api/opentelemetrycollectors.md index 907d2bd341..d06b0f0dc8 100644 --- a/docs/api/opentelemetrycollectors.md +++ b/docs/api/opentelemetrycollectors.md @@ -46,7 +46,7 @@ OpenTelemetryCollector is the Schema for the opentelemetrycollectors API. true - metadata + metadata object Refer to the Kubernetes API documentation for the fields of the `metadata` field. true @@ -176,6 +176,20 @@ consumed in the config file for the Collector.
These can then in certain cases be consumed in the config file for the Collector.
false + + extensionService + object + + ExtensionService to override configuration of the generated Collector ExtensionService.
+ + false + + headlessService + object + + HeadlessService to override configuration of the generated Collector HeadlessService.
+ + false hostNetwork boolean @@ -261,6 +275,13 @@ Deprecated: use "OpenTelemetryCollector.Spec.Autoscaler.MinReplicas" instead.
Enum: daemonset, deployment, sidecar, statefulset
false + + monitoringService + object + + MonitoringService to override configuration of the generated Collector MonitoringService.
+ + false nodeSelector map[string]string @@ -353,6 +374,13 @@ In sidecar mode, this controls the security context for the injected sidecar container.
false + + service + object + + Service to override configuration of the generated Collector Service.
+ + false serviceAccount string @@ -6058,6 +6086,76 @@ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/nam +### OpenTelemetryCollector.spec.extensionService +[↩ Parent](#opentelemetrycollectorspec) + + + +ExtensionService to override configuration of the generated Collector ExtensionService. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
enabledboolean + Enabled indicates whether the Service should be created. +nil means not set (defaults to enabled for backward compatibility)
+
false
namestring + Name to override the default Service name
+
false
+ + +### OpenTelemetryCollector.spec.headlessService +[↩ Parent](#opentelemetrycollectorspec) + + + +HeadlessService to override configuration of the generated Collector HeadlessService. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
enabledboolean + Enabled indicates whether the Service should be created. +nil means not set (defaults to enabled for backward compatibility)
+
false
namestring + Name to override the default Service name
+
false
+ + ### OpenTelemetryCollector.spec.ingress [↩ Parent](#opentelemetrycollectorspec) @@ -9734,6 +9832,41 @@ More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#cont +### OpenTelemetryCollector.spec.monitoringService +[↩ Parent](#opentelemetrycollectorspec) + + + +MonitoringService to override configuration of the generated Collector MonitoringService. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
enabledboolean + Enabled indicates whether the Service should be created. +nil means not set (defaults to enabled for backward compatibility)
+
false
namestring + Name to override the default Service name
+
false
+ + ### OpenTelemetryCollector.spec.observability [↩ Parent](#opentelemetrycollectorspec) @@ -10851,6 +10984,41 @@ PodSecurityContext, the value specified in SecurityContext takes precedence.
+### OpenTelemetryCollector.spec.service +[↩ Parent](#opentelemetrycollectorspec) + + + +Service to override configuration of the generated Collector Service. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
enabledboolean + Enabled indicates whether the Service should be created. +nil means not set (defaults to enabled for backward compatibility)
+
false
namestring + Name to override the default Service name
+
false
+ + ### OpenTelemetryCollector.spec.targetAllocator [↩ Parent](#opentelemetrycollectorspec) @@ -19400,7 +19568,7 @@ OpenTelemetryCollector is the Schema for the opentelemetrycollectors API. true - metadata + metadata object Refer to the Kubernetes API documentation for the fields of the `metadata` field. true @@ -19409,6 +19577,8 @@ OpenTelemetryCollector is the Schema for the opentelemetrycollectors API. object OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector.
+
+ Validations:
  • !(self.mode == 'sidecar' && size(self.tolerations) > 0) || !has(self.tolerations): the OpenTelemetry Collector mode is set to sidecar, which does not support the attribute 'tolerations'
  • !(self.mode == 'sidecar' && self.priorityClassName != '') || !has(self.priorityClassName): the OpenTelemetry Collector mode is set to sidecar, which does not support the attribute 'priorityClassName'
  • !(self.mode == 'sidecar' && self.affinity != null) || !has(self.affinity): the OpenTelemetry Collector mode is set to sidecar, which does not support the attribute 'affinity'
  • !(self.mode == 'sidecar' && size(self.additionalContainers) > 0) || !has(self.additionalContainers): the OpenTelemetry Collector mode is set to sidecar, which does not support the attribute 'additionalContainers'
  • false @@ -19536,6 +19706,20 @@ This is only applicable to Deployment mode.
    List of sources to populate environment variables on the generated pods.
    false + + extensionService + object + + ExtensionService to override configuration of the generated Collector ExtensionService.
    + + false + + headlessService + object + + HeadlessService to override configuration of the generated Collector HeadlessService.
    + + false hostNetwork boolean @@ -19629,6 +19813,13 @@ Default is managed.
    Enum: daemonset, deployment, sidecar, statefulset
    false + + monitoringService + object + + MonitoringService to override configuration of the generated Collector MonitoringService.
    + + false nodeSelector map[string]string @@ -19745,6 +19936,13 @@ In sidecar mode, this controls the security context for the injected sidecar container.
    false + + service + object + + Service to override configuration of the generated Collector Service.
    + + false serviceAccount string @@ -25683,6 +25881,76 @@ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/nam +### OpenTelemetryCollector.spec.extensionService +[↩ Parent](#opentelemetrycollectorspec-1) + + + +ExtensionService to override configuration of the generated Collector ExtensionService. + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescriptionRequired
    enabledboolean + Enabled indicates whether the Service should be created. +nil means not set (defaults to enabled for backward compatibility)
    +
    false
    namestring + Name to override the default Service name
    +
    false
    + + +### OpenTelemetryCollector.spec.headlessService +[↩ Parent](#opentelemetrycollectorspec-1) + + + +HeadlessService to override configuration of the generated Collector HeadlessService. + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescriptionRequired
    enabledboolean + Enabled indicates whether the Service should be created. +nil means not set (defaults to enabled for backward compatibility)
    +
    false
    namestring + Name to override the default Service name
    +
    false
    + + ### OpenTelemetryCollector.spec.ingress [↩ Parent](#opentelemetrycollectorspec-1) @@ -29359,6 +29627,41 @@ More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#cont +### OpenTelemetryCollector.spec.monitoringService +[↩ Parent](#opentelemetrycollectorspec-1) + + + +MonitoringService to override configuration of the generated Collector MonitoringService. + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescriptionRequired
    enabledboolean + Enabled indicates whether the Service should be created. +nil means not set (defaults to enabled for backward compatibility)
    +
    false
    namestring + Name to override the default Service name
    +
    false
    + + ### OpenTelemetryCollector.spec.observability [↩ Parent](#opentelemetrycollectorspec-1) @@ -30700,6 +31003,41 @@ PodSecurityContext, the value specified in SecurityContext takes precedence.
    +### OpenTelemetryCollector.spec.service +[↩ Parent](#opentelemetrycollectorspec-1) + + + +Service to override configuration of the generated Collector Service. + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescriptionRequired
    enabledboolean + Enabled indicates whether the Service should be created. +nil means not set (defaults to enabled for backward compatibility)
    +
    false
    namestring + Name to override the default Service name
    +
    false
    + + ### OpenTelemetryCollector.spec.targetAllocator [↩ Parent](#opentelemetrycollectorspec-1) @@ -39488,4 +39826,4 @@ Deployment, Daemonset, StatefulSet.
    false - \ No newline at end of file + diff --git a/docs/api/targetallocators.md b/docs/api/targetallocators.md index 4eeb4afdfa..72038c70ec 100644 --- a/docs/api/targetallocators.md +++ b/docs/api/targetallocators.md @@ -45,7 +45,7 @@ TargetAllocator is the Schema for the targetallocators API. true - metadata + metadata object Refer to the Kubernetes API documentation for the fields of the `metadata` field. true @@ -14578,4 +14578,4 @@ TargetAllocatorStatus defines the observed state of Target Allocator. false - \ No newline at end of file + diff --git a/internal/controllers/builder_test.go b/internal/controllers/builder_test.go index 0acd72f9a0..eb49164977 100644 --- a/internal/controllers/builder_test.go +++ b/internal/controllers/builder_test.go @@ -558,6 +558,48 @@ service: Annotations: map[string]string{}, }, }, + &networkingv1.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-ingress", + Namespace: "test", + Labels: map[string]string{ + "app.kubernetes.io/instance": "test.test", + "app.kubernetes.io/managed-by": "opentelemetry-operator", + "app.kubernetes.io/name": "test-ingress", + "app.kubernetes.io/component": "opentelemetry-collector", + "app.kubernetes.io/part-of": "opentelemetry", + "app.kubernetes.io/version": "latest", + }, + Annotations: map[string]string{ + "something": "true", + }, + }, + Spec: networkingv1.IngressSpec{ + Rules: []networkingv1.IngressRule{ + { + Host: "example.com", + IngressRuleValue: networkingv1.IngressRuleValue{ + HTTP: &networkingv1.HTTPIngressRuleValue{ + Paths: []networkingv1.HTTPIngressPath{ + { + Path: "/examplereceiver", + PathType: &pathTypePrefix, + Backend: networkingv1.IngressBackend{ + Service: &networkingv1.IngressServiceBackend{ + Name: "test-collector", + Port: networkingv1.ServiceBackendPort{ + Name: "examplereceiver", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "test-collector", @@ -640,48 +682,6 @@ service: Selector: selectorLabels, }, }, - &networkingv1.Ingress{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-ingress", - Namespace: "test", - Labels: map[string]string{ - "app.kubernetes.io/instance": "test.test", - "app.kubernetes.io/managed-by": "opentelemetry-operator", - "app.kubernetes.io/name": "test-ingress", - "app.kubernetes.io/component": "opentelemetry-collector", - "app.kubernetes.io/part-of": "opentelemetry", - "app.kubernetes.io/version": "latest", - }, - Annotations: map[string]string{ - "something": "true", - }, - }, - Spec: networkingv1.IngressSpec{ - Rules: []networkingv1.IngressRule{ - { - Host: "example.com", - IngressRuleValue: networkingv1.IngressRuleValue{ - HTTP: &networkingv1.HTTPIngressRuleValue{ - Paths: []networkingv1.HTTPIngressPath{ - { - Path: "/examplereceiver", - PathType: &pathTypePrefix, - Backend: networkingv1.IngressBackend{ - Service: &networkingv1.IngressServiceBackend{ - Name: "test-collector", - Port: networkingv1.ServiceBackendPort{ - Name: "examplereceiver", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, }, wantErr: false, }, diff --git a/internal/manifests/collector/collector.go b/internal/manifests/collector/collector.go index 4398047bf0..4ae1bb1fa9 100644 --- a/internal/manifests/collector/collector.go +++ b/internal/manifests/collector/collector.go @@ -39,12 +39,20 @@ func Build(params manifests.Params) ([]client.Object, error) { manifests.Factory(ConfigMap), manifests.Factory(HorizontalPodAutoscaler), manifests.Factory(ServiceAccount), - manifests.Factory(Service), - manifests.Factory(HeadlessService), - manifests.Factory(MonitoringService), - manifests.Factory(ExtensionService), manifests.Factory(Ingress), }...) + if params.OtelCol.Spec.Service.IsEnabled() { + manifestFactories = append(manifestFactories, manifests.Factory(Service)) + } + if params.OtelCol.Spec.HeadlessService.IsEnabled() { + manifestFactories = append(manifestFactories, manifests.Factory(HeadlessService)) + } + if params.OtelCol.Spec.MonitoringService.IsEnabled() { + manifestFactories = append(manifestFactories, manifests.Factory(MonitoringService)) + } + if params.OtelCol.Spec.ExtensionService.IsEnabled() { + manifestFactories = append(manifestFactories, manifests.Factory(ExtensionService)) + } if featuregate.CollectorUsesTargetAllocatorCR.IsEnabled() { manifestFactories = append(manifestFactories, manifests.Factory(TargetAllocator)) @@ -54,7 +62,12 @@ func Build(params manifests.Params) ([]client.Object, error) { if params.OtelCol.Spec.Mode == v1beta1.ModeSidecar { manifestFactories = append(manifestFactories, manifests.Factory(PodMonitor)) } else { - manifestFactories = append(manifestFactories, manifests.Factory(ServiceMonitor), manifests.Factory(ServiceMonitorMonitoring)) + if params.OtelCol.Spec.Service.IsEnabled() { + manifestFactories = append(manifestFactories, manifests.Factory(ServiceMonitor)) + } + if params.OtelCol.Spec.MonitoringService.IsEnabled() { + manifestFactories = append(manifestFactories, manifests.Factory(ServiceMonitorMonitoring)) + } } } diff --git a/internal/manifests/collector/collector_test.go b/internal/manifests/collector/collector_test.go index 059dc0deb1..2428fa7377 100644 --- a/internal/manifests/collector/collector_test.go +++ b/internal/manifests/collector/collector_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" v1 "k8s.io/api/authorization/v1" rbacv1 "k8s.io/api/rbac/v1" + "k8s.io/utils/ptr" "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/prometheus" @@ -159,7 +160,7 @@ func TestBuild(t *testing.T) { }, Config: config.New(), }, - expectedObjects: 5, + expectedObjects: 5, // ConfigMap, ServiceAccount, Deployment, PodDisruptionBudget, MonitoringService wantErr: false, }, { @@ -316,6 +317,21 @@ func TestBuild(t *testing.T) { expectedObjects: 9, wantErr: true, }, + { + name: "disabled services are not created", + params: manifests.Params{ + Log: logger, + OtelCol: v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Mode: v1beta1.ModeDeployment, + MonitoringService: v1beta1.ServiceSpec{Enabled: ptr.To(false)}, + }, + }, + Config: config.New(), + }, + expectedObjects: 4, // ConfigMap, ServiceAccount, Deployment, PodDisruptionBudget + wantErr: false, + }, } for _, tt := range tests { diff --git a/internal/manifests/collector/service.go b/internal/manifests/collector/service.go index 6e5bcbbd75..1ef96b80ab 100644 --- a/internal/manifests/collector/service.go +++ b/internal/manifests/collector/service.go @@ -44,7 +44,10 @@ func HeadlessService(params manifests.Params) (*corev1.Service, error) { return h, err } - h.Name = naming.HeadlessService(params.OtelCol.Name) + h.Name = params.OtelCol.Spec.HeadlessService.Name + if h.Name == "" { + h.Name = naming.HeadlessService(params.OtelCol.Name) + } h.Labels[headlessLabel] = valueExists h.Labels[serviceTypeLabel] = HeadlessServiceType.String() @@ -62,7 +65,10 @@ func HeadlessService(params manifests.Params) (*corev1.Service, error) { } func MonitoringService(params manifests.Params) (*corev1.Service, error) { - name := naming.MonitoringService(params.OtelCol.Name) + name := params.OtelCol.Spec.MonitoringService.Name + if name == "" { + name = naming.MonitoringService(params.OtelCol.Name) + } labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{}) labels[monitoringLabel] = valueExists labels[serviceTypeLabel] = MonitoringServiceType.String() @@ -98,7 +104,10 @@ func MonitoringService(params manifests.Params) (*corev1.Service, error) { } func ExtensionService(params manifests.Params) (*corev1.Service, error) { - name := naming.ExtensionService(params.OtelCol.Name) + name := params.OtelCol.Spec.ExtensionService.Name + if name == "" { + name = naming.ExtensionService(params.OtelCol.Name) + } labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{}) labels[serviceTypeLabel] = ExtensionServiceType.String() @@ -131,7 +140,10 @@ func ExtensionService(params manifests.Params) (*corev1.Service, error) { } func Service(params manifests.Params) (*corev1.Service, error) { - name := naming.Service(params.OtelCol.Name) + name := params.OtelCol.Spec.Service.Name + if name == "" { + name = naming.Service(params.OtelCol.Name) + } labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{}) labels[serviceTypeLabel] = BaseServiceType.String() @@ -187,7 +199,7 @@ func Service(params manifests.Params) (*corev1.Service, error) { return &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: naming.Service(params.OtelCol.Name), + Name: name, Namespace: params.OtelCol.Namespace, Labels: labels, Annotations: annotations, diff --git a/internal/manifests/collector/service_test.go b/internal/manifests/collector/service_test.go index 73fddb9932..4ce193c8c1 100644 --- a/internal/manifests/collector/service_test.go +++ b/internal/manifests/collector/service_test.go @@ -10,6 +10,7 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" @@ -258,6 +259,15 @@ func TestDesiredService(t *testing.T) { assert.NoError(t, err) }) + t.Run("should use custom service name when specified", func(t *testing.T) { + params := deploymentParams() + params.OtelCol.Spec.Service = v1beta1.ServiceSpec{Enabled: ptr.To(true), Name: "custom-service"} + actual, err := Service(params) + assert.NoError(t, err) + assert.NotNil(t, actual) + assert.Equal(t, "custom-service", actual.Name) + }) + } func TestHeadlessService(t *testing.T) { @@ -268,6 +278,14 @@ func TestHeadlessService(t *testing.T) { assert.Equal(t, actual.GetAnnotations()["service.beta.openshift.io/serving-cert-secret-name"], "test-collector-headless-tls") assert.Equal(t, actual.Spec.ClusterIP, "None") }) + + t.Run("should use custom headless service name when specified", func(t *testing.T) { + params := deploymentParams() + params.OtelCol.Spec.HeadlessService = v1beta1.ServiceSpec{Enabled: ptr.To(true), Name: "custom-headless-service"} + actual, err := HeadlessService(params) + assert.NoError(t, err) + assert.Equal(t, "custom-headless-service", actual.Name) + }) } func TestMonitoringService(t *testing.T) { @@ -309,13 +327,22 @@ func TestMonitoringService(t *testing.T) { assert.NotNil(t, actual) assert.Equal(t, expected, actual.Spec.Ports) }) + + t.Run("should use custom monitoring service name when specified", func(t *testing.T) { + params := deploymentParams() + params.OtelCol.Spec.MonitoringService = v1beta1.ServiceSpec{Enabled: ptr.To(true), Name: "custom-monitoring-service"} + actual, err := MonitoringService(params) + assert.NoError(t, err) + assert.Equal(t, "custom-monitoring-service", actual.Name) + }) } func TestExtensionService(t *testing.T) { testCases := []struct { - name string - params manifests.Params - expectedPorts []v1.ServicePort + name string + params manifests.Params + expectedPorts []v1.ServicePort + expectedService string }{ { name: "when the extension has http endpoint", @@ -487,6 +514,32 @@ func TestExtensionService(t *testing.T) { }, }, }, + { + name: "when the extension service name is overridden", + params: manifests.Params{ + Config: config.Config{}, + Log: testLogger, + OtelCol: v1beta1.OpenTelemetryCollector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{ + Service: v1beta1.Service{ + Extensions: []string{"jaeger_query"}, + }, + Extensions: &v1beta1.AnyConfig{ + Object: map[string]interface{}{}, + }, + }, + ExtensionService: v1beta1.ServiceSpec{ + Name: "custom-extension-service", + }, + }, + }, + }, + expectedService: "custom-extension-service", + }, } for _, tc := range testCases { @@ -497,7 +550,11 @@ func TestExtensionService(t *testing.T) { if len(tc.expectedPorts) > 0 { assert.NotNil(t, actual) - assert.Equal(t, actual.Name, naming.ExtensionService(tc.params.OtelCol.Name)) + expectedServiceName := tc.expectedService + if expectedServiceName == "" { + expectedServiceName = naming.ExtensionService(tc.params.OtelCol.Name) + } + assert.Equal(t, expectedServiceName, actual.Name) // ports assertion assert.Equal(t, len(tc.expectedPorts), len(actual.Spec.Ports)) assert.Equal(t, tc.expectedPorts[0].Name, actual.Spec.Ports[0].Name) diff --git a/internal/manifests/collector/statefulset.go b/internal/manifests/collector/statefulset.go index 72b34c006d..c943acad4d 100644 --- a/internal/manifests/collector/statefulset.go +++ b/internal/manifests/collector/statefulset.go @@ -30,7 +30,10 @@ func StatefulSet(params manifests.Params) (*appsv1.StatefulSet, error) { serviceName := params.OtelCol.Spec.ServiceName if serviceName == "" { - serviceName = naming.HeadlessService(params.OtelCol.Name) + serviceName = params.OtelCol.Spec.HeadlessService.Name + if serviceName == "" { + serviceName = naming.HeadlessService(params.OtelCol.Name) + } } return &appsv1.StatefulSet{ From 48f9ab717c59101e8e742201cc240d5b621ec1b1 Mon Sep 17 00:00:00 2001 From: Kaushik Surya Date: Wed, 6 Aug 2025 19:28:59 -0400 Subject: [PATCH 2/4] Add E2E tests for configuring collector services --- .../00-assert-default.yaml | 16 +++ .../00-install-default.yaml | 25 ++++ .../01-assert-disabled.yaml | 8 ++ .../01-install-disabled.yaml | 27 ++++ .../02-assert-custom-names.yaml | 16 +++ .../02-install-custom-names.yaml | 26 ++++ .../chainsaw-test.yaml | 25 ++++ ...sert-jaeger-extension-disable-service.yaml | 117 ++++++++++++++++++ ...tall-jaeger-extension-disable-service.yaml | 32 +++++ tests/e2e/extension/chainsaw-test.yaml | 7 ++ 10 files changed, 299 insertions(+) create mode 100644 tests/e2e/collector-service-configuration/00-assert-default.yaml create mode 100644 tests/e2e/collector-service-configuration/00-install-default.yaml create mode 100644 tests/e2e/collector-service-configuration/01-assert-disabled.yaml create mode 100644 tests/e2e/collector-service-configuration/01-install-disabled.yaml create mode 100644 tests/e2e/collector-service-configuration/02-assert-custom-names.yaml create mode 100644 tests/e2e/collector-service-configuration/02-install-custom-names.yaml create mode 100644 tests/e2e/collector-service-configuration/chainsaw-test.yaml create mode 100644 tests/e2e/extension/02-assert-jaeger-extension-disable-service.yaml create mode 100644 tests/e2e/extension/02-install-jaeger-extension-disable-service.yaml diff --git a/tests/e2e/collector-service-configuration/00-assert-default.yaml b/tests/e2e/collector-service-configuration/00-assert-default.yaml new file mode 100644 index 0000000000..9609da37a0 --- /dev/null +++ b/tests/e2e/collector-service-configuration/00-assert-default.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: simplest-collector +--- +apiVersion: v1 +kind: Service +metadata: + name: simplest-collector-headless +spec: + clusterIP: None +--- +apiVersion: v1 +kind: Service +metadata: + name: simplest-collector-monitoring diff --git a/tests/e2e/collector-service-configuration/00-install-default.yaml b/tests/e2e/collector-service-configuration/00-install-default.yaml new file mode 100644 index 0000000000..59fc9faa54 --- /dev/null +++ b/tests/e2e/collector-service-configuration/00-install-default.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: chainsaw-collector-service-configuration +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: simplest +spec: + config: + receivers: + otlp: + protocols: + grpc: + http: + + exporters: + debug: + + service: + pipelines: + traces: + receivers: [otlp] + exporters: [debug] \ No newline at end of file diff --git a/tests/e2e/collector-service-configuration/01-assert-disabled.yaml b/tests/e2e/collector-service-configuration/01-assert-disabled.yaml new file mode 100644 index 0000000000..db420051cc --- /dev/null +++ b/tests/e2e/collector-service-configuration/01-assert-disabled.yaml @@ -0,0 +1,8 @@ +(x_k8s_exists($client, 'v1', 'Service', $namespace, 'simplest-disabled-collector')): false +--- +(x_k8s_exists($client, 'v1', 'Service', $namespace, 'simplest-disabled-collector-headless')): false +--- +apiVersion: v1 +kind: Service +metadata: + name: simplest-disabled-collector-monitoring diff --git a/tests/e2e/collector-service-configuration/01-install-disabled.yaml b/tests/e2e/collector-service-configuration/01-install-disabled.yaml new file mode 100644 index 0000000000..595f563ce3 --- /dev/null +++ b/tests/e2e/collector-service-configuration/01-install-disabled.yaml @@ -0,0 +1,27 @@ +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: simplest-disabled +spec: + service: + enabled: false + headlessService: + enabled: false + extensionService: + enabled: false + config: + receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + processors: + batch: {} + exporters: + debug: {} + service: + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [debug] \ No newline at end of file diff --git a/tests/e2e/collector-service-configuration/02-assert-custom-names.yaml b/tests/e2e/collector-service-configuration/02-assert-custom-names.yaml new file mode 100644 index 0000000000..7f325e208d --- /dev/null +++ b/tests/e2e/collector-service-configuration/02-assert-custom-names.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: my-custom-service +--- +apiVersion: v1 +kind: Service +metadata: + name: my-custom-headless +spec: + clusterIP: None +--- +apiVersion: v1 +kind: Service +metadata: + name: my-custom-monitoring diff --git a/tests/e2e/collector-service-configuration/02-install-custom-names.yaml b/tests/e2e/collector-service-configuration/02-install-custom-names.yaml new file mode 100644 index 0000000000..d5ad82d3df --- /dev/null +++ b/tests/e2e/collector-service-configuration/02-install-custom-names.yaml @@ -0,0 +1,26 @@ +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: simplest-custom-names +spec: + service: + name: my-custom-service + headlessService: + name: my-custom-headless + monitoringService: + name: my-custom-monitoring + config: + receivers: + otlp: + protocols: + grpc: + http: + + exporters: + debug: + + service: + pipelines: + traces: + receivers: [ otlp ] + exporters: [ debug ] \ No newline at end of file diff --git a/tests/e2e/collector-service-configuration/chainsaw-test.yaml b/tests/e2e/collector-service-configuration/chainsaw-test.yaml new file mode 100644 index 0000000000..0d12ab80e8 --- /dev/null +++ b/tests/e2e/collector-service-configuration/chainsaw-test.yaml @@ -0,0 +1,25 @@ +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: collector-service-configuration +spec: + description: Test collector service configuration functionality + steps: + - name: install-collector-default-services + try: + - apply: + file: 00-install-default.yaml + - assert: + file: 00-assert-default.yaml + - name: install-collector-disabled-services + try: + - apply: + file: 01-install-disabled.yaml + - assert: + file: 01-assert-disabled.yaml + - name: install-collector-custom-names + try: + - apply: + file: 02-install-custom-names.yaml + - assert: + file: 02-assert-custom-names.yaml \ No newline at end of file diff --git a/tests/e2e/extension/02-assert-jaeger-extension-disable-service.yaml b/tests/e2e/extension/02-assert-jaeger-extension-disable-service.yaml new file mode 100644 index 0000000000..77feb14c17 --- /dev/null +++ b/tests/e2e/extension/02-assert-jaeger-extension-disable-service.yaml @@ -0,0 +1,117 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: jaeger-inmemory-disable-service-collector +spec: + template: + spec: + containers: + - ports: + - containerPort: 16686 + name: jaeger-query + protocol: TCP + - containerPort: 8888 + name: metrics + protocol: TCP + - containerPort: 4317 + name: otlp-grpc + protocol: TCP + - containerPort: 4318 + name: otlp-http + protocol: TCP +status: + readyReplicas: 1 +--- +apiVersion: v1 +kind: Service +metadata: + name: jaeger-inmemory-disable-service-collector +spec: + ports: + - appProtocol: grpc + name: otlp-grpc + port: 4317 + protocol: TCP + targetPort: 4317 + - appProtocol: http + name: otlp-http + port: 4318 + protocol: TCP + targetPort: 4318 +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + service.beta.openshift.io/serving-cert-secret-name: jaeger-inmemory-disable-service-collector-headless-tls + labels: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/name: jaeger-inmemory-disable-service-collector + app.kubernetes.io/part-of: opentelemetry + app.kubernetes.io/version: latest + operator.opentelemetry.io/collector-headless-service: Exists + operator.opentelemetry.io/collector-service-type: headless + name: jaeger-inmemory-disable-service-collector-headless + ownerReferences: + - apiVersion: opentelemetry.io/v1beta1 + blockOwnerDeletion: true + controller: true + kind: OpenTelemetryCollector + name: jaeger-inmemory-disable-service +spec: + clusterIP: None + clusterIPs: + - None + internalTrafficPolicy: Cluster + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack + ports: + - appProtocol: grpc + name: otlp-grpc + port: 4317 + protocol: TCP + targetPort: 4317 + - appProtocol: http + name: otlp-http + port: 4318 + protocol: TCP + targetPort: 4318 + selector: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/part-of: opentelemetry + sessionAffinity: None + type: ClusterIP +status: + loadBalancer: {} +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/name: jaeger-inmemory-disable-service-collector-monitoring + app.kubernetes.io/part-of: opentelemetry + app.kubernetes.io/version: latest + operator.opentelemetry.io/collector-monitoring-service: Exists + operator.opentelemetry.io/collector-service-type: monitoring + name: jaeger-inmemory-disable-service-collector-monitoring +spec: + ports: + - name: monitoring + port: 8888 + protocol: TCP + targetPort: 8888 + selector: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/part-of: opentelemetry + sessionAffinity: None + type: ClusterIP +status: + loadBalancer: {} +--- +(x_k8s_exists($client, 'v1', 'Service', $namespace, 'jaeger-inmemory-disable-service-collector-extension')): false diff --git a/tests/e2e/extension/02-install-jaeger-extension-disable-service.yaml b/tests/e2e/extension/02-install-jaeger-extension-disable-service.yaml new file mode 100644 index 0000000000..54a642794b --- /dev/null +++ b/tests/e2e/extension/02-install-jaeger-extension-disable-service.yaml @@ -0,0 +1,32 @@ +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: jaeger-inmemory-disable-service +spec: + image: jaegertracing/jaeger:latest + extensionService: + enabled: false + config: + service: + extensions: [jaeger_storage, jaeger_query] + pipelines: + traces: + receivers: [otlp] + exporters: [jaeger_storage_exporter] + extensions: + jaeger_query: + storage: + traces: memstore + jaeger_storage: + backends: + memstore: + memory: + max_traces: 100000 + receivers: + otlp: + protocols: + grpc: + http: + exporters: + jaeger_storage_exporter: + trace_storage: memstore diff --git a/tests/e2e/extension/chainsaw-test.yaml b/tests/e2e/extension/chainsaw-test.yaml index d7423b0086..a4e73c5d7e 100644 --- a/tests/e2e/extension/chainsaw-test.yaml +++ b/tests/e2e/extension/chainsaw-test.yaml @@ -20,3 +20,10 @@ spec: file: 01-install-health-check-extension.yaml - assert: file: 01-assert-health-check-extension.yaml + - name: step-02 + description: health check extension + try: + - apply: + file: 02-install-jaeger-extension-disable-service.yaml + - assert: + file: 02-assert-jaeger-extension-disable-service.yaml From ec2bfc3eef11101bc76a741b50e75b462f9ba7d6 Mon Sep 17 00:00:00 2001 From: Kaushik Surya Date: Thu, 7 Aug 2025 17:20:24 -0400 Subject: [PATCH 3/4] Remove changes to v1alpha1 --- apis/v1alpha1/convert.go | 32 +--- apis/v1alpha1/opentelemetrycollector_types.go | 33 ---- apis/v1alpha1/zz_generated.deepcopy.go | 24 --- ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 28 --- ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 28 --- ...ntelemetry.io_opentelemetrycollectors.yaml | 28 --- docs/api/opentelemetrycollectors.md | 176 +----------------- 9 files changed, 11 insertions(+), 342 deletions(-) diff --git a/apis/v1alpha1/convert.go b/apis/v1alpha1/convert.go index 76cd716e7d..87a2da9f1c 100644 --- a/apis/v1alpha1/convert.go +++ b/apis/v1alpha1/convert.go @@ -103,15 +103,11 @@ func tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error StatefulSetCommonFields: v1beta1.StatefulSetCommonFields{ VolumeClaimTemplates: copy.Spec.VolumeClaimTemplates, }, - Autoscaler: tov1beta1Autoscaler(copy.Spec.Autoscaler, copy.Spec.MinReplicas, copy.Spec.MaxReplicas), - TargetAllocator: tov1beta1TA(copy.Spec.TargetAllocator), - Mode: v1beta1.Mode(copy.Spec.Mode), - UpgradeStrategy: v1beta1.UpgradeStrategy(copy.Spec.UpgradeStrategy), - Config: *cfg, - Service: tov1beta1ServiceSpec(copy.Spec.Service), - HeadlessService: tov1beta1ServiceSpec(copy.Spec.HeadlessService), - MonitoringService: tov1beta1ServiceSpec(copy.Spec.MonitoringService), - ExtensionService: tov1beta1ServiceSpec(copy.Spec.ExtensionService), + Autoscaler: tov1beta1Autoscaler(copy.Spec.Autoscaler, copy.Spec.MinReplicas, copy.Spec.MaxReplicas), + TargetAllocator: tov1beta1TA(copy.Spec.TargetAllocator), + Mode: v1beta1.Mode(copy.Spec.Mode), + UpgradeStrategy: v1beta1.UpgradeStrategy(copy.Spec.UpgradeStrategy), + Config: *cfg, Ingress: v1beta1.Ingress{ Type: v1beta1.IngressType(copy.Spec.Ingress.Type), RuleType: v1beta1.IngressRuleType(copy.Spec.Ingress.RuleType), @@ -254,13 +250,6 @@ func tov1beta1Probe(in *Probe) *v1beta1.Probe { } } -func tov1beta1ServiceSpec(in ServiceSpec) v1beta1.ServiceSpec { - return v1beta1.ServiceSpec{ - Enabled: in.Enabled, - Name: in.Name, - } -} - func tov1beta1ConfigMaps(in []ConfigMapsSpec) []v1beta1.ConfigMapsSpec { var mapsSpecs []v1beta1.ConfigMapsSpec for _, m := range in { @@ -347,10 +336,6 @@ func tov1alpha1(in v1beta1.OpenTelemetryCollector) (*OpenTelemetryCollector, err Termination: TLSRouteTerminationType(copy.Spec.Ingress.Route.Termination), }, }, - Service: tov1alpha1ServiceSpec(copy.Spec.Service), - HeadlessService: tov1alpha1ServiceSpec(copy.Spec.HeadlessService), - MonitoringService: tov1alpha1ServiceSpec(copy.Spec.MonitoringService), - ExtensionService: tov1alpha1ServiceSpec(copy.Spec.ExtensionService), HostNetwork: copy.Spec.HostNetwork, ShareProcessNamespace: copy.Spec.ShareProcessNamespace, PriorityClassName: copy.Spec.PriorityClassName, @@ -398,13 +383,6 @@ func tov1alpha1Probe(in *v1beta1.Probe) *Probe { } } -func tov1alpha1ServiceSpec(in v1beta1.ServiceSpec) ServiceSpec { - return ServiceSpec{ - Enabled: in.Enabled, - Name: in.Name, - } -} - func tov1alpha1Autoscaler(in *v1beta1.AutoscalerSpec) *AutoscalerSpec { if in == nil { return nil diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go index db95a02778..5a466137a8 100644 --- a/apis/v1alpha1/opentelemetrycollector_types.go +++ b/apis/v1alpha1/opentelemetrycollector_types.go @@ -239,22 +239,6 @@ type OpenTelemetryCollectorSpec struct { // +optional ServiceName string `json:"serviceName,omitempty"` - // Service to override configuration of the generated Collector Service. - // +optional - Service ServiceSpec `json:"service,omitempty"` - - // HeadlessService to override configuration of the generated Collector HeadlessService. - // +optional - HeadlessService ServiceSpec `json:"headlessService,omitempty"` - - // MonitoringService to override configuration of the generated Collector MonitoringService. - // +optional - MonitoringService ServiceSpec `json:"monitoringService,omitempty"` - - // ExtensionService to override configuration of the generated Collector ExtensionService. - // +optional - ExtensionService ServiceSpec `json:"extensionService,omitempty"` - // AdditionalContainers allows injecting additional containers into the Collector's pod definition. // These sidecar containers can be used for authentication proxies, log shipping sidecars, agents for shipping // metrics to their cloud, or in general sidecars that do not support automatic injection. This option only @@ -616,20 +600,3 @@ type ConfigMapsSpec struct { func init() { SchemeBuilder.Register(&OpenTelemetryCollector{}, &OpenTelemetryCollectorList{}) } - -type ServiceSpec struct { - // Enabled indicates whether the Service should be created. - // nil means not set (defaults to enabled for backward compatibility) - // +optional - Enabled *bool `json:"enabled,omitempty"` - - // Name to override the default Service name - // +optional - Name string `json:"name,omitempty"` -} - -// IsEnabled returns true if the service should be created. -// nil (not set) defaults to true for backward compatibility. -func (s *ServiceSpec) IsEnabled() bool { - return s.Enabled == nil || *s.Enabled -} diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index 1616ffe0de..d2add49fda 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -973,10 +973,6 @@ func (in *OpenTelemetryCollectorSpec) DeepCopyInto(out *OpenTelemetryCollectorSp (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.Service.DeepCopyInto(&out.Service) - in.HeadlessService.DeepCopyInto(&out.HeadlessService) - in.MonitoringService.DeepCopyInto(&out.MonitoringService) - in.ExtensionService.DeepCopyInto(&out.ExtensionService) if in.AdditionalContainers != nil { in, out := &in.AdditionalContainers, &out.AdditionalContainers *out = make([]v1.Container, len(*in)) @@ -1304,26 +1300,6 @@ func (in *ScaleSubresourceStatus) DeepCopy() *ScaleSubresourceStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. -func (in *ServiceSpec) DeepCopy() *ServiceSpec { - if in == nil { - return nil - } - out := new(ServiceSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TLS) DeepCopyInto(out *TLS) { *out = *in diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index eac4d5409d..d2e32f10d4 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2025-08-06T20:58:08Z" + createdAt: "2025-08-07T21:06:48Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 662515ea44..bccbe7774a 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -1454,20 +1454,6 @@ spec: x-kubernetes-map-type: atomic type: object type: array - extensionService: - properties: - enabled: - type: boolean - name: - type: string - type: object - headlessService: - properties: - enabled: - type: boolean - name: - type: string - type: object hostNetwork: type: boolean image: @@ -2360,13 +2346,6 @@ spec: - sidecar - statefulset type: string - monitoringService: - properties: - enabled: - type: boolean - name: - type: string - type: object nodeSelector: additionalProperties: type: string @@ -2617,13 +2596,6 @@ spec: type: string type: object type: object - service: - properties: - enabled: - type: boolean - name: - type: string - type: object serviceAccount: type: string serviceName: diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index cb153a2be0..3e072f5df1 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2025-08-06T20:58:09Z" + createdAt: "2025-08-07T21:07:12Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 662515ea44..bccbe7774a 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -1454,20 +1454,6 @@ spec: x-kubernetes-map-type: atomic type: object type: array - extensionService: - properties: - enabled: - type: boolean - name: - type: string - type: object - headlessService: - properties: - enabled: - type: boolean - name: - type: string - type: object hostNetwork: type: boolean image: @@ -2360,13 +2346,6 @@ spec: - sidecar - statefulset type: string - monitoringService: - properties: - enabled: - type: boolean - name: - type: string - type: object nodeSelector: additionalProperties: type: string @@ -2617,13 +2596,6 @@ spec: type: string type: object type: object - service: - properties: - enabled: - type: boolean - name: - type: string - type: object serviceAccount: type: string serviceName: diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 7afbde0725..8e176dad01 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -1440,20 +1440,6 @@ spec: x-kubernetes-map-type: atomic type: object type: array - extensionService: - properties: - enabled: - type: boolean - name: - type: string - type: object - headlessService: - properties: - enabled: - type: boolean - name: - type: string - type: object hostNetwork: type: boolean image: @@ -2346,13 +2332,6 @@ spec: - sidecar - statefulset type: string - monitoringService: - properties: - enabled: - type: boolean - name: - type: string - type: object nodeSelector: additionalProperties: type: string @@ -2603,13 +2582,6 @@ spec: type: string type: object type: object - service: - properties: - enabled: - type: boolean - name: - type: string - type: object serviceAccount: type: string serviceName: diff --git a/docs/api/opentelemetrycollectors.md b/docs/api/opentelemetrycollectors.md index d06b0f0dc8..94b7a7e22a 100644 --- a/docs/api/opentelemetrycollectors.md +++ b/docs/api/opentelemetrycollectors.md @@ -176,20 +176,6 @@ consumed in the config file for the Collector.
    These can then in certain cases be consumed in the config file for the Collector.
    false - - extensionService - object - - ExtensionService to override configuration of the generated Collector ExtensionService.
    - - false - - headlessService - object - - HeadlessService to override configuration of the generated Collector HeadlessService.
    - - false hostNetwork boolean @@ -275,13 +261,6 @@ Deprecated: use "OpenTelemetryCollector.Spec.Autoscaler.MinReplicas" instead.
    Enum: daemonset, deployment, sidecar, statefulset
    false - - monitoringService - object - - MonitoringService to override configuration of the generated Collector MonitoringService.
    - - false nodeSelector map[string]string @@ -374,13 +353,6 @@ In sidecar mode, this controls the security context for the injected sidecar container.
    false - - service - object - - Service to override configuration of the generated Collector Service.
    - - false serviceAccount string @@ -6086,76 +6058,6 @@ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/nam -### OpenTelemetryCollector.spec.extensionService -[↩ Parent](#opentelemetrycollectorspec) - - - -ExtensionService to override configuration of the generated Collector ExtensionService. - - - - - - - - - - - - - - - - - - - - - -
    NameTypeDescriptionRequired
    enabledboolean - Enabled indicates whether the Service should be created. -nil means not set (defaults to enabled for backward compatibility)
    -
    false
    namestring - Name to override the default Service name
    -
    false
    - - -### OpenTelemetryCollector.spec.headlessService -[↩ Parent](#opentelemetrycollectorspec) - - - -HeadlessService to override configuration of the generated Collector HeadlessService. - - - - - - - - - - - - - - - - - - - - - -
    NameTypeDescriptionRequired
    enabledboolean - Enabled indicates whether the Service should be created. -nil means not set (defaults to enabled for backward compatibility)
    -
    false
    namestring - Name to override the default Service name
    -
    false
    - - ### OpenTelemetryCollector.spec.ingress [↩ Parent](#opentelemetrycollectorspec) @@ -9832,41 +9734,6 @@ More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#cont -### OpenTelemetryCollector.spec.monitoringService -[↩ Parent](#opentelemetrycollectorspec) - - - -MonitoringService to override configuration of the generated Collector MonitoringService. - - - - - - - - - - - - - - - - - - - - - -
    NameTypeDescriptionRequired
    enabledboolean - Enabled indicates whether the Service should be created. -nil means not set (defaults to enabled for backward compatibility)
    -
    false
    namestring - Name to override the default Service name
    -
    false
    - - ### OpenTelemetryCollector.spec.observability [↩ Parent](#opentelemetrycollectorspec) @@ -10984,41 +10851,6 @@ PodSecurityContext, the value specified in SecurityContext takes precedence.
    -### OpenTelemetryCollector.spec.service -[↩ Parent](#opentelemetrycollectorspec) - - - -Service to override configuration of the generated Collector Service. - - - - - - - - - - - - - - - - - - - - - -
    NameTypeDescriptionRequired
    enabledboolean - Enabled indicates whether the Service should be created. -nil means not set (defaults to enabled for backward compatibility)
    -
    false
    namestring - Name to override the default Service name
    -
    false
    - - ### OpenTelemetryCollector.spec.targetAllocator [↩ Parent](#opentelemetrycollectorspec) @@ -19707,14 +19539,14 @@ This is only applicable to Deployment mode.
    false - extensionService + extensionService object ExtensionService to override configuration of the generated Collector ExtensionService.
    false - headlessService + headlessService object HeadlessService to override configuration of the generated Collector HeadlessService.
    @@ -19814,7 +19646,7 @@ Default is managed.
    false - monitoringService + monitoringService object MonitoringService to override configuration of the generated Collector MonitoringService.
    @@ -19937,7 +19769,7 @@ injected sidecar container.
    false - service + service object Service to override configuration of the generated Collector Service.
    From 2e945c2c88437af2d2e596d36ed2702bff455403 Mon Sep 17 00:00:00 2001 From: Kaushik Surya Date: Tue, 9 Sep 2025 12:26:30 -0400 Subject: [PATCH 4/4] Merge from main --- ...ntelemetry.io_opentelemetrycollectors.yaml | 8 +- internal/controllers/builder_test.go | 80 +++++++++---------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 77bb07b770..08359c8623 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -6956,17 +6956,17 @@ spec: - sidecar - statefulset type: string - networkPolicy: + monitoringService: properties: enabled: type: boolean + name: + type: string type: object - monitoringService: + networkPolicy: properties: enabled: type: boolean - name: - type: string type: object nodeSelector: additionalProperties: diff --git a/internal/controllers/builder_test.go b/internal/controllers/builder_test.go index e2806a82a1..7abe0916fe 100644 --- a/internal/controllers/builder_test.go +++ b/internal/controllers/builder_test.go @@ -285,6 +285,46 @@ service: Annotations: map[string]string{}, }, }, + &networkingv1.NetworkPolicy{ + ObjectMeta: v1.ObjectMeta{ + Name: "test-collector-networkpolicy", + Namespace: "test", + Labels: map[string]string{ + "app.kubernetes.io/component": "opentelemetry-collector", + "app.kubernetes.io/instance": "test.test", + "app.kubernetes.io/managed-by": "opentelemetry-operator", + "app.kubernetes.io/name": "test-collector-networkpolicy", + "app.kubernetes.io/part-of": "opentelemetry", + "app.kubernetes.io/version": "latest", + }, + Annotations: map[string]string{}, + }, + Spec: networkingv1.NetworkPolicySpec{ + PodSelector: metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app.kubernetes.io/component": "opentelemetry-collector", + "app.kubernetes.io/instance": "test.test", + "app.kubernetes.io/managed-by": "opentelemetry-operator", + "app.kubernetes.io/part-of": "opentelemetry", + }, + }, + Ingress: []networkingv1.NetworkPolicyIngressRule{ + { + Ports: []networkingv1.NetworkPolicyPort{ + { + Protocol: &tcp, + Port: &intstr.IntOrString{Type: intstr.Int, IntVal: 12345}, + }, + { + Protocol: &tcp, + Port: &intstr.IntOrString{Type: intstr.Int, IntVal: 8888}, + }, + }, + }, + }, + PolicyTypes: []networkingv1.PolicyType{networkingv1.PolicyTypeIngress}, + }, + }, &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "test-collector", @@ -367,46 +407,6 @@ service: Selector: selectorLabels, }, }, - &networkingv1.NetworkPolicy{ - ObjectMeta: v1.ObjectMeta{ - Name: "test-collector-networkpolicy", - Namespace: "test", - Labels: map[string]string{ - "app.kubernetes.io/component": "opentelemetry-collector", - "app.kubernetes.io/instance": "test.test", - "app.kubernetes.io/managed-by": "opentelemetry-operator", - "app.kubernetes.io/name": "test-collector-networkpolicy", - "app.kubernetes.io/part-of": "opentelemetry", - "app.kubernetes.io/version": "latest", - }, - Annotations: map[string]string{}, - }, - Spec: networkingv1.NetworkPolicySpec{ - PodSelector: metav1.LabelSelector{ - MatchLabels: map[string]string{ - "app.kubernetes.io/component": "opentelemetry-collector", - "app.kubernetes.io/instance": "test.test", - "app.kubernetes.io/managed-by": "opentelemetry-operator", - "app.kubernetes.io/part-of": "opentelemetry", - }, - }, - Ingress: []networkingv1.NetworkPolicyIngressRule{ - { - Ports: []networkingv1.NetworkPolicyPort{ - { - Protocol: &tcp, - Port: &intstr.IntOrString{Type: intstr.Int, IntVal: 12345}, - }, - { - Protocol: &tcp, - Port: &intstr.IntOrString{Type: intstr.Int, IntVal: 8888}, - }, - }, - }, - }, - PolicyTypes: []networkingv1.PolicyType{networkingv1.PolicyTypeIngress}, - }, - }, }, wantErr: false, },