diff --git a/apis/v1beta1/common.go b/apis/common/common.go
similarity index 89%
rename from apis/v1beta1/common.go
rename to apis/common/common.go
index d4c421553d..c842d24457 100644
--- a/apis/v1beta1/common.go
+++ b/apis/common/common.go
@@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package v1beta1
+// +kubebuilder:object:generate=true
+// +groupName=opentelemetry.io
+package common
import (
autoscalingv2 "k8s.io/api/autoscaling/v2"
@@ -94,6 +96,33 @@ type PortsSpec struct {
v1.ServicePort `json:",inline"`
}
+// ObservabilitySpec defines how telemetry data gets handled.
+type ObservabilitySpec struct {
+ // Metrics defines the metrics configuration for operands.
+ //
+ // +optional
+ // +kubebuilder:validation:Optional
+ // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Metrics Config"
+ Metrics MetricsConfigSpec `json:"metrics,omitempty"`
+}
+
+// MetricsConfigSpec defines a metrics config.
+type MetricsConfigSpec struct {
+ // EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar mode) should be created for the service managed by the OpenTelemetry Operator.
+ // The operator.observability.prometheus feature gate must be enabled to use this feature.
+ //
+ // +optional
+ // +kubebuilder:validation:Optional
+ // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Create ServiceMonitors for OpenTelemetry Collector"
+ EnableMetrics bool `json:"enableMetrics,omitempty"`
+ // DisablePrometheusAnnotations controls the automatic addition of default Prometheus annotations
+ // ('prometheus.io/scrape', 'prometheus.io/port', and 'prometheus.io/path')
+ //
+ // +optional
+ // +kubebuilder:validation:Optional
+ DisablePrometheusAnnotations bool `json:"disablePrometheusAnnotations,omitempty"`
+}
+
type OpenTelemetryCommonFields struct {
// ManagementState defines if the CR should be managed by the operator or not.
// Default is managed.
diff --git a/apis/v1beta1/config.go b/apis/common/config.go
similarity index 99%
rename from apis/v1beta1/config.go
rename to apis/common/config.go
index 61f166b0f3..d168b7a059 100644
--- a/apis/v1beta1/config.go
+++ b/apis/common/config.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package v1beta1
+package common
import (
"bytes"
@@ -102,7 +102,7 @@ func (c *Config) Yaml() (string, error) {
}
// Returns null objects in the config.
-func (c *Config) nullObjects() []string {
+func (c *Config) NullObjects() []string {
var nullKeys []string
if nulls := hasNullValue(c.Receivers.Object); len(nulls) > 0 {
nullKeys = append(nullKeys, addPrefix("receivers.", nulls)...)
diff --git a/apis/v1beta1/config_test.go b/apis/common/config_test.go
similarity index 98%
rename from apis/v1beta1/config_test.go
rename to apis/common/config_test.go
index cf148c5d91..cebab64354 100644
--- a/apis/v1beta1/config_test.go
+++ b/apis/common/config_test.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package v1beta1
+package common
import (
"encoding/json"
@@ -69,7 +69,7 @@ func TestNullObjects(t *testing.T) {
err = json.Unmarshal(collectorJson, cfg)
require.NoError(t, err)
- nullObjects := cfg.nullObjects()
+ nullObjects := cfg.NullObjects()
assert.Equal(t, []string{"connectors.spanmetrics:", "exporters.otlp.endpoint:", "extensions.health_check:", "processors.batch:", "receivers.otlp.protocols.grpc:", "receivers.otlp.protocols.http:"}, nullObjects)
}
@@ -107,7 +107,7 @@ func TestNullObjects_go_yaml(t *testing.T) {
err = go_yaml.Unmarshal(collectorYaml, cfg)
require.NoError(t, err)
- nullObjects := cfg.nullObjects()
+ nullObjects := cfg.NullObjects()
assert.Equal(t, []string{"connectors.spanmetrics:", "exporters.otlp.endpoint:", "extensions.health_check:", "processors.batch:", "receivers.otlp.protocols.grpc:", "receivers.otlp.protocols.http:"}, nullObjects)
}
diff --git a/apis/common/targetallocator_types.go b/apis/common/targetallocator_types.go
new file mode 100644
index 0000000000..61c32a2373
--- /dev/null
+++ b/apis/common/targetallocator_types.go
@@ -0,0 +1,64 @@
+// Copyright The OpenTelemetry Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package common
+
+import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+type (
+ // TargetAllocatorAllocationStrategy represent a strategy Target Allocator uses to distribute targets to each collector
+ // +kubebuilder:validation:Enum=least-weighted;consistent-hashing;per-node
+ TargetAllocatorAllocationStrategy string
+ // TargetAllocatorFilterStrategy represent a filtering strategy for targets before they are assigned to collectors
+ // +kubebuilder:validation:Enum="";relabel-config
+ TargetAllocatorFilterStrategy string
+)
+
+const (
+ // TargetAllocatorAllocationStrategyLeastWeighted targets will be distributed to collector with fewer targets currently assigned.
+ TargetAllocatorAllocationStrategyLeastWeighted TargetAllocatorAllocationStrategy = "least-weighted"
+
+ // TargetAllocatorAllocationStrategyConsistentHashing targets will be consistently added to collectors, which allows a high-availability setup.
+ TargetAllocatorAllocationStrategyConsistentHashing TargetAllocatorAllocationStrategy = "consistent-hashing"
+
+ // TargetAllocatorAllocationStrategyPerNode targets will be assigned to the collector on the node they reside on (use only with daemon set).
+ TargetAllocatorAllocationStrategyPerNode TargetAllocatorAllocationStrategy = "per-node"
+
+ // TargetAllocatorFilterStrategyRelabelConfig targets will be consistently drops targets based on the relabel_config.
+ TargetAllocatorFilterStrategyRelabelConfig TargetAllocatorFilterStrategy = "relabel-config"
+)
+
+// TargetAllocatorPrometheusCR configures Prometheus CustomResource handling in the Target Allocator.
+type TargetAllocatorPrometheusCR struct {
+ // Enabled indicates whether to use a PrometheusOperator custom resources as targets or not.
+ // +optional
+ Enabled bool `json:"enabled,omitempty"`
+ // Default interval between consecutive scrapes. Intervals set in ServiceMonitors and PodMonitors override it.
+ //Equivalent to the same setting on the Prometheus CR.
+ //
+ // Default: "30s"
+ // +kubebuilder:default:="30s"
+ // +kubebuilder:validation:Format:=duration
+ ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"`
+ // PodMonitors to be selected for target discovery.
+ // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
+ // PodMonitor's meta labels. The requirements are ANDed.
+ // +optional
+ PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"`
+ // ServiceMonitors to be selected for target discovery.
+ // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
+ // ServiceMonitor's meta labels. The requirements are ANDed.
+ // +optional
+ ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"`
+}
diff --git a/apis/v1beta1/testdata/otelcol-connectors.yaml b/apis/common/testdata/otelcol-connectors.yaml
similarity index 100%
rename from apis/v1beta1/testdata/otelcol-connectors.yaml
rename to apis/common/testdata/otelcol-connectors.yaml
diff --git a/apis/v1beta1/testdata/otelcol-couchbase.yaml b/apis/common/testdata/otelcol-couchbase.yaml
similarity index 100%
rename from apis/v1beta1/testdata/otelcol-couchbase.yaml
rename to apis/common/testdata/otelcol-couchbase.yaml
diff --git a/apis/v1beta1/testdata/otelcol-demo.yaml b/apis/common/testdata/otelcol-demo.yaml
similarity index 100%
rename from apis/v1beta1/testdata/otelcol-demo.yaml
rename to apis/common/testdata/otelcol-demo.yaml
diff --git a/apis/v1beta1/testdata/otelcol-extensions.yaml b/apis/common/testdata/otelcol-extensions.yaml
similarity index 100%
rename from apis/v1beta1/testdata/otelcol-extensions.yaml
rename to apis/common/testdata/otelcol-extensions.yaml
diff --git a/apis/v1beta1/testdata/otelcol-filelog.yaml b/apis/common/testdata/otelcol-filelog.yaml
similarity index 100%
rename from apis/v1beta1/testdata/otelcol-filelog.yaml
rename to apis/common/testdata/otelcol-filelog.yaml
diff --git a/apis/v1beta1/testdata/otelcol-null-values.yaml b/apis/common/testdata/otelcol-null-values.yaml
similarity index 100%
rename from apis/v1beta1/testdata/otelcol-null-values.yaml
rename to apis/common/testdata/otelcol-null-values.yaml
diff --git a/apis/common/zz_generated.deepcopy.go b/apis/common/zz_generated.deepcopy.go
new file mode 100644
index 0000000000..90602be6cf
--- /dev/null
+++ b/apis/common/zz_generated.deepcopy.go
@@ -0,0 +1,448 @@
+//go:build !ignore_autogenerated
+
+// Copyright The OpenTelemetry Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Code generated by controller-gen. DO NOT EDIT.
+
+package common
+
+import (
+ "k8s.io/api/autoscaling/v2"
+ "k8s.io/api/core/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *AutoscalerSpec) DeepCopyInto(out *AutoscalerSpec) {
+ *out = *in
+ if in.MinReplicas != nil {
+ in, out := &in.MinReplicas, &out.MinReplicas
+ *out = new(int32)
+ **out = **in
+ }
+ if in.MaxReplicas != nil {
+ in, out := &in.MaxReplicas, &out.MaxReplicas
+ *out = new(int32)
+ **out = **in
+ }
+ if in.Behavior != nil {
+ in, out := &in.Behavior, &out.Behavior
+ *out = new(v2.HorizontalPodAutoscalerBehavior)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Metrics != nil {
+ in, out := &in.Metrics, &out.Metrics
+ *out = make([]MetricSpec, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.TargetCPUUtilization != nil {
+ in, out := &in.TargetCPUUtilization, &out.TargetCPUUtilization
+ *out = new(int32)
+ **out = **in
+ }
+ if in.TargetMemoryUtilization != nil {
+ in, out := &in.TargetMemoryUtilization, &out.TargetMemoryUtilization
+ *out = new(int32)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoscalerSpec.
+func (in *AutoscalerSpec) DeepCopy() *AutoscalerSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(AutoscalerSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *Config) DeepCopyInto(out *Config) {
+ *out = *in
+ in.Receivers.DeepCopyInto(&out.Receivers)
+ in.Exporters.DeepCopyInto(&out.Exporters)
+ if in.Processors != nil {
+ in, out := &in.Processors, &out.Processors
+ *out = (*in).DeepCopy()
+ }
+ if in.Connectors != nil {
+ in, out := &in.Connectors, &out.Connectors
+ *out = (*in).DeepCopy()
+ }
+ if in.Extensions != nil {
+ in, out := &in.Extensions, &out.Extensions
+ *out = (*in).DeepCopy()
+ }
+ in.Service.DeepCopyInto(&out.Service)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config.
+func (in *Config) DeepCopy() *Config {
+ if in == nil {
+ return nil
+ }
+ out := new(Config)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *MetricSpec) DeepCopyInto(out *MetricSpec) {
+ *out = *in
+ if in.Pods != nil {
+ in, out := &in.Pods, &out.Pods
+ *out = new(v2.PodsMetricSource)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricSpec.
+func (in *MetricSpec) DeepCopy() *MetricSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(MetricSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *MetricsConfig) DeepCopyInto(out *MetricsConfig) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsConfig.
+func (in *MetricsConfig) DeepCopy() *MetricsConfig {
+ if in == nil {
+ return nil
+ }
+ out := new(MetricsConfig)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *MetricsConfigSpec) DeepCopyInto(out *MetricsConfigSpec) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsConfigSpec.
+func (in *MetricsConfigSpec) DeepCopy() *MetricsConfigSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(MetricsConfigSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ObservabilitySpec) DeepCopyInto(out *ObservabilitySpec) {
+ *out = *in
+ out.Metrics = in.Metrics
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObservabilitySpec.
+func (in *ObservabilitySpec) DeepCopy() *ObservabilitySpec {
+ if in == nil {
+ return nil
+ }
+ out := new(ObservabilitySpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *OpenTelemetryCommonFields) DeepCopyInto(out *OpenTelemetryCommonFields) {
+ *out = *in
+ in.Resources.DeepCopyInto(&out.Resources)
+ if in.NodeSelector != nil {
+ in, out := &in.NodeSelector, &out.NodeSelector
+ *out = make(map[string]string, len(*in))
+ for key, val := range *in {
+ (*out)[key] = val
+ }
+ }
+ if in.Args != nil {
+ in, out := &in.Args, &out.Args
+ *out = make(map[string]string, len(*in))
+ for key, val := range *in {
+ (*out)[key] = val
+ }
+ }
+ if in.Replicas != nil {
+ in, out := &in.Replicas, &out.Replicas
+ *out = new(int32)
+ **out = **in
+ }
+ if in.Autoscaler != nil {
+ in, out := &in.Autoscaler, &out.Autoscaler
+ *out = new(AutoscalerSpec)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.PodDisruptionBudget != nil {
+ in, out := &in.PodDisruptionBudget, &out.PodDisruptionBudget
+ *out = new(PodDisruptionBudgetSpec)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.SecurityContext != nil {
+ in, out := &in.SecurityContext, &out.SecurityContext
+ *out = new(v1.SecurityContext)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.PodSecurityContext != nil {
+ in, out := &in.PodSecurityContext, &out.PodSecurityContext
+ *out = new(v1.PodSecurityContext)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.PodAnnotations != nil {
+ in, out := &in.PodAnnotations, &out.PodAnnotations
+ *out = make(map[string]string, len(*in))
+ for key, val := range *in {
+ (*out)[key] = val
+ }
+ }
+ if in.VolumeMounts != nil {
+ in, out := &in.VolumeMounts, &out.VolumeMounts
+ *out = make([]v1.VolumeMount, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.Ports != nil {
+ in, out := &in.Ports, &out.Ports
+ *out = make([]PortsSpec, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.Env != nil {
+ in, out := &in.Env, &out.Env
+ *out = make([]v1.EnvVar, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.EnvFrom != nil {
+ in, out := &in.EnvFrom, &out.EnvFrom
+ *out = make([]v1.EnvFromSource, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.VolumeClaimTemplates != nil {
+ in, out := &in.VolumeClaimTemplates, &out.VolumeClaimTemplates
+ *out = make([]v1.PersistentVolumeClaim, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.Tolerations != nil {
+ in, out := &in.Tolerations, &out.Tolerations
+ *out = make([]v1.Toleration, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.Volumes != nil {
+ in, out := &in.Volumes, &out.Volumes
+ *out = make([]v1.Volume, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.Affinity != nil {
+ in, out := &in.Affinity, &out.Affinity
+ *out = new(v1.Affinity)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Lifecycle != nil {
+ in, out := &in.Lifecycle, &out.Lifecycle
+ *out = new(v1.Lifecycle)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.TerminationGracePeriodSeconds != nil {
+ in, out := &in.TerminationGracePeriodSeconds, &out.TerminationGracePeriodSeconds
+ *out = new(int64)
+ **out = **in
+ }
+ if in.TopologySpreadConstraints != nil {
+ in, out := &in.TopologySpreadConstraints, &out.TopologySpreadConstraints
+ *out = make([]v1.TopologySpreadConstraint, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.InitContainers != nil {
+ in, out := &in.InitContainers, &out.InitContainers
+ *out = make([]v1.Container, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.AdditionalContainers != nil {
+ in, out := &in.AdditionalContainers, &out.AdditionalContainers
+ *out = make([]v1.Container, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenTelemetryCommonFields.
+func (in *OpenTelemetryCommonFields) DeepCopy() *OpenTelemetryCommonFields {
+ if in == nil {
+ return nil
+ }
+ out := new(OpenTelemetryCommonFields)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *PodDisruptionBudgetSpec) DeepCopyInto(out *PodDisruptionBudgetSpec) {
+ *out = *in
+ if in.MinAvailable != nil {
+ in, out := &in.MinAvailable, &out.MinAvailable
+ *out = new(intstr.IntOrString)
+ **out = **in
+ }
+ if in.MaxUnavailable != nil {
+ in, out := &in.MaxUnavailable, &out.MaxUnavailable
+ *out = new(intstr.IntOrString)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodDisruptionBudgetSpec.
+func (in *PodDisruptionBudgetSpec) DeepCopy() *PodDisruptionBudgetSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(PodDisruptionBudgetSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *PortsSpec) DeepCopyInto(out *PortsSpec) {
+ *out = *in
+ in.ServicePort.DeepCopyInto(&out.ServicePort)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortsSpec.
+func (in *PortsSpec) DeepCopy() *PortsSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(PortsSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *Service) DeepCopyInto(out *Service) {
+ *out = *in
+ if in.Extensions != nil {
+ in, out := &in.Extensions, &out.Extensions
+ *out = new([]string)
+ if **in != nil {
+ in, out := *in, *out
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ }
+ if in.Telemetry != nil {
+ in, out := &in.Telemetry, &out.Telemetry
+ *out = (*in).DeepCopy()
+ }
+ in.Pipelines.DeepCopyInto(&out.Pipelines)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Service.
+func (in *Service) DeepCopy() *Service {
+ if in == nil {
+ return nil
+ }
+ out := new(Service)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *TargetAllocatorPrometheusCR) DeepCopyInto(out *TargetAllocatorPrometheusCR) {
+ *out = *in
+ if in.ScrapeInterval != nil {
+ in, out := &in.ScrapeInterval, &out.ScrapeInterval
+ *out = new(metav1.Duration)
+ **out = **in
+ }
+ if in.PodMonitorSelector != nil {
+ in, out := &in.PodMonitorSelector, &out.PodMonitorSelector
+ *out = new(metav1.LabelSelector)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.ServiceMonitorSelector != nil {
+ in, out := &in.ServiceMonitorSelector, &out.ServiceMonitorSelector
+ *out = new(metav1.LabelSelector)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorPrometheusCR.
+func (in *TargetAllocatorPrometheusCR) DeepCopy() *TargetAllocatorPrometheusCR {
+ if in == nil {
+ return nil
+ }
+ out := new(TargetAllocatorPrometheusCR)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *Telemetry) DeepCopyInto(out *Telemetry) {
+ *out = *in
+ out.Metrics = in.Metrics
+ if in.Resource != nil {
+ in, out := &in.Resource, &out.Resource
+ *out = make(map[string]*string, len(*in))
+ for key, val := range *in {
+ var outVal *string
+ if val == nil {
+ (*out)[key] = nil
+ } else {
+ inVal := (*in)[key]
+ in, out := &inVal, &outVal
+ *out = new(string)
+ **out = **in
+ }
+ (*out)[key] = outVal
+ }
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Telemetry.
+func (in *Telemetry) DeepCopy() *Telemetry {
+ if in == nil {
+ return nil
+ }
+ out := new(Telemetry)
+ in.DeepCopyInto(out)
+ return out
+}
diff --git a/apis/v1alpha1/convert.go b/apis/v1alpha1/convert.go
index fb37e1c781..50f35bfae5 100644
--- a/apis/v1alpha1/convert.go
+++ b/apis/v1alpha1/convert.go
@@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
)
@@ -65,7 +66,7 @@ func (dst *OpenTelemetryCollector) ConvertFrom(srcRaw conversion.Hub) error {
func tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error) {
copy := in.DeepCopy()
- cfg := &v1beta1.Config{}
+ cfg := &common.Config{}
if err := yaml.Unmarshal([]byte(copy.Spec.Config), cfg); err != nil {
return v1beta1.OpenTelemetryCollector{}, errors.New("could not convert config json to v1beta1.Config")
}
@@ -82,8 +83,8 @@ func tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error
Image: in.Status.Image,
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
- ManagementState: v1beta1.ManagementStateType(copy.Spec.ManagementState),
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ ManagementState: common.ManagementStateType(copy.Spec.ManagementState),
Resources: copy.Spec.Resources,
NodeSelector: copy.Spec.NodeSelector,
Args: copy.Spec.Args,
@@ -129,8 +130,8 @@ func tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error
},
},
LivenessProbe: tov1beta1Probe(copy.Spec.LivenessProbe),
- Observability: v1beta1.ObservabilitySpec{
- Metrics: v1beta1.MetricsConfigSpec{
+ Observability: common.ObservabilitySpec{
+ Metrics: common.MetricsConfigSpec{
EnableMetrics: copy.Spec.Observability.Metrics.EnableMetrics,
DisablePrometheusAnnotations: copy.Spec.Observability.Metrics.DisablePrometheusAnnotations,
},
@@ -145,11 +146,11 @@ func tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error
}, nil
}
-func tov1beta1Ports(in []PortsSpec) []v1beta1.PortsSpec {
- var ports []v1beta1.PortsSpec
+func tov1beta1Ports(in []PortsSpec) []common.PortsSpec {
+ var ports []common.PortsSpec
for _, p := range in {
- ports = append(ports, v1beta1.PortsSpec{
+ ports = append(ports, common.PortsSpec{
ServicePort: v1.ServicePort{
Name: p.ServicePort.Name,
Protocol: p.ServicePort.Protocol,
@@ -170,13 +171,13 @@ func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedde
Replicas: in.Replicas,
NodeSelector: in.NodeSelector,
Resources: in.Resources,
- AllocationStrategy: tov1beta1TAAllocationStrategy(in.AllocationStrategy),
- FilterStrategy: tov1beta1TAFilterStrategy(in.FilterStrategy),
+ AllocationStrategy: in.AllocationStrategy,
+ FilterStrategy: in.FilterStrategy,
ServiceAccount: in.ServiceAccount,
Image: in.Image,
Enabled: in.Enabled,
Affinity: in.Affinity,
- PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{
+ PrometheusCR: common.TargetAllocatorPrometheusCR{
Enabled: in.PrometheusCR.Enabled,
ScrapeInterval: in.PrometheusCR.ScrapeInterval,
// prometheus_cr.pod_monitor_selector shouldn't be nil when selector is empty
@@ -192,8 +193,8 @@ func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedde
TopologySpreadConstraints: in.TopologySpreadConstraints,
Tolerations: in.Tolerations,
Env: in.Env,
- Observability: v1beta1.ObservabilitySpec{
- Metrics: v1beta1.MetricsConfigSpec{
+ Observability: common.ObservabilitySpec{
+ Metrics: common.MetricsConfigSpec{
EnableMetrics: in.Observability.Metrics.EnableMetrics,
DisablePrometheusAnnotations: in.Observability.Metrics.DisablePrometheusAnnotations,
},
@@ -203,7 +204,7 @@ func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedde
}
// The conversion takes into account deprecated v1alpha1 spec.minReplicas and spec.maxReplicas.
-func tov1beta1Autoscaler(in *AutoscalerSpec, minReplicas, maxReplicas *int32) *v1beta1.AutoscalerSpec {
+func tov1beta1Autoscaler(in *AutoscalerSpec, minReplicas, maxReplicas *int32) *common.AutoscalerSpec {
if in == nil && minReplicas == nil && maxReplicas == nil {
return nil
}
@@ -211,9 +212,9 @@ func tov1beta1Autoscaler(in *AutoscalerSpec, minReplicas, maxReplicas *int32) *v
in = &AutoscalerSpec{}
}
- var metrics []v1beta1.MetricSpec
+ var metrics []common.MetricSpec
for _, m := range in.Metrics {
- metrics = append(metrics, v1beta1.MetricSpec{
+ metrics = append(metrics, common.MetricSpec{
Type: m.Type,
Pods: m.Pods,
})
@@ -225,7 +226,7 @@ func tov1beta1Autoscaler(in *AutoscalerSpec, minReplicas, maxReplicas *int32) *v
in.MinReplicas = minReplicas
}
- return &v1beta1.AutoscalerSpec{
+ return &common.AutoscalerSpec{
MinReplicas: in.MinReplicas,
MaxReplicas: in.MaxReplicas,
Behavior: in.Behavior,
@@ -235,11 +236,11 @@ func tov1beta1Autoscaler(in *AutoscalerSpec, minReplicas, maxReplicas *int32) *v
}
}
-func tov1beta1PodDisruptionBudget(in *PodDisruptionBudgetSpec) *v1beta1.PodDisruptionBudgetSpec {
+func tov1beta1PodDisruptionBudget(in *PodDisruptionBudgetSpec) *common.PodDisruptionBudgetSpec {
if in == nil {
return nil
}
- return &v1beta1.PodDisruptionBudgetSpec{
+ return &common.PodDisruptionBudgetSpec{
MinAvailable: in.MinAvailable,
MaxUnavailable: in.MaxUnavailable,
}
@@ -270,7 +271,7 @@ func tov1beta1ConfigMaps(in []ConfigMapsSpec) []v1beta1.ConfigMapsSpec {
return mapsSpecs
}
-func tov1alpha1Ports(in []v1beta1.PortsSpec) []PortsSpec {
+func tov1alpha1Ports(in []common.PortsSpec) []PortsSpec {
var ports []PortsSpec
for _, p := range in {
@@ -368,7 +369,7 @@ func tov1alpha1(in v1beta1.OpenTelemetryCollector) (*OpenTelemetryCollector, err
}, nil
}
-func tov1alpha1PodDisruptionBudget(in *v1beta1.PodDisruptionBudgetSpec) *PodDisruptionBudgetSpec {
+func tov1alpha1PodDisruptionBudget(in *common.PodDisruptionBudgetSpec) *PodDisruptionBudgetSpec {
if in == nil {
return nil
}
@@ -392,7 +393,7 @@ func tov1alpha1Probe(in *v1beta1.Probe) *Probe {
}
}
-func tov1alpha1Autoscaler(in *v1beta1.AutoscalerSpec) *AutoscalerSpec {
+func tov1alpha1Autoscaler(in *common.AutoscalerSpec) *AutoscalerSpec {
if in == nil {
return nil
}
@@ -440,8 +441,8 @@ func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocat
Replicas: in.Replicas,
NodeSelector: in.NodeSelector,
Resources: in.Resources,
- AllocationStrategy: tov1alpha1TAAllocationStrategy(in.AllocationStrategy),
- FilterStrategy: tov1alpha1TAFilterStrategy(in.FilterStrategy),
+ AllocationStrategy: in.AllocationStrategy,
+ FilterStrategy: in.FilterStrategy,
ServiceAccount: in.ServiceAccount,
Image: in.Image,
Enabled: in.Enabled,
@@ -466,42 +467,3 @@ func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocat
PodDisruptionBudget: tov1alpha1PodDisruptionBudget(in.PodDisruptionBudget),
}
}
-
-func tov1alpha1TAFilterStrategy(strategy v1beta1.TargetAllocatorFilterStrategy) string {
- switch strategy {
- case v1beta1.TargetAllocatorFilterStrategyRelabelConfig:
- return string(strategy)
- }
- return ""
-}
-
-func tov1alpha1TAAllocationStrategy(strategy v1beta1.TargetAllocatorAllocationStrategy) OpenTelemetryTargetAllocatorAllocationStrategy {
- switch strategy {
- case v1beta1.TargetAllocatorAllocationStrategyConsistentHashing:
- return OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing
- case v1beta1.TargetAllocatorAllocationStrategyPerNode:
- return OpenTelemetryTargetAllocatorAllocationStrategyPerNode
- case v1beta1.TargetAllocatorAllocationStrategyLeastWeighted:
- return OpenTelemetryTargetAllocatorAllocationStrategyLeastWeighted
- }
- return ""
-}
-
-func tov1beta1TAFilterStrategy(strategy string) v1beta1.TargetAllocatorFilterStrategy {
- if strategy == string(v1beta1.TargetAllocatorFilterStrategyRelabelConfig) {
- return v1beta1.TargetAllocatorFilterStrategyRelabelConfig
- }
- return ""
-}
-
-func tov1beta1TAAllocationStrategy(strategy OpenTelemetryTargetAllocatorAllocationStrategy) v1beta1.TargetAllocatorAllocationStrategy {
- switch strategy {
- case OpenTelemetryTargetAllocatorAllocationStrategyPerNode:
- return v1beta1.TargetAllocatorAllocationStrategyPerNode
- case OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing:
- return v1beta1.TargetAllocatorAllocationStrategyConsistentHashing
- case OpenTelemetryTargetAllocatorAllocationStrategyLeastWeighted:
- return v1beta1.TargetAllocatorAllocationStrategyLeastWeighted
- }
- return ""
-}
diff --git a/apis/v1alpha1/convert_test.go b/apis/v1alpha1/convert_test.go
index ba8bb063d0..9beeb3f652 100644
--- a/apis/v1alpha1/convert_test.go
+++ b/apis/v1alpha1/convert_test.go
@@ -29,6 +29,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
)
@@ -85,7 +86,7 @@ func Test_tov1beta1_config(t *testing.T) {
}
func Test_tov1alpha1_config(t *testing.T) {
- cfg := v1beta1.Config{}
+ cfg := common.Config{}
err := yaml.Unmarshal([]byte(collectorCfg), &cfg)
require.NoError(t, err)
@@ -427,7 +428,7 @@ func createTA() OpenTelemetryTargetAllocator {
v1.ResourceMemory: resource.MustParse("128Mi"),
},
},
- AllocationStrategy: OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing,
+ AllocationStrategy: common.TargetAllocatorAllocationStrategyConsistentHashing,
FilterStrategy: "relabel-config",
ServiceAccount: "serviceAccountName",
Image: "custom_image",
@@ -527,11 +528,11 @@ func TestConvertTo(t *testing.T) {
Name: "otel",
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
ServiceAccount: "otelcol",
},
TargetAllocator: v1beta1.TargetAllocatorEmbedded{
- PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{
+ PrometheusCR: common.TargetAllocatorPrometheusCR{
PodMonitorSelector: &metav1.LabelSelector{},
ServiceMonitorSelector: &metav1.LabelSelector{},
},
@@ -549,7 +550,7 @@ func TestConvertFrom(t *testing.T) {
Name: "otel",
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
ServiceAccount: "otelcol",
},
},
diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go
index a2c5055fd0..e1330b30be 100644
--- a/apis/v1alpha1/opentelemetrycollector_types.go
+++ b/apis/v1alpha1/opentelemetrycollector_types.go
@@ -21,6 +21,8 @@ import (
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
+
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
)
// ManagementStateType defines the type for CR management states.
@@ -320,13 +322,13 @@ type OpenTelemetryTargetAllocator struct {
// WARNING: The per-node strategy currently ignores targets without a Node, like control plane components.
// +optional
// +kubebuilder:default:=consistent-hashing
- AllocationStrategy OpenTelemetryTargetAllocatorAllocationStrategy `json:"allocationStrategy,omitempty"`
+ AllocationStrategy common.TargetAllocatorAllocationStrategy `json:"allocationStrategy,omitempty"`
// FilterStrategy determines how to filter targets before allocating them among the collectors.
// The only current option is relabel-config (drops targets based on prom relabel_config).
// The default is relabel-config.
// +optional
// +kubebuilder:default:=relabel-config
- FilterStrategy string `json:"filterStrategy,omitempty"`
+ FilterStrategy common.TargetAllocatorFilterStrategy `json:"filterStrategy,omitempty"`
// ServiceAccount indicates the name of an existing service account to use with this instance. When set,
// the operator will not automatically create a ServiceAccount for the TargetAllocator.
// +optional
diff --git a/apis/v1beta1/targetallocator_types.go b/apis/v1alpha1/targetallocator_types.go
similarity index 91%
rename from apis/v1beta1/targetallocator_types.go
rename to apis/v1alpha1/targetallocator_types.go
index c833c54816..b238f1bdfb 100644
--- a/apis/v1beta1/targetallocator_types.go
+++ b/apis/v1alpha1/targetallocator_types.go
@@ -12,10 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package v1beta1
+package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
)
func init() {
@@ -57,7 +59,7 @@ type TargetAllocatorStatus struct {
// TargetAllocatorSpec defines the desired state of TargetAllocator.
type TargetAllocatorSpec struct {
// Common defines fields that are common to all OpenTelemetry CRD workloads.
- OpenTelemetryCommonFields `json:",inline"`
+ common.OpenTelemetryCommonFields `json:",inline"`
// CollectorSelector is the selector for Collector Pods the target allocator will allocate targets to.
CollectorSelector metav1.LabelSelector `json:"collectorSelector,omitempty"`
// AllocationStrategy determines which strategy the target allocator should use for allocation.
@@ -66,29 +68,29 @@ type TargetAllocatorSpec struct {
// WARNING: The per-node strategy currently ignores targets without a Node, like control plane components.
// +optional
// +kubebuilder:default:=consistent-hashing
- AllocationStrategy TargetAllocatorAllocationStrategy `json:"allocationStrategy,omitempty"`
+ AllocationStrategy common.TargetAllocatorAllocationStrategy `json:"allocationStrategy,omitempty"`
// FilterStrategy determines how to filter targets before allocating them among the collectors.
// The only current option is relabel-config (drops targets based on prom relabel_config).
// The default is relabel-config.
// +optional
// +kubebuilder:default:=relabel-config
- FilterStrategy TargetAllocatorFilterStrategy `json:"filterStrategy,omitempty"`
+ FilterStrategy common.TargetAllocatorFilterStrategy `json:"filterStrategy,omitempty"`
// ScrapeConfigs define static Prometheus scrape configurations for the target allocator.
// To use dynamic configurations from ServiceMonitors and PodMonitors, see the PrometheusCR section.
// For the exact format, see https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config.
// +optional
// +listType=atomic
// +kubebuilder:pruning:PreserveUnknownFields
- ScrapeConfigs []AnyConfig `json:"scrapeConfigs,omitempty"`
+ ScrapeConfigs []common.AnyConfig `json:"scrapeConfigs,omitempty"`
// PrometheusCR defines the configuration for the retrieval of PrometheusOperator CRDs ( servicemonitor.monitoring.coreos.com/v1 and podmonitor.monitoring.coreos.com/v1 ).
// +optional
- PrometheusCR TargetAllocatorPrometheusCR `json:"prometheusCR,omitempty"`
+ PrometheusCR common.TargetAllocatorPrometheusCR `json:"prometheusCR,omitempty"`
// ObservabilitySpec defines how telemetry data gets handled.
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Observability"
- Observability ObservabilitySpec `json:"observability,omitempty"`
+ Observability common.ObservabilitySpec `json:"observability,omitempty"`
}
// TargetAllocatorPrometheusCR configures Prometheus CustomResource handling in the Target Allocator.
diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go
index 8f47cb64dc..0810b70ee3 100644
--- a/apis/v1alpha1/zz_generated.deepcopy.go
+++ b/apis/v1alpha1/zz_generated.deepcopy.go
@@ -19,6 +19,7 @@
package v1alpha1
import (
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
"k8s.io/api/autoscaling/v2"
"k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
@@ -1243,3 +1244,133 @@ func (in *ScaleSubresourceStatus) DeepCopy() *ScaleSubresourceStatus {
in.DeepCopyInto(out)
return out
}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *TargetAllocator) DeepCopyInto(out *TargetAllocator) {
+ *out = *in
+ out.TypeMeta = in.TypeMeta
+ in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
+ in.Spec.DeepCopyInto(&out.Spec)
+ out.Status = in.Status
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocator.
+func (in *TargetAllocator) DeepCopy() *TargetAllocator {
+ if in == nil {
+ return nil
+ }
+ out := new(TargetAllocator)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+func (in *TargetAllocator) DeepCopyObject() runtime.Object {
+ if c := in.DeepCopy(); c != nil {
+ return c
+ }
+ return nil
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *TargetAllocatorList) DeepCopyInto(out *TargetAllocatorList) {
+ *out = *in
+ out.TypeMeta = in.TypeMeta
+ in.ListMeta.DeepCopyInto(&out.ListMeta)
+ if in.Items != nil {
+ in, out := &in.Items, &out.Items
+ *out = make([]OpenTelemetryCollector, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorList.
+func (in *TargetAllocatorList) DeepCopy() *TargetAllocatorList {
+ if in == nil {
+ return nil
+ }
+ out := new(TargetAllocatorList)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+func (in *TargetAllocatorList) DeepCopyObject() runtime.Object {
+ if c := in.DeepCopy(); c != nil {
+ return c
+ }
+ return nil
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *TargetAllocatorPrometheusCR) DeepCopyInto(out *TargetAllocatorPrometheusCR) {
+ *out = *in
+ if in.ScrapeInterval != nil {
+ in, out := &in.ScrapeInterval, &out.ScrapeInterval
+ *out = new(metav1.Duration)
+ **out = **in
+ }
+ if in.PodMonitorSelector != nil {
+ in, out := &in.PodMonitorSelector, &out.PodMonitorSelector
+ *out = new(metav1.LabelSelector)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.ServiceMonitorSelector != nil {
+ in, out := &in.ServiceMonitorSelector, &out.ServiceMonitorSelector
+ *out = new(metav1.LabelSelector)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorPrometheusCR.
+func (in *TargetAllocatorPrometheusCR) DeepCopy() *TargetAllocatorPrometheusCR {
+ if in == nil {
+ return nil
+ }
+ out := new(TargetAllocatorPrometheusCR)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *TargetAllocatorSpec) DeepCopyInto(out *TargetAllocatorSpec) {
+ *out = *in
+ in.OpenTelemetryCommonFields.DeepCopyInto(&out.OpenTelemetryCommonFields)
+ in.CollectorSelector.DeepCopyInto(&out.CollectorSelector)
+ if in.ScrapeConfigs != nil {
+ in, out := &in.ScrapeConfigs, &out.ScrapeConfigs
+ *out = make([]common.AnyConfig, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ in.PrometheusCR.DeepCopyInto(&out.PrometheusCR)
+ out.Observability = in.Observability
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorSpec.
+func (in *TargetAllocatorSpec) DeepCopy() *TargetAllocatorSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(TargetAllocatorSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *TargetAllocatorStatus) DeepCopyInto(out *TargetAllocatorStatus) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorStatus.
+func (in *TargetAllocatorStatus) DeepCopy() *TargetAllocatorStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(TargetAllocatorStatus)
+ in.DeepCopyInto(out)
+ return out
+}
diff --git a/apis/v1beta1/collector_webhook.go b/apis/v1beta1/collector_webhook.go
index e26f4e232c..876d7abdb7 100644
--- a/apis/v1beta1/collector_webhook.go
+++ b/apis/v1beta1/collector_webhook.go
@@ -29,6 +29,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
"github.com/open-telemetry/opentelemetry-operator/internal/config"
ta "github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator/adapters"
"github.com/open-telemetry/opentelemetry-operator/internal/rbac"
@@ -124,7 +125,7 @@ func (c CollectorWebhook) Default(_ context.Context, obj runtime.Object) error {
// not blocking node drains but preventing out-of-the-box
// from disruption generated by them with replicas > 1
if otelcol.Spec.PodDisruptionBudget == nil {
- otelcol.Spec.PodDisruptionBudget = &PodDisruptionBudgetSpec{
+ otelcol.Spec.PodDisruptionBudget = &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -138,9 +139,9 @@ func (c CollectorWebhook) Default(_ context.Context, obj runtime.Object) error {
// just one replica, not blocking node drains but preventing
// out-of-the-box from disruption generated by them with replicas > 1
if otelcol.Spec.TargetAllocator.Enabled &&
- otelcol.Spec.TargetAllocator.AllocationStrategy == TargetAllocatorAllocationStrategyConsistentHashing &&
+ otelcol.Spec.TargetAllocator.AllocationStrategy == common.TargetAllocatorAllocationStrategyConsistentHashing &&
otelcol.Spec.TargetAllocator.PodDisruptionBudget == nil {
- otelcol.Spec.TargetAllocator.PodDisruptionBudget = &PodDisruptionBudgetSpec{
+ otelcol.Spec.TargetAllocator.PodDisruptionBudget = &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -157,7 +158,7 @@ func (c CollectorWebhook) Default(_ context.Context, obj runtime.Object) error {
// If someone upgrades to a later version without upgrading their CRD they will not have a management state set.
// This results in a default state of unmanaged preventing reconciliation from continuing.
if len(otelcol.Spec.ManagementState) == 0 {
- otelcol.Spec.ManagementState = ManagementStateManaged
+ otelcol.Spec.ManagementState = common.ManagementStateManaged
}
return nil
}
@@ -189,7 +190,7 @@ func (c CollectorWebhook) ValidateDelete(ctx context.Context, obj runtime.Object
func (c CollectorWebhook) validate(ctx context.Context, r *OpenTelemetryCollector) (admission.Warnings, error) {
warnings := admission.Warnings{}
- nullObjects := r.Spec.Config.nullObjects()
+ nullObjects := r.Spec.Config.NullObjects()
if len(nullObjects) > 0 {
warnings = append(warnings, fmt.Sprintf("Collector config spec.config has null objects: %s. For compatibility tooling (kustomize and kubectl edit) it is recommended to use empty obejects e.g. batch: {}.", strings.Join(nullObjects, ", ")))
}
@@ -329,12 +330,12 @@ func (c CollectorWebhook) validateTargetAllocatorConfig(ctx context.Context, r *
return nil, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the target allocation deployment", r.Spec.Mode)
}
- if r.Spec.Mode == ModeDaemonSet && r.Spec.TargetAllocator.AllocationStrategy != TargetAllocatorAllocationStrategyPerNode {
- return nil, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which must be used with target allocation strategy %s ", r.Spec.Mode, TargetAllocatorAllocationStrategyPerNode)
+ if r.Spec.Mode == ModeDaemonSet && r.Spec.TargetAllocator.AllocationStrategy != common.TargetAllocatorAllocationStrategyPerNode {
+ return nil, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which must be used with target allocation strategy %s ", r.Spec.Mode, common.TargetAllocatorAllocationStrategyPerNode)
}
- if r.Spec.TargetAllocator.AllocationStrategy == TargetAllocatorAllocationStrategyPerNode && r.Spec.Mode != ModeDaemonSet {
- return nil, fmt.Errorf("target allocation strategy %s is only supported in OpenTelemetry Collector mode %s", TargetAllocatorAllocationStrategyPerNode, ModeDaemonSet)
+ if r.Spec.TargetAllocator.AllocationStrategy == common.TargetAllocatorAllocationStrategyPerNode && r.Spec.Mode != ModeDaemonSet {
+ return nil, fmt.Errorf("target allocation strategy %s is only supported in OpenTelemetry Collector mode %s", common.TargetAllocatorAllocationStrategyPerNode, ModeDaemonSet)
}
cfgYaml, err := r.Spec.Config.Yaml()
@@ -366,7 +367,7 @@ func (c CollectorWebhook) validateTargetAllocatorConfig(ctx context.Context, r *
return nil, nil
}
-func checkAutoscalerSpec(autoscaler *AutoscalerSpec) error {
+func checkAutoscalerSpec(autoscaler *common.AutoscalerSpec) error {
if autoscaler.Behavior != nil {
if autoscaler.Behavior.ScaleDown != nil && autoscaler.Behavior.ScaleDown.StabilizationWindowSeconds != nil &&
*autoscaler.Behavior.ScaleDown.StabilizationWindowSeconds < int32(1) {
diff --git a/apis/v1beta1/collector_webhook_test.go b/apis/v1beta1/collector_webhook_test.go
index 253ae99971..23cceea207 100644
--- a/apis/v1beta1/collector_webhook_test.go
+++ b/apis/v1beta1/collector_webhook_test.go
@@ -36,6 +36,7 @@ import (
"k8s.io/client-go/kubernetes/scheme"
kubeTesting "k8s.io/client-go/testing"
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
"github.com/open-telemetry/opentelemetry-operator/internal/config"
"github.com/open-telemetry/opentelemetry-operator/internal/rbac"
)
@@ -55,14 +56,14 @@ func TestValidate(t *testing.T) {
name: "Test ",
collector: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- Config: Config{
- Processors: &AnyConfig{
+ Config: common.Config{
+ Processors: &common.AnyConfig{
Object: map[string]interface{}{
"batch": nil,
"foo": nil,
},
},
- Extensions: &AnyConfig{
+ Extensions: &common.AnyConfig{
Object: map[string]interface{}{
"foo": nil,
},
@@ -116,10 +117,10 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
},
},
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- ManagementState: ManagementStateManaged,
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ ManagementState: common.ManagementStateManaged,
Replicas: &one,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -137,7 +138,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: OpenTelemetryCollectorSpec{
Mode: ModeSidecar,
UpgradeStrategy: "adhoc",
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &five,
},
},
@@ -151,10 +152,10 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: OpenTelemetryCollectorSpec{
Mode: ModeSidecar,
UpgradeStrategy: "adhoc",
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &five,
- ManagementState: ManagementStateManaged,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ ManagementState: common.ManagementStateManaged,
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -170,9 +171,9 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: OpenTelemetryCollectorSpec{
Mode: ModeSidecar,
UpgradeStrategy: "adhoc",
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &five,
- ManagementState: ManagementStateUnmanaged,
+ ManagementState: common.ManagementStateUnmanaged,
},
},
},
@@ -185,10 +186,10 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: OpenTelemetryCollectorSpec{
Mode: ModeSidecar,
UpgradeStrategy: "adhoc",
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &five,
- ManagementState: ManagementStateUnmanaged,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ ManagementState: common.ManagementStateUnmanaged,
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -202,8 +203,8 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
name: "Setting Autoscaler MaxReplicas",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &five,
MinReplicas: &one,
},
@@ -219,15 +220,15 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: OpenTelemetryCollectorSpec{
Mode: ModeDeployment,
UpgradeStrategy: UpgradeStrategyAutomatic,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &one,
- ManagementState: ManagementStateManaged,
- Autoscaler: &AutoscalerSpec{
+ ManagementState: common.ManagementStateManaged,
+ Autoscaler: &common.AutoscalerSpec{
TargetCPUUtilization: &defaultCPUTarget,
MaxReplicas: &five,
MinReplicas: &one,
},
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -255,10 +256,10 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
},
Spec: OpenTelemetryCollectorSpec{
Mode: ModeDeployment,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- ManagementState: ManagementStateManaged,
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ ManagementState: common.ManagementStateManaged,
Replicas: &one,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -280,8 +281,8 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Mode: ModeDeployment,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MinAvailable: &intstr.IntOrString{
Type: intstr.String,
StrVal: "10%",
@@ -298,10 +299,10 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
},
Spec: OpenTelemetryCollectorSpec{
Mode: ModeDeployment,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &one,
- ManagementState: ManagementStateManaged,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ ManagementState: common.ManagementStateManaged,
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MinAvailable: &intstr.IntOrString{
Type: intstr.String,
StrVal: "10%",
@@ -319,8 +320,8 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Mode: ModeDeployment,
TargetAllocator: TargetAllocatorEmbedded{
Enabled: true,
- AllocationStrategy: TargetAllocatorAllocationStrategyConsistentHashing,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ AllocationStrategy: common.TargetAllocatorAllocationStrategyConsistentHashing,
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MinAvailable: &intstr.IntOrString{
Type: intstr.String,
StrVal: "10%",
@@ -337,10 +338,10 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
},
Spec: OpenTelemetryCollectorSpec{
Mode: ModeDeployment,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &one,
- ManagementState: ManagementStateManaged,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ ManagementState: common.ManagementStateManaged,
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -351,8 +352,8 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
TargetAllocator: TargetAllocatorEmbedded{
Enabled: true,
Replicas: &one,
- AllocationStrategy: TargetAllocatorAllocationStrategyConsistentHashing,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ AllocationStrategy: common.TargetAllocatorAllocationStrategyConsistentHashing,
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MinAvailable: &intstr.IntOrString{
Type: intstr.String,
StrVal: "10%",
@@ -370,7 +371,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
TargetAllocator: TargetAllocatorEmbedded{
Enabled: true,
Replicas: &one,
- AllocationStrategy: TargetAllocatorAllocationStrategyConsistentHashing,
+ AllocationStrategy: common.TargetAllocatorAllocationStrategyConsistentHashing,
},
},
},
@@ -382,10 +383,10 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
},
Spec: OpenTelemetryCollectorSpec{
Mode: ModeDeployment,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &one,
- ManagementState: ManagementStateManaged,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ ManagementState: common.ManagementStateManaged,
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -396,8 +397,8 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
TargetAllocator: TargetAllocatorEmbedded{
Enabled: true,
Replicas: &one,
- AllocationStrategy: TargetAllocatorAllocationStrategyConsistentHashing,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ AllocationStrategy: common.TargetAllocatorAllocationStrategyConsistentHashing,
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -414,7 +415,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Mode: ModeDeployment,
TargetAllocator: TargetAllocatorEmbedded{
Enabled: true,
- AllocationStrategy: TargetAllocatorAllocationStrategyLeastWeighted,
+ AllocationStrategy: common.TargetAllocatorAllocationStrategyLeastWeighted,
},
},
},
@@ -426,10 +427,10 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
},
Spec: OpenTelemetryCollectorSpec{
Mode: ModeDeployment,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &one,
- ManagementState: ManagementStateManaged,
- PodDisruptionBudget: &PodDisruptionBudgetSpec{
+ ManagementState: common.ManagementStateManaged,
+ PodDisruptionBudget: &common.PodDisruptionBudgetSpec{
MaxUnavailable: &intstr.IntOrString{
Type: intstr.Int,
IntVal: 1,
@@ -440,7 +441,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
TargetAllocator: TargetAllocatorEmbedded{
Enabled: true,
Replicas: &one,
- AllocationStrategy: TargetAllocatorAllocationStrategyLeastWeighted,
+ AllocationStrategy: common.TargetAllocatorAllocationStrategyLeastWeighted,
},
},
},
@@ -490,7 +491,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
three := int32(3)
five := int32(5)
- cfg := Config{}
+ cfg := common.Config{}
err := yaml.Unmarshal([]byte(cfgYaml), &cfg)
require.NoError(t, err)
@@ -510,9 +511,9 @@ func TestOTELColValidatingWebhook(t *testing.T) {
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Mode: ModeStatefulSet,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &three,
- Autoscaler: &AutoscalerSpec{
+ Autoscaler: &common.AutoscalerSpec{
MinReplicas: &one,
MaxReplicas: &five,
Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{
@@ -525,7 +526,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
},
TargetCPUUtilization: &five,
},
- Ports: []PortsSpec{
+ Ports: []common.PortsSpec{
{
ServicePort: v1.ServicePort{
Name: "port1",
@@ -555,9 +556,9 @@ func TestOTELColValidatingWebhook(t *testing.T) {
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Mode: ModeStatefulSet,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &three,
- Autoscaler: &AutoscalerSpec{
+ Autoscaler: &common.AutoscalerSpec{
MinReplicas: &one,
MaxReplicas: &five,
Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{
@@ -570,7 +571,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
},
TargetCPUUtilization: &five,
},
- Ports: []PortsSpec{
+ Ports: []common.PortsSpec{
{
ServicePort: v1.ServicePort{
Name: "port1",
@@ -589,7 +590,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
UpgradeStrategy: "adhoc",
TargetAllocator: TargetAllocatorEmbedded{
Enabled: true,
- PrometheusCR: TargetAllocatorPrometheusCR{Enabled: true},
+ PrometheusCR: common.TargetAllocatorPrometheusCR{Enabled: true},
},
Config: cfg,
},
@@ -616,9 +617,9 @@ func TestOTELColValidatingWebhook(t *testing.T) {
Spec: OpenTelemetryCollectorSpec{
Mode: ModeStatefulSet,
UpgradeStrategy: "adhoc",
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &three,
- Ports: []PortsSpec{
+ Ports: []common.PortsSpec{
{
ServicePort: v1.ServicePort{
Name: "port1",
@@ -633,7 +634,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
},
},
},
- Autoscaler: &AutoscalerSpec{
+ Autoscaler: &common.AutoscalerSpec{
Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{
ScaleDown: &autoscalingv2.HPAScalingRules{
StabilizationWindowSeconds: &three,
@@ -647,7 +648,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
},
TargetAllocator: TargetAllocatorEmbedded{
Enabled: true,
- PrometheusCR: TargetAllocatorPrometheusCR{Enabled: true},
+ PrometheusCR: common.TargetAllocatorPrometheusCR{Enabled: true},
},
Config: cfg,
},
@@ -658,7 +659,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Mode: ModeSidecar,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
VolumeClaimTemplates: []v1.PersistentVolumeClaim{{}, {}},
},
},
@@ -670,7 +671,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Mode: ModeSidecar,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Tolerations: []v1.Toleration{{}, {}},
},
},
@@ -708,7 +709,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
Mode: ModeDaemonSet,
TargetAllocator: TargetAllocatorEmbedded{
Enabled: true,
- AllocationStrategy: TargetAllocatorAllocationStrategyLeastWeighted,
+ AllocationStrategy: common.TargetAllocatorAllocationStrategyLeastWeighted,
},
},
},
@@ -718,8 +719,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid port name",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Ports: []PortsSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Ports: []common.PortsSpec{
{
ServicePort: v1.ServicePort{
// this port name contains a non alphanumeric character, which is invalid.
@@ -738,8 +739,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid port name, too long",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Ports: []PortsSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Ports: []common.PortsSpec{
{
ServicePort: v1.ServicePort{
Name: "aaaabbbbccccdddd", // len: 16, too long
@@ -756,8 +757,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid port num",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Ports: []PortsSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Ports: []common.PortsSpec{
{
ServicePort: v1.ServicePort{
Name: "aaaabbbbccccddd", // len: 15
@@ -774,8 +775,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid max replicas",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &zero,
},
},
@@ -787,9 +788,9 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid replicas, greater than max",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Replicas: &five,
- Autoscaler: &AutoscalerSpec{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &three,
},
},
@@ -801,8 +802,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid min replicas, greater than max",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &three,
MinReplicas: &five,
},
@@ -815,8 +816,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid min replicas, lesser than 1",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &three,
MinReplicas: &zero,
},
@@ -829,8 +830,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid autoscaler scale down",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &three,
Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{
ScaleDown: &autoscalingv2.HPAScalingRules{
@@ -847,8 +848,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid autoscaler scale up",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &three,
Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{
ScaleUp: &autoscalingv2.HPAScalingRules{
@@ -865,8 +866,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid autoscaler target cpu utilization",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &three,
TargetCPUUtilization: &zero,
},
@@ -879,8 +880,8 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "autoscaler minReplicas is less than maxReplicas",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &one,
MinReplicas: &five,
},
@@ -893,10 +894,10 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid autoscaler metric type",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &three,
- Metrics: []MetricSpec{
+ Metrics: []common.MetricSpec{
{
Type: autoscalingv2.ResourceMetricSourceType,
},
@@ -911,10 +912,10 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid pod metric average value",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &three,
- Metrics: []MetricSpec{
+ Metrics: []common.MetricSpec{
{
Type: autoscalingv2.PodsMetricSourceType,
Pods: &autoscalingv2.PodsMetricSource{
@@ -938,10 +939,10 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "utilization target is not valid with pod metrics",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
- Autoscaler: &AutoscalerSpec{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
+ Autoscaler: &common.AutoscalerSpec{
MaxReplicas: &three,
- Metrics: []MetricSpec{
+ Metrics: []common.MetricSpec{
{
Type: autoscalingv2.PodsMetricSourceType,
Pods: &autoscalingv2.PodsMetricSource{
@@ -980,7 +981,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Mode: ModeSidecar,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
PriorityClassName: "test-class",
},
},
@@ -992,7 +993,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Mode: ModeSidecar,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Affinity: &v1.Affinity{
NodeAffinity: &v1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{
@@ -1086,7 +1087,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Mode: ModeSidecar,
- OpenTelemetryCommonFields: OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
AdditionalContainers: []v1.Container{
{
Name: "test",
diff --git a/apis/v1beta1/opentelemetrycollector_types.go b/apis/v1beta1/opentelemetrycollector_types.go
index f21637d7fe..6ad89a8f58 100644
--- a/apis/v1beta1/opentelemetrycollector_types.go
+++ b/apis/v1beta1/opentelemetrycollector_types.go
@@ -18,6 +18,8 @@ import (
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
)
func init() {
@@ -78,7 +80,7 @@ type OpenTelemetryCollectorStatus struct {
// OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector.
type OpenTelemetryCollectorSpec struct {
// OpenTelemetryCommonFields are fields that are on all OpenTelemetry CRD workloads.
- OpenTelemetryCommonFields `json:",inline"`
+ common.OpenTelemetryCommonFields `json:",inline"`
// TargetAllocator indicates a value which determines whether to spawn a target allocation resource or not.
// +optional
TargetAllocator TargetAllocatorEmbedded `json:"targetAllocator,omitempty"`
@@ -92,7 +94,7 @@ type OpenTelemetryCollectorSpec struct {
// The empty objects e.g. batch: should be written as batch: {} otherwise they won't work with kustomize or kubectl edit.
// +required
// +kubebuilder:pruning:PreserveUnknownFields
- Config Config `json:"config"`
+ Config common.Config `json:"config"`
// Ingress is used to specify how OpenTelemetry Collector is exposed. This
// functionality is only available if one of the valid modes is set.
// Valid modes are: deployment, daemonset and statefulset.
@@ -108,7 +110,7 @@ type OpenTelemetryCollectorSpec struct {
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Observability"
- Observability ObservabilitySpec `json:"observability,omitempty"`
+ Observability common.ObservabilitySpec `json:"observability,omitempty"`
// ConfigMaps is a list of ConfigMaps in the same namespace as the OpenTelemetryCollector
// object, which shall be mounted into the Collector Pods.
@@ -146,13 +148,13 @@ type TargetAllocatorEmbedded struct {
// WARNING: The per-node strategy currently ignores targets without a Node, like control plane components.
// +optional
// +kubebuilder:default:=consistent-hashing
- AllocationStrategy TargetAllocatorAllocationStrategy `json:"allocationStrategy,omitempty"`
+ AllocationStrategy common.TargetAllocatorAllocationStrategy `json:"allocationStrategy,omitempty"`
// FilterStrategy determines how to filter targets before allocating them among the collectors.
// The only current option is relabel-config (drops targets based on prom relabel_config).
// The default is relabel-config.
// +optional
// +kubebuilder:default:=relabel-config
- FilterStrategy TargetAllocatorFilterStrategy `json:"filterStrategy,omitempty"`
+ FilterStrategy common.TargetAllocatorFilterStrategy `json:"filterStrategy,omitempty"`
// ServiceAccount indicates the name of an existing service account to use with this instance. When set,
// the operator will not automatically create a ServiceAccount for the TargetAllocator.
// +optional
@@ -169,7 +171,7 @@ type TargetAllocatorEmbedded struct {
// PrometheusCR defines the configuration for the retrieval of PrometheusOperator CRDs ( servicemonitor.monitoring.coreos.com/v1 and podmonitor.monitoring.coreos.com/v1 ) retrieval.
// All CR instances which the ServiceAccount has access to will be retrieved. This includes other namespaces.
// +optional
- PrometheusCR TargetAllocatorPrometheusCR `json:"prometheusCR,omitempty"`
+ PrometheusCR common.TargetAllocatorPrometheusCR `json:"prometheusCR,omitempty"`
// SecurityContext configures the container security context for
// the targetallocator.
// +optional
@@ -197,12 +199,12 @@ type TargetAllocatorEmbedded struct {
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Observability"
- Observability ObservabilitySpec `json:"observability,omitempty"`
+ Observability common.ObservabilitySpec `json:"observability,omitempty"`
// PodDisruptionBudget specifies the pod disruption budget configuration to use
// for the target allocator workload.
//
// +optional
- PodDisruptionBudget *PodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`
+ PodDisruptionBudget *common.PodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`
}
// Probe defines the OpenTelemetry's pod probe config. Only Liveness probe is supported currently.
@@ -243,33 +245,6 @@ type Probe struct {
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
}
-// ObservabilitySpec defines how telemetry data gets handled.
-type ObservabilitySpec struct {
- // Metrics defines the metrics configuration for operands.
- //
- // +optional
- // +kubebuilder:validation:Optional
- // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Metrics Config"
- Metrics MetricsConfigSpec `json:"metrics,omitempty"`
-}
-
-// MetricsConfigSpec defines a metrics config.
-type MetricsConfigSpec struct {
- // EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar mode) should be created for the service managed by the OpenTelemetry Operator.
- // The operator.observability.prometheus feature gate must be enabled to use this feature.
- //
- // +optional
- // +kubebuilder:validation:Optional
- // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Create ServiceMonitors for OpenTelemetry Collector"
- EnableMetrics bool `json:"enableMetrics,omitempty"`
- // DisablePrometheusAnnotations controls the automatic addition of default Prometheus annotations
- // ('prometheus.io/scrape', 'prometheus.io/port', and 'prometheus.io/path')
- //
- // +optional
- // +kubebuilder:validation:Optional
- DisablePrometheusAnnotations bool `json:"disablePrometheusAnnotations,omitempty"`
-}
-
// ScaleSubresourceStatus defines the observed state of the OpenTelemetryCollector's
// scale subresource.
type ScaleSubresourceStatus struct {
diff --git a/apis/v1beta1/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go
index 80cddf7dd0..44643cdd4c 100644
--- a/apis/v1beta1/zz_generated.deepcopy.go
+++ b/apis/v1beta1/zz_generated.deepcopy.go
@@ -19,91 +19,12 @@
package v1beta1
import (
- "k8s.io/api/autoscaling/v2"
- "k8s.io/api/core/v1"
- networkingv1 "k8s.io/api/networking/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
+ corev1 "k8s.io/api/core/v1"
+ "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/runtime"
- "k8s.io/apimachinery/pkg/util/intstr"
)
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *AutoscalerSpec) DeepCopyInto(out *AutoscalerSpec) {
- *out = *in
- if in.MinReplicas != nil {
- in, out := &in.MinReplicas, &out.MinReplicas
- *out = new(int32)
- **out = **in
- }
- if in.MaxReplicas != nil {
- in, out := &in.MaxReplicas, &out.MaxReplicas
- *out = new(int32)
- **out = **in
- }
- if in.Behavior != nil {
- in, out := &in.Behavior, &out.Behavior
- *out = new(v2.HorizontalPodAutoscalerBehavior)
- (*in).DeepCopyInto(*out)
- }
- if in.Metrics != nil {
- in, out := &in.Metrics, &out.Metrics
- *out = make([]MetricSpec, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.TargetCPUUtilization != nil {
- in, out := &in.TargetCPUUtilization, &out.TargetCPUUtilization
- *out = new(int32)
- **out = **in
- }
- if in.TargetMemoryUtilization != nil {
- in, out := &in.TargetMemoryUtilization, &out.TargetMemoryUtilization
- *out = new(int32)
- **out = **in
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoscalerSpec.
-func (in *AutoscalerSpec) DeepCopy() *AutoscalerSpec {
- if in == nil {
- return nil
- }
- out := new(AutoscalerSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *Config) DeepCopyInto(out *Config) {
- *out = *in
- in.Receivers.DeepCopyInto(&out.Receivers)
- in.Exporters.DeepCopyInto(&out.Exporters)
- if in.Processors != nil {
- in, out := &in.Processors, &out.Processors
- *out = (*in).DeepCopy()
- }
- if in.Connectors != nil {
- in, out := &in.Connectors, &out.Connectors
- *out = (*in).DeepCopy()
- }
- if in.Extensions != nil {
- in, out := &in.Extensions, &out.Extensions
- *out = (*in).DeepCopy()
- }
- in.Service.DeepCopyInto(&out.Service)
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config.
-func (in *Config) DeepCopy() *Config {
- if in == nil {
- return nil
- }
- out := new(Config)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ConfigMapsSpec) DeepCopyInto(out *ConfigMapsSpec) {
*out = *in
@@ -131,7 +52,7 @@ func (in *Ingress) DeepCopyInto(out *Ingress) {
}
if in.TLS != nil {
in, out := &in.TLS, &out.TLS
- *out = make([]networkingv1.IngressTLS, len(*in))
+ *out = make([]v1.IngressTLS, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
@@ -154,72 +75,6 @@ func (in *Ingress) DeepCopy() *Ingress {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *MetricSpec) DeepCopyInto(out *MetricSpec) {
- *out = *in
- if in.Pods != nil {
- in, out := &in.Pods, &out.Pods
- *out = new(v2.PodsMetricSource)
- (*in).DeepCopyInto(*out)
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricSpec.
-func (in *MetricSpec) DeepCopy() *MetricSpec {
- if in == nil {
- return nil
- }
- out := new(MetricSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *MetricsConfig) DeepCopyInto(out *MetricsConfig) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsConfig.
-func (in *MetricsConfig) DeepCopy() *MetricsConfig {
- if in == nil {
- return nil
- }
- out := new(MetricsConfig)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *MetricsConfigSpec) DeepCopyInto(out *MetricsConfigSpec) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsConfigSpec.
-func (in *MetricsConfigSpec) DeepCopy() *MetricsConfigSpec {
- if in == nil {
- return nil
- }
- out := new(MetricsConfigSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *ObservabilitySpec) DeepCopyInto(out *ObservabilitySpec) {
- *out = *in
- out.Metrics = in.Metrics
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObservabilitySpec.
-func (in *ObservabilitySpec) DeepCopy() *ObservabilitySpec {
- if in == nil {
- return nil
- }
- out := new(ObservabilitySpec)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *OpenShiftRoute) DeepCopyInto(out *OpenShiftRoute) {
*out = *in
@@ -342,194 +197,6 @@ func (in *OpenTelemetryCollectorStatus) DeepCopy() *OpenTelemetryCollectorStatus
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *OpenTelemetryCommonFields) DeepCopyInto(out *OpenTelemetryCommonFields) {
- *out = *in
- in.Resources.DeepCopyInto(&out.Resources)
- if in.NodeSelector != nil {
- in, out := &in.NodeSelector, &out.NodeSelector
- *out = make(map[string]string, len(*in))
- for key, val := range *in {
- (*out)[key] = val
- }
- }
- if in.Args != nil {
- in, out := &in.Args, &out.Args
- *out = make(map[string]string, len(*in))
- for key, val := range *in {
- (*out)[key] = val
- }
- }
- if in.Replicas != nil {
- in, out := &in.Replicas, &out.Replicas
- *out = new(int32)
- **out = **in
- }
- if in.Autoscaler != nil {
- in, out := &in.Autoscaler, &out.Autoscaler
- *out = new(AutoscalerSpec)
- (*in).DeepCopyInto(*out)
- }
- if in.PodDisruptionBudget != nil {
- in, out := &in.PodDisruptionBudget, &out.PodDisruptionBudget
- *out = new(PodDisruptionBudgetSpec)
- (*in).DeepCopyInto(*out)
- }
- if in.SecurityContext != nil {
- in, out := &in.SecurityContext, &out.SecurityContext
- *out = new(v1.SecurityContext)
- (*in).DeepCopyInto(*out)
- }
- if in.PodSecurityContext != nil {
- in, out := &in.PodSecurityContext, &out.PodSecurityContext
- *out = new(v1.PodSecurityContext)
- (*in).DeepCopyInto(*out)
- }
- if in.PodAnnotations != nil {
- in, out := &in.PodAnnotations, &out.PodAnnotations
- *out = make(map[string]string, len(*in))
- for key, val := range *in {
- (*out)[key] = val
- }
- }
- if in.VolumeMounts != nil {
- in, out := &in.VolumeMounts, &out.VolumeMounts
- *out = make([]v1.VolumeMount, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.Ports != nil {
- in, out := &in.Ports, &out.Ports
- *out = make([]PortsSpec, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.Env != nil {
- in, out := &in.Env, &out.Env
- *out = make([]v1.EnvVar, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.EnvFrom != nil {
- in, out := &in.EnvFrom, &out.EnvFrom
- *out = make([]v1.EnvFromSource, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.VolumeClaimTemplates != nil {
- in, out := &in.VolumeClaimTemplates, &out.VolumeClaimTemplates
- *out = make([]v1.PersistentVolumeClaim, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.Tolerations != nil {
- in, out := &in.Tolerations, &out.Tolerations
- *out = make([]v1.Toleration, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.Volumes != nil {
- in, out := &in.Volumes, &out.Volumes
- *out = make([]v1.Volume, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.Affinity != nil {
- in, out := &in.Affinity, &out.Affinity
- *out = new(v1.Affinity)
- (*in).DeepCopyInto(*out)
- }
- if in.Lifecycle != nil {
- in, out := &in.Lifecycle, &out.Lifecycle
- *out = new(v1.Lifecycle)
- (*in).DeepCopyInto(*out)
- }
- if in.TerminationGracePeriodSeconds != nil {
- in, out := &in.TerminationGracePeriodSeconds, &out.TerminationGracePeriodSeconds
- *out = new(int64)
- **out = **in
- }
- if in.TopologySpreadConstraints != nil {
- in, out := &in.TopologySpreadConstraints, &out.TopologySpreadConstraints
- *out = make([]v1.TopologySpreadConstraint, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.InitContainers != nil {
- in, out := &in.InitContainers, &out.InitContainers
- *out = make([]v1.Container, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.AdditionalContainers != nil {
- in, out := &in.AdditionalContainers, &out.AdditionalContainers
- *out = make([]v1.Container, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenTelemetryCommonFields.
-func (in *OpenTelemetryCommonFields) DeepCopy() *OpenTelemetryCommonFields {
- if in == nil {
- return nil
- }
- out := new(OpenTelemetryCommonFields)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *PodDisruptionBudgetSpec) DeepCopyInto(out *PodDisruptionBudgetSpec) {
- *out = *in
- if in.MinAvailable != nil {
- in, out := &in.MinAvailable, &out.MinAvailable
- *out = new(intstr.IntOrString)
- **out = **in
- }
- if in.MaxUnavailable != nil {
- in, out := &in.MaxUnavailable, &out.MaxUnavailable
- *out = new(intstr.IntOrString)
- **out = **in
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodDisruptionBudgetSpec.
-func (in *PodDisruptionBudgetSpec) DeepCopy() *PodDisruptionBudgetSpec {
- if in == nil {
- return nil
- }
- out := new(PodDisruptionBudgetSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *PortsSpec) DeepCopyInto(out *PortsSpec) {
- *out = *in
- in.ServicePort.DeepCopyInto(&out.ServicePort)
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortsSpec.
-func (in *PortsSpec) DeepCopy() *PortsSpec {
- if in == nil {
- return nil
- }
- out := new(PortsSpec)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Probe) DeepCopyInto(out *Probe) {
*out = *in
@@ -590,62 +257,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 *Service) DeepCopyInto(out *Service) {
- *out = *in
- if in.Extensions != nil {
- in, out := &in.Extensions, &out.Extensions
- *out = new([]string)
- if **in != nil {
- in, out := *in, *out
- *out = make([]string, len(*in))
- copy(*out, *in)
- }
- }
- if in.Telemetry != nil {
- in, out := &in.Telemetry, &out.Telemetry
- *out = (*in).DeepCopy()
- }
- in.Pipelines.DeepCopyInto(&out.Pipelines)
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Service.
-func (in *Service) DeepCopy() *Service {
- if in == nil {
- return nil
- }
- out := new(Service)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *TargetAllocator) DeepCopyInto(out *TargetAllocator) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
- in.Spec.DeepCopyInto(&out.Spec)
- out.Status = in.Status
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocator.
-func (in *TargetAllocator) DeepCopy() *TargetAllocator {
- if in == nil {
- return nil
- }
- out := new(TargetAllocator)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *TargetAllocator) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TargetAllocatorEmbedded) DeepCopyInto(out *TargetAllocatorEmbedded) {
*out = *in
@@ -664,37 +275,37 @@ func (in *TargetAllocatorEmbedded) DeepCopyInto(out *TargetAllocatorEmbedded) {
in.Resources.DeepCopyInto(&out.Resources)
if in.Affinity != nil {
in, out := &in.Affinity, &out.Affinity
- *out = new(v1.Affinity)
+ *out = new(corev1.Affinity)
(*in).DeepCopyInto(*out)
}
in.PrometheusCR.DeepCopyInto(&out.PrometheusCR)
if in.SecurityContext != nil {
in, out := &in.SecurityContext, &out.SecurityContext
- *out = new(v1.SecurityContext)
+ *out = new(corev1.SecurityContext)
(*in).DeepCopyInto(*out)
}
if in.PodSecurityContext != nil {
in, out := &in.PodSecurityContext, &out.PodSecurityContext
- *out = new(v1.PodSecurityContext)
+ *out = new(corev1.PodSecurityContext)
(*in).DeepCopyInto(*out)
}
if in.TopologySpreadConstraints != nil {
in, out := &in.TopologySpreadConstraints, &out.TopologySpreadConstraints
- *out = make([]v1.TopologySpreadConstraint, len(*in))
+ *out = make([]corev1.TopologySpreadConstraint, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Tolerations != nil {
in, out := &in.Tolerations, &out.Tolerations
- *out = make([]v1.Toleration, len(*in))
+ *out = make([]corev1.Toleration, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Env != nil {
in, out := &in.Env, &out.Env
- *out = make([]v1.EnvVar, len(*in))
+ *out = make([]corev1.EnvVar, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
@@ -702,7 +313,7 @@ func (in *TargetAllocatorEmbedded) DeepCopyInto(out *TargetAllocatorEmbedded) {
out.Observability = in.Observability
if in.PodDisruptionBudget != nil {
in, out := &in.PodDisruptionBudget, &out.PodDisruptionBudget
- *out = new(PodDisruptionBudgetSpec)
+ *out = new(common.PodDisruptionBudgetSpec)
(*in).DeepCopyInto(*out)
}
}
@@ -716,138 +327,3 @@ func (in *TargetAllocatorEmbedded) DeepCopy() *TargetAllocatorEmbedded {
in.DeepCopyInto(out)
return out
}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *TargetAllocatorList) DeepCopyInto(out *TargetAllocatorList) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ListMeta.DeepCopyInto(&out.ListMeta)
- if in.Items != nil {
- in, out := &in.Items, &out.Items
- *out = make([]OpenTelemetryCollector, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorList.
-func (in *TargetAllocatorList) DeepCopy() *TargetAllocatorList {
- if in == nil {
- return nil
- }
- out := new(TargetAllocatorList)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *TargetAllocatorList) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *TargetAllocatorPrometheusCR) DeepCopyInto(out *TargetAllocatorPrometheusCR) {
- *out = *in
- if in.ScrapeInterval != nil {
- in, out := &in.ScrapeInterval, &out.ScrapeInterval
- *out = new(metav1.Duration)
- **out = **in
- }
- if in.PodMonitorSelector != nil {
- in, out := &in.PodMonitorSelector, &out.PodMonitorSelector
- *out = new(metav1.LabelSelector)
- (*in).DeepCopyInto(*out)
- }
- if in.ServiceMonitorSelector != nil {
- in, out := &in.ServiceMonitorSelector, &out.ServiceMonitorSelector
- *out = new(metav1.LabelSelector)
- (*in).DeepCopyInto(*out)
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorPrometheusCR.
-func (in *TargetAllocatorPrometheusCR) DeepCopy() *TargetAllocatorPrometheusCR {
- if in == nil {
- return nil
- }
- out := new(TargetAllocatorPrometheusCR)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *TargetAllocatorSpec) DeepCopyInto(out *TargetAllocatorSpec) {
- *out = *in
- in.OpenTelemetryCommonFields.DeepCopyInto(&out.OpenTelemetryCommonFields)
- in.CollectorSelector.DeepCopyInto(&out.CollectorSelector)
- if in.ScrapeConfigs != nil {
- in, out := &in.ScrapeConfigs, &out.ScrapeConfigs
- *out = make([]AnyConfig, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- in.PrometheusCR.DeepCopyInto(&out.PrometheusCR)
- out.Observability = in.Observability
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorSpec.
-func (in *TargetAllocatorSpec) DeepCopy() *TargetAllocatorSpec {
- if in == nil {
- return nil
- }
- out := new(TargetAllocatorSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *TargetAllocatorStatus) DeepCopyInto(out *TargetAllocatorStatus) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorStatus.
-func (in *TargetAllocatorStatus) DeepCopy() *TargetAllocatorStatus {
- if in == nil {
- return nil
- }
- out := new(TargetAllocatorStatus)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *Telemetry) DeepCopyInto(out *Telemetry) {
- *out = *in
- out.Metrics = in.Metrics
- if in.Resource != nil {
- in, out := &in.Resource, &out.Resource
- *out = make(map[string]*string, len(*in))
- for key, val := range *in {
- var outVal *string
- if val == nil {
- (*out)[key] = nil
- } else {
- inVal := (*in)[key]
- in, out := &inVal, &outVal
- *out = new(string)
- **out = **in
- }
- (*out)[key] = outVal
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Telemetry.
-func (in *Telemetry) DeepCopy() *Telemetry {
- if in == nil {
- return nil
- }
- out := new(Telemetry)
- in.DeepCopyInto(out)
- return out
-}
diff --git a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
index 9facf2f1aa..2310cc5400 100644
--- a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
+++ b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
@@ -2921,6 +2921,9 @@ spec:
type: array
filterStrategy:
default: relabel-config
+ enum:
+ - ""
+ - relabel-config
type: string
image:
type: string
diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
index b17a8dede1..b3729cdcc4 100644
--- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
+++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
@@ -2907,6 +2907,9 @@ spec:
type: array
filterStrategy:
default: relabel-config
+ enum:
+ - ""
+ - relabel-config
type: string
image:
type: string
diff --git a/config/crd/bases/opentelemetry.io_targetallocators.yaml b/config/crd/bases/opentelemetry.io_targetallocators.yaml
index 7d59d689c6..30346ed44f 100644
--- a/config/crd/bases/opentelemetry.io_targetallocators.yaml
+++ b/config/crd/bases/opentelemetry.io_targetallocators.yaml
@@ -14,7 +14,7 @@ spec:
singular: targetallocator
scope: Namespaced
versions:
- - name: v1beta1
+ - name: v1alpha1
schema:
openAPIV3Schema:
properties:
diff --git a/controllers/builder_test.go b/controllers/builder_test.go
index 5614b3fc80..6f94dcc69b 100644
--- a/controllers/builder_test.go
+++ b/controllers/builder_test.go
@@ -32,6 +32,7 @@ import (
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
"github.com/open-telemetry/opentelemetry-operator/internal/config"
@@ -83,7 +84,7 @@ service:
exporters: [logging]
`
- goodConfig := v1beta1.Config{}
+ goodConfig := common.Config{}
err := go_yaml.Unmarshal([]byte(goodConfigYaml), &goodConfig)
require.NoError(t, err)
one := int32(1)
@@ -105,7 +106,7 @@ service:
Namespace: "test",
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
},
@@ -345,7 +346,7 @@ service:
Namespace: "test",
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
},
@@ -634,7 +635,7 @@ service:
Namespace: "test",
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
ServiceAccount: "my-special-sa",
@@ -1126,7 +1127,7 @@ service:
exporters: [logging]
`
- goodConfig := v1beta1.Config{}
+ goodConfig := common.Config{}
err := go_yaml.Unmarshal([]byte(goodConfigYaml), &goodConfig)
require.NoError(t, err)
one := int32(1)
@@ -1149,7 +1150,7 @@ service:
Namespace: "test",
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
},
@@ -1158,7 +1159,7 @@ service:
TargetAllocator: v1beta1.TargetAllocatorEmbedded{
Enabled: true,
FilterStrategy: "relabel-config",
- PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{
+ PrometheusCR: common.TargetAllocatorPrometheusCR{
Enabled: true,
},
},
@@ -1538,7 +1539,7 @@ prometheus_cr:
Namespace: "test",
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
- OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
+ OpenTelemetryCommonFields: common.OpenTelemetryCommonFields{
Image: "test",
Replicas: &one,
},
@@ -1546,12 +1547,12 @@ prometheus_cr:
Config: goodConfig,
TargetAllocator: v1beta1.TargetAllocatorEmbedded{
Enabled: true,
- PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{
+ PrometheusCR: common.TargetAllocatorPrometheusCR{
Enabled: true,
},
FilterStrategy: "relabel-config",
- Observability: v1beta1.ObservabilitySpec{
- Metrics: v1beta1.MetricsConfigSpec{
+ Observability: common.ObservabilitySpec{
+ Metrics: common.MetricsConfigSpec{
EnableMetrics: true,
},
},
diff --git a/controllers/opentelemetrycollector_controller.go b/controllers/opentelemetrycollector_controller.go
index 258c5fadfc..1d39abbd6b 100644
--- a/controllers/opentelemetrycollector_controller.go
+++ b/controllers/opentelemetrycollector_controller.go
@@ -36,6 +36,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
+ "github.com/open-telemetry/opentelemetry-operator/apis/common"
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/openshift"
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/prometheus"
@@ -197,7 +198,7 @@ func (r *OpenTelemetryCollectorReconciler) Reconcile(ctx context.Context, req ct
return ctrl.Result{}, nil
}
- if instance.Spec.ManagementState == v1beta1.ManagementStateUnmanaged {
+ if instance.Spec.ManagementState == common.ManagementStateUnmanaged {
log.Info("Skipping reconciliation for unmanaged OpenTelemetryCollector resource", "name", req.String())
// Stop requeueing for unmanaged OpenTelemetryCollector custom resources
return ctrl.Result{}, nil
diff --git a/docs/api.md b/docs/api.md
index 8235f45406..7ca5859069 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -21589,12 +21589,13 @@ consumed in the config file for the TargetAllocator.